-
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
134 additions
and
46 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,42 +1,41 @@ | ||
import { Badge } from "../../../packages/design-system/src/badge"; | ||
import { Meta, StoryObj } from '@storybook/react'; | ||
import { Badge } from "../../../packages/design-system/src/badge"; | ||
import { Meta, StoryObj } from "@storybook/react"; | ||
|
||
export default { | ||
|
||
title: 'Components/Badge', | ||
title: "Components/Badge", | ||
component: Badge, | ||
argTypes: { | ||
color: { control: 'color' }, | ||
icon: { control: 'boolean' }, | ||
color: { control: "color" }, | ||
icon: { control: "boolean" }, | ||
variant: { | ||
control: { type: 'select', options: ['neutral', 'primary', 'secondary'] }, | ||
control: { type: "select", options: ["neutral", "primary", "secondary"] }, | ||
}, | ||
}, | ||
tags: ['autodocs'], | ||
tags: ["autodocs"], | ||
} as Meta; | ||
|
||
type Story = StoryObj<typeof Badge>; | ||
type Story = StoryObj<typeof Badge>; | ||
|
||
export const Neutral : Story = { | ||
export const Neutral: Story = { | ||
args: { | ||
icon: false, | ||
variant: 'neutral', | ||
children: 'Label', | ||
variant: "neutral", | ||
children: "Label", | ||
}, | ||
}; | ||
|
||
export const Primary : Story = { | ||
args : { | ||
export const Primary: Story = { | ||
args: { | ||
icon: true, | ||
variant: 'primary', | ||
children: 'Label', | ||
} | ||
variant: "primary", | ||
children: "Label", | ||
}, | ||
}; | ||
|
||
export const Secondary : Story = { | ||
args : { | ||
export const Secondary: Story = { | ||
args: { | ||
icon: false, | ||
variant: 'secondary', | ||
children: 'Label', | ||
} | ||
variant: "secondary", | ||
children: "Label", | ||
}, | ||
}; |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -17,4 +17,4 @@ function BadgeStarIcon() { | |
); | ||
} | ||
|
||
export default BadgeStarIcon; | ||
export default BadgeStarIcon; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,34 +1,38 @@ | ||
import React from 'react'; | ||
import BadgeStarIcon from "./Badge/BadgeStarIcon" | ||
import React from "react"; | ||
import BadgeStarIcon from "./Badge/BadgeStarIcon"; | ||
|
||
export interface BadgeProps { | ||
icon?: boolean; | ||
variant?: 'neutral' | 'secondary' | 'primary'; | ||
variant?: "neutral" | "secondary" | "primary"; | ||
children: React.ReactNode; | ||
} | ||
|
||
const Badge: React.FC<BadgeProps> = ({ icon = false, variant = 'primary', children }) => { | ||
const showIcon = icon || variant === 'primary'; | ||
const neutralVariant = variant === 'primary' || variant === 'neutral' | ||
|
||
const Badge: React.FC<BadgeProps> = ({ | ||
icon = false, | ||
variant = "primary", | ||
children, | ||
}) => { | ||
const showIcon = icon || variant === "primary"; | ||
const neutralVariant = variant === "primary" || variant === "neutral"; | ||
|
||
return ( | ||
<div className={ | ||
`k1-flex k1-flex-row k1-justify-center k1-items-center rounded-[0.375rem] px-[0.5rem] py-[0.25rem] k1-gap-1 m-0 font-bold uppercase relative ${showIcon ? 'k1-w-[4.5rem]' : 'k1-w-[3.125rem]'} ${showIcon ? 'k1-h-[1.625rem]' : 'k1-h-[1.5rem]'}` | ||
}> | ||
{showIcon && <div className="k1-inline-block k1-items-center"><BadgeStarIcon/></div>} | ||
<div className = { | ||
`flex text-[0.625rem] font-bold leading-[1.125rem] k1-border-hidden k1-outline-none w-[2.125rem] h-[1.125rem] k1-items-center k1-justify-center k1-inline-block | ||
${neutralVariant ? 'k1-text-[#565252]' : 'k1-text-[#821414]'} | ||
${neutralVariant ? 'bg-[#FFF4F5]' : 'bg-[#F8F7F7]'}` | ||
} | ||
> | ||
<div | ||
className={`k1-flex k1-flex-row k1-justify-center k1-items-center rounded-[0.375rem] px-[0.5rem] py-[0.25rem] k1-gap-1 m-0 font-bold uppercase relative ${showIcon ? "k1-w-[4.5rem]" : "k1-w-[3.125rem]"} ${showIcon ? "k1-h-[1.625rem]" : "k1-h-[1.5rem]"}`} | ||
> | ||
{showIcon && ( | ||
<div className="k1-inline-block k1-items-center"> | ||
<BadgeStarIcon /> | ||
</div> | ||
)} | ||
<div | ||
className={`flex text-[0.625rem] font-bold leading-[1.125rem] k1-border-hidden k1-outline-none w-[2.125rem] h-[1.125rem] k1-items-center k1-justify-center k1-inline-block | ||
${neutralVariant ? "k1-text-[#565252]" : "k1-text-[#821414]"} | ||
${neutralVariant ? "bg-[#FFF4F5]" : "bg-[#F8F7F7]"}`} | ||
> | ||
{children} | ||
</div> | ||
</div> | ||
); | ||
}; | ||
|
||
export { Badge }; | ||
|
||
|
||
|