-
Notifications
You must be signed in to change notification settings - Fork 1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[FEAT] Chip 컴포넌트,스토리북 구현 #52
Changes from all commits
9979205
2e6bf73
2c7d0a4
fc6697b
3d0a0fb
6dda7d9
1946a9a
8323f82
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
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>; | ||
}, | ||
}; |
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; | ||
}; |
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', | ||
}, | ||
}); |
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> | ||||||||||||||||||||||||||||||||||||||||
); | ||||||||||||||||||||||||||||||||||||||||
}; | ||||||||||||||||||||||||||||||||||||||||
Comment on lines
+4
to
+10
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🛠️ Refactor suggestion 접근성 개선이 필요합니다 다음과 같은 접근성 관련 속성들을 추가하는 것이 좋습니다: -export const Chip = ({ variant, children, ...props }: Props) => {
+export const Chip = ({ variant, children, role = "status", ...props }: Props) => {
return (
<span
+ role={role}
+ aria-label={typeof children === 'string' ? children : undefined}
className={ChipVariants({ variant })}
{...props}
>
{children}
</span>
);
}; 📝 Committable suggestion
Suggested change
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🛠️ Refactor suggestion
접근성 개선을 위한 aria-label 속성 추가를 권장드립니다.
스크린 리더 사용자를 위해 Chip의 목적을 설명하는 aria-label을 추가하면 좋을 것 같습니다.
📝 Committable suggestion