-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
[FEAT] Chip 컴포넌트,스토리북 구현
- Loading branch information
Showing
7 changed files
with
69 additions
and
2 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
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,32 @@ | ||
/* eslint-disable no-restricted-exports */ | ||
import type { Meta, StoryObj } from '@storybook/react'; | ||
|
||
import { Chip } from '.'; | ||
|
||
const meta = { | ||
title: 'components/common/Chip', | ||
component: Chip, | ||
tags: ['autodocs'], | ||
} satisfies Meta<typeof Chip>; | ||
|
||
export default meta; | ||
type Story = StoryObj<typeof Chip>; | ||
|
||
export const Basic: Story = { | ||
args: { | ||
variant: 'medium', | ||
children: '카페', | ||
}, | ||
argTypes: { | ||
variant: { | ||
control: 'inline-radio', | ||
options: ['small', 'medium', 'large'], | ||
}, | ||
children: { | ||
control: 'text', | ||
}, | ||
}, | ||
render: (args) => { | ||
return <Chip variant={args.variant}>{args.children}</Chip>; | ||
}, | ||
}; |
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,11 @@ | ||
export type Props = { | ||
/** | ||
* The variant of the Chip. | ||
* @default 'large' | ||
*/ | ||
variant: 'small' | 'medium' | 'large'; | ||
/** | ||
* content to be displayed within the Chip component. | ||
*/ | ||
children: string; | ||
}; |
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,14 @@ | ||
import { cva } from 'class-variance-authority'; | ||
|
||
export const ChipVariants = cva(`bg-primary rounded-md text-white cursor-default px-3 py-1`, { | ||
variants: { | ||
variant: { | ||
small: 'h-6 min-w-6 text-caption', | ||
medium: 'h-7 min-w-7 text-body4', | ||
large: 'h-8 min-w-8 text-body3', | ||
}, | ||
}, | ||
defaultVariants: { | ||
variant: 'medium', | ||
}, | ||
}); |
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,10 @@ | ||
import { Props } from './Chip.types'; | ||
import { ChipVariants } from './Chip.variants'; | ||
|
||
export const Chip = ({ variant, children, ...props }: Props) => { | ||
return ( | ||
<span className={ChipVariants({ variant })} {...props}> | ||
{children} | ||
</span> | ||
); | ||
}; |
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