-
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.
- Loading branch information
Showing
4 changed files
with
141 additions
and
1 deletion.
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,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: { | ||
neutral: { | ||
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' }, | ||
}, | ||
], | ||
}); |
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,53 @@ | ||
import { forwardRef } from 'react'; | ||
import type { HTMLAttributes, ReactNode } from 'react'; | ||
import * as styles from './Badge.css'; | ||
|
||
export type BadgeSize = 'medium' | 'large'; | ||
export type BadgeVariant = 'neutral' | 'primary' | 'pink' | 'blue'; | ||
export type BadgeShape = 'round' | 'square'; | ||
|
||
type BadgeCombination = | ||
| { | ||
size: Extract<BadgeSize, 'medium'>; | ||
variant: Extract<BadgeVariant, 'neutral'>; | ||
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, 'neutral'>; | ||
shape: Extract<BadgeShape, 'square'>; | ||
}; | ||
|
||
export type BadgeProps = HTMLAttributes<HTMLSpanElement> & | ||
BadgeCombination & { | ||
children: ReactNode; | ||
}; | ||
|
||
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> | ||
) | ||
); | ||
|
||
Badge.displayName = '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