Skip to content

Commit

Permalink
add rest props spread for using ProjectBadge in the OSS Banner context (
Browse files Browse the repository at this point in the history
#91)

* add rest props spread for using ProjectBadge in the OSS Banner context

* add svg element props to ProjectBadge and a new story to test

---------

Co-authored-by: Christy Presler <[email protected]>
  • Loading branch information
cpresler and cpresler authored Apr 22, 2024
1 parent a4c7267 commit 5efa237
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 2 deletions.
6 changes: 6 additions & 0 deletions .changeset/kind-candles-fail.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
"formidable-oss-badges": patch
---

Enable ProjectBadge to accept additional props for use in OSS Banner - matching
FeaturedBadge"
16 changes: 16 additions & 0 deletions src/ProjectBadge.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,3 +17,19 @@ ReactLiveBadge.args = {
color: "skyblue",
simple: false,
}

const BannerTemplate: ComponentStory<typeof ProjectBadge> = args => (
<ProjectBadge {...args} />
)

export const ReactNativeBadge = BannerTemplate.bind({})
ReactNativeBadge.args = {
abbreviation: "Re",
description: "React Native",
color: "skyblue",
simple: true,
x: "40",
y: "160",
width: "200",
height: "200",
}
7 changes: 5 additions & 2 deletions src/ProjectBadge.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React, { CSSProperties, Fragment } from "react"
import React, { CSSProperties, Fragment, SVGProps } from "react"
import clsx from "clsx"
import reducerFn from "./reducerFn"
import styles from "./styles.module.css"
Expand All @@ -7,7 +7,7 @@ const BLACK = "#202020"
const BASE_Y = 58
const includesDescender = (str: string) => RegExp(`[gjpqy]`).test(str)

type Props = {
type Props = SVGProps<SVGSVGElement> & {
color?: string
abbreviation: string
description: string
Expand Down Expand Up @@ -52,6 +52,8 @@ const ProjectBadge = (props: Props) => {
style,
isHoverable = true,
simple = false,
description,
...rest
} = props
let baseY = BASE_Y
if (simple) {
Expand All @@ -64,6 +66,7 @@ const ProjectBadge = (props: Props) => {
viewBox="0 0 600 595"
className={clsx(isHoverable && styles.hoverableLogo, className)}
style={style}
{...rest}
>
<g fill="none" fillRule="evenodd">
<path
Expand Down

0 comments on commit 5efa237

Please sign in to comment.