-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Feature/BAR-89] Badge 컴포넌트 구현 (#22)
- Loading branch information
Showing
5 changed files
with
121 additions
and
0 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 |
---|---|---|
@@ -0,0 +1,38 @@ | ||
import type { Meta, StoryObj } from '@storybook/react'; | ||
|
||
import Badge from './Badge'; | ||
import { BADGE_TYPE } from './constants'; | ||
|
||
const meta: Meta<typeof Badge> = { | ||
title: 'Components/Badge', | ||
component: Badge, | ||
parameters: { | ||
componentSubtitle: '카테고리를 나타내는 컴포넌트', | ||
}, | ||
}; | ||
|
||
export default meta; | ||
|
||
type Story = StoryObj<typeof Badge>; | ||
|
||
export const Basic: Story = { | ||
args: { | ||
children: '부탁하기', | ||
color: 'blue', | ||
}, | ||
render: (args) => <Badge color={args.color}>{args.children}</Badge>, | ||
}; | ||
|
||
export const AllBadges: Story = { | ||
render: () => ( | ||
<div style={{ display: 'flex', gap: '8px' }}> | ||
<Badge color={BADGE_TYPE['부탁하기']}>부탁하기</Badge> | ||
<Badge color={BADGE_TYPE['보고하기']}>보고하기</Badge> | ||
<Badge color={BADGE_TYPE['축하하기']}>축하하기</Badge> | ||
<Badge color={BADGE_TYPE['위로하기']}>위로하기</Badge> | ||
<Badge color={BADGE_TYPE['감사 전하기']}>감사 전하기</Badge> | ||
<Badge color={BADGE_TYPE['안부 전하기']}>안부 전하기</Badge> | ||
<Badge color={BADGE_TYPE['기타']}>기타</Badge> | ||
</div> | ||
), | ||
}; |
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 |
---|---|---|
@@ -0,0 +1,21 @@ | ||
import type { PropsWithChildren } from 'react'; | ||
|
||
import * as styles from './style.css'; | ||
|
||
interface BadgeProps { | ||
color: | ||
| 'blue' | ||
| 'green' | ||
| 'yellow' | ||
| 'red' | ||
| 'orange' | ||
| 'purple' | ||
| 'grey' | ||
| 'black'; | ||
} | ||
|
||
const Badge = ({ children, color }: PropsWithChildren<BadgeProps>) => { | ||
return <span className={styles.badge({ color })}>{children}</span>; | ||
}; | ||
|
||
export default Badge; |
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 |
---|---|---|
@@ -0,0 +1,9 @@ | ||
export const BADGE_TYPE = { | ||
부탁하기: 'blue', | ||
보고하기: 'orange', | ||
축하하기: 'green', | ||
위로하기: 'purple', | ||
'감사 전하기': 'red', | ||
'안부 전하기': 'yellow', | ||
기타: 'black', | ||
} as const; |
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 |
---|---|---|
@@ -0,0 +1,47 @@ | ||
import { recipe } from '@vanilla-extract/recipes'; | ||
|
||
import { sprinkles } from '@/src/styles/sprinkles.css'; | ||
import { COLORS } from '@/src/styles/tokens'; | ||
|
||
export const badge = recipe({ | ||
base: [ | ||
sprinkles({ typography: '13/Title/Semibold' }), | ||
{ | ||
display: 'inline-block', | ||
width: 'fit-content', | ||
padding: '6px 8px', | ||
color: COLORS['Grey/White'], | ||
borderRadius: '6px', | ||
whiteSpace: 'nowrap', | ||
}, | ||
], | ||
variants: { | ||
color: { | ||
blue: { | ||
backgroundColor: COLORS['Blue/Default'], | ||
}, | ||
green: { | ||
backgroundColor: COLORS['Green'], | ||
}, | ||
yellow: { | ||
backgroundColor: COLORS['Yellow'], | ||
}, | ||
red: { | ||
backgroundColor: COLORS['LightRed'], | ||
}, | ||
orange: { | ||
backgroundColor: COLORS['Orange'], | ||
}, | ||
purple: { | ||
backgroundColor: COLORS['Purple'], | ||
}, | ||
grey: { | ||
color: COLORS['Grey/250'], | ||
backgroundColor: COLORS['Grey/600'], | ||
}, | ||
black: { | ||
backgroundColor: COLORS['Grey/800'], | ||
}, | ||
}, | ||
}, | ||
}); |
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