-
Notifications
You must be signed in to change notification settings - Fork 0
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] Badge 컴포넌트 구현 #58
Changes from 2 commits
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,68 @@ | ||
import { recipe } from '@vanilla-extract/recipes'; | ||
import { vars } from '@repo/theme'; | ||
|
||
export const badge = recipe({ | ||
base: { | ||
display: 'inline-flex', | ||
alignItems: 'center', | ||
justifyContent: 'center', | ||
whiteSpace: 'nowrap', | ||
height: 'fit-content', | ||
}, | ||
|
||
variants: { | ||
size: { | ||
medium: { | ||
fontSize: vars.typography.fontSize[14], | ||
fontWeight: vars.typography.fontWeight.medium, | ||
lineHeight: '150%', | ||
}, | ||
large: { | ||
fontSize: vars.typography.fontSize[20], | ||
fontWeight: vars.typography.fontWeight.semibold, | ||
lineHeight: '150%', | ||
}, | ||
}, | ||
variant: { | ||
neautral: { | ||
backgroundColor: vars.colors.grey50, | ||
color: vars.colors.grey600, | ||
}, | ||
primary: { | ||
backgroundColor: vars.colors.primary600, | ||
color: vars.colors.grey, | ||
}, | ||
pink: { | ||
backgroundColor: vars.colors.pink200, | ||
color: vars.colors.grey600, | ||
}, | ||
blue: { | ||
backgroundColor: vars.colors.blue200, | ||
color: vars.colors.grey600, | ||
}, | ||
}, | ||
shape: { | ||
round: { | ||
borderRadius: 100, | ||
}, | ||
square: { | ||
borderRadius: '4px', | ||
}, | ||
}, | ||
}, | ||
|
||
compoundVariants: [ | ||
{ | ||
variants: { shape: 'round', size: 'medium' }, | ||
style: { padding: '4px 10px' }, | ||
}, | ||
{ | ||
variants: { shape: 'square', size: 'medium' }, | ||
style: { padding: '2px 6px' }, | ||
}, | ||
{ | ||
variants: { shape: 'square', size: 'large' }, | ||
style: { padding: '4px 8px' }, | ||
}, | ||
], | ||
}); |
Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
@@ -0,0 +1,53 @@ | ||||||||||||||||||||||||||||||||||||||||||||||||||
import { forwardRef } from 'react'; | ||||||||||||||||||||||||||||||||||||||||||||||||||
import type { HTMLAttributes } from 'react'; | ||||||||||||||||||||||||||||||||||||||||||||||||||
import * as styles from './Badge.css'; | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||
export type BadgeSize = 'medium' | 'large'; | ||||||||||||||||||||||||||||||||||||||||||||||||||
export type BadgeVariant = 'neautral' | 'primary' | 'pink' | 'blue'; | ||||||||||||||||||||||||||||||||||||||||||||||||||
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. 'neutral' 단어 오타를 수정해주세요 'neautral'이라고 작성된 부분을 'neutral'로 수정해야 합니다. -export type BadgeVariant = 'neautral' | 'primary' | 'pink' | 'blue';
+export type BadgeVariant = 'neutral' | 'primary' | 'pink' | 'blue'; 📝 Committable suggestion
Suggested change
|
||||||||||||||||||||||||||||||||||||||||||||||||||
export type BadgeShape = 'round' | 'square'; | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||
type BadgeCombination = | ||||||||||||||||||||||||||||||||||||||||||||||||||
| { | ||||||||||||||||||||||||||||||||||||||||||||||||||
size: Extract<BadgeSize, 'medium'>; | ||||||||||||||||||||||||||||||||||||||||||||||||||
variant: Extract<BadgeVariant, 'neautral'>; | ||||||||||||||||||||||||||||||||||||||||||||||||||
shape: Extract<BadgeShape, 'round'>; | ||||||||||||||||||||||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||||||||||||||||||||||
| { | ||||||||||||||||||||||||||||||||||||||||||||||||||
size: Extract<BadgeSize, 'medium'>; | ||||||||||||||||||||||||||||||||||||||||||||||||||
variant: Extract<BadgeVariant, 'pink'>; | ||||||||||||||||||||||||||||||||||||||||||||||||||
shape: Extract<BadgeShape, 'square'>; | ||||||||||||||||||||||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||||||||||||||||||||||
| { | ||||||||||||||||||||||||||||||||||||||||||||||||||
size: Extract<BadgeSize, 'medium'>; | ||||||||||||||||||||||||||||||||||||||||||||||||||
variant: Extract<BadgeVariant, 'primary'>; | ||||||||||||||||||||||||||||||||||||||||||||||||||
shape: Extract<BadgeShape, 'round'>; | ||||||||||||||||||||||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||||||||||||||||||||||
| { | ||||||||||||||||||||||||||||||||||||||||||||||||||
size: Extract<BadgeSize, 'medium'>; | ||||||||||||||||||||||||||||||||||||||||||||||||||
variant: Extract<BadgeVariant, 'blue'>; | ||||||||||||||||||||||||||||||||||||||||||||||||||
shape: Extract<BadgeShape, 'square'>; | ||||||||||||||||||||||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||||||||||||||||||||||
| { | ||||||||||||||||||||||||||||||||||||||||||||||||||
size: Extract<BadgeSize, 'large'>; | ||||||||||||||||||||||||||||||||||||||||||||||||||
variant: Extract<BadgeVariant, 'neautral'>; | ||||||||||||||||||||||||||||||||||||||||||||||||||
shape: Extract<BadgeShape, 'square'>; | ||||||||||||||||||||||||||||||||||||||||||||||||||
}; | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||
export type BadgeProps = HTMLAttributes<HTMLSpanElement> & | ||||||||||||||||||||||||||||||||||||||||||||||||||
BadgeCombination & { | ||||||||||||||||||||||||||||||||||||||||||||||||||
children: React.ReactNode; | ||||||||||||||||||||||||||||||||||||||||||||||||||
minseong0324 marked this conversation as resolved.
Show resolved
Hide resolved
|
||||||||||||||||||||||||||||||||||||||||||||||||||
}; | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||
export const Badge = forwardRef<HTMLSpanElement, BadgeProps>( | ||||||||||||||||||||||||||||||||||||||||||||||||||
({ size, variant, shape, children, className = '', ...props }, ref) => ( | ||||||||||||||||||||||||||||||||||||||||||||||||||
<span | ||||||||||||||||||||||||||||||||||||||||||||||||||
ref={ref} | ||||||||||||||||||||||||||||||||||||||||||||||||||
className={`${styles.badge({ size, variant, shape })} ${className}`} | ||||||||||||||||||||||||||||||||||||||||||||||||||
{...props} | ||||||||||||||||||||||||||||||||||||||||||||||||||
> | ||||||||||||||||||||||||||||||||||||||||||||||||||
{children} | ||||||||||||||||||||||||||||||||||||||||||||||||||
</span> | ||||||||||||||||||||||||||||||||||||||||||||||||||
) | ||||||||||||||||||||||||||||||||||||||||||||||||||
); | ||||||||||||||||||||||||||||||||||||||||||||||||||
Comment on lines
+41
to
+51
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 접근성 속성을 추가해주세요 Badge 컴포넌트에 접근성 속성이 누락되어 있습니다. 스크린 리더 사용자를 위해 적절한 ARIA 속성을 추가하는 것이 좋습니다. <span
ref={ref}
className={`${styles.badge({ size, variant, shape })} ${className}`}
+ role="status"
+ aria-label={typeof children === 'string' ? children : undefined}
{...props}
>
{children}
</span> 📝 Committable suggestion
Suggested change
|
||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||
Badge.displayName = 'Badge'; |
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.
'neutral' 변형 이름 수정 필요
'neautral' 오타를 'neutral'로 수정해야 합니다.
📝 Committable suggestion
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.
요거 확인 부탁드려요!
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.
@kongnayeon 'neautral' 오타가 여러 파일에서 발견되었습니다. 다음 위치들도 함께 수정이 필요합니다:
packages/ui/src/components/Badge/Badge.css.ts
: variant 정의packages/ui/src/components/Badge/Badge.tsx
: BadgeVariant 타입 정의apps/web/src/app/page.tsx
: Badge 컴포넌트 사용 부분모든 'neautral'을 'neutral'로 수정해주시면 감사하겠습니다.
ʕ •ᴥ•ʔ
| |
🔗 Analysis chain
@kongnayeon 네, 'neautral'을 'neutral'로 수정하는 것이 맞습니다. 이 수정으로 Badge 컴포넌트의 variant 이름이 올바르게 표기될 것입니다. 변경사항을 적용해주시면 감사하겠습니다.
ʕ •ᴥ•ʔ
| |
🏁 Scripts executed
The following scripts were executed for the analysis:
Script:
Length of output: 637