Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
134 changes: 99 additions & 35 deletions packages/@react-spectrum/s2/src/Badge.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,12 @@ export interface BadgeStyleProps {
*
* @default 'neutral'
*/
variant: 'accent' | 'informative' | 'neutral' | 'positive' | 'notice' | 'negative' | 'gray' | 'red' | 'orange' | 'yellow' | 'charteuse' | 'celery' | 'green' | 'seafoam' | 'cyan' | 'blue' | 'indigo' | 'purple' | 'fuchsia' | 'magenta' | 'pink' | 'turquoise' | 'brown' | 'cinnamon' | 'silver'
variant?: 'accent' | 'informative' | 'neutral' | 'positive' | 'notice' | 'negative' | 'gray' | 'red' | 'orange' | 'yellow' | 'charteuse' | 'celery' | 'green' | 'seafoam' | 'cyan' | 'blue' | 'indigo' | 'purple' | 'fuchsia' | 'magenta' | 'pink' | 'turquoise' | 'brown' | 'cinnamon' | 'silver',
/**
* The fill of the badge.
* @default 'bold'
*/
fillStyle?: 'bold' | 'subtle' | 'outline'
}

export interface BadgeProps extends DOMProps, AriaLabelingProps, StyleProps, BadgeStyleProps, SlotProps {
Expand Down Expand Up @@ -73,42 +78,100 @@ const badge = style<BadgeStyleProps>({
},
columnGap: 'text-to-visual',
color: {
default: 'white',
variant: {
notice: 'black',
orange: 'black',
yellow: 'black',
charteuse: 'black',
celery: 'black'
fillStyle: {
bold: {
default: 'white',
variant: {
notice: 'black',
orange: 'black',
yellow: 'black',
charteuse: 'black',
celery: 'black'
}
},
subtle: 'gray-1000',
outline: 'gray-1000'
}
},
backgroundColor: {
variant: {
accent: 'accent',
informative: 'informative',
neutral: 'neutral-subdued',
positive: 'positive',
notice: 'notice',
negative: 'negative',
gray: 'gray',
red: 'red',
orange: 'orange',
yellow: 'yellow',
charteuse: 'chartreuse',
celery: 'celery',
green: 'green',
seafoam: 'seafoam',
cyan: 'cyan',
blue: 'blue',
indigo: 'indigo',
purple: 'purple',
fuchsia: 'fuchsia',
magenta: 'magenta',
pink: 'pink',
turquoise: 'turquoise',
brown: 'brown',
cinnamon: 'cinnamon',
silver: 'silver'
fillStyle: {
bold: {
variant: {
accent: 'accent',
informative: 'informative',
neutral: 'neutral-subdued',
positive: 'positive',
notice: 'notice',
negative: 'negative',
gray: 'gray',
red: 'red',
orange: 'orange',
yellow: 'yellow',
charteuse: 'chartreuse',
celery: 'celery',
green: 'green',
seafoam: 'seafoam',
cyan: 'cyan',
blue: 'blue',
indigo: 'indigo',
purple: 'purple',
fuchsia: 'fuchsia',
magenta: 'magenta',
pink: 'pink',
turquoise: 'turquoise',
brown: 'brown',
cinnamon: 'cinnamon',
silver: 'silver'
}
},
subtle: {
variant: {
accent: 'accent-200',
informative: 'informative-subtle',
neutral: 'neutral-subtle',
positive: 'positive-subtle',
notice: 'notice-subtle',
negative: 'negative-subtle',
gray: 'gray-100',
red: 'red-200',
orange: 'orange-200',
yellow: 'yellow-200',
charteuse: 'chartreuse-200',
celery: 'celery-200',
green: 'green-200',
seafoam: 'seafoam-200',
cyan: 'cyan-200',
blue: 'blue-200',
indigo: 'indigo-200',
purple: 'purple-200',
fuchsia: 'fuchsia-200',
magenta: 'magenta-200',
pink: 'pink-200',
turquoise: 'turquoise-200',
brown: 'brown-200',
cinnamon: 'cinnamon-200',
silver: 'silver-200'
}
},
outline: 'gray-25'
}
},
borderStyle: 'solid',
boxSizing: 'border-box',
borderWidth: 2,
borderColor: {
default: 'transparent',
fillStyle: {
outline: {
variant: {
accent: 'accent-800',
informative: 'informative-800',
neutral: 'gray-700',
positive: 'positive-700',
notice: 'notice-700',
negative: 'negative-800',
}
}
}
},
'--iconPrimary': {
Expand All @@ -123,6 +186,7 @@ function Badge(props: BadgeProps, ref: DOMRef<HTMLDivElement>) {
children,
variant = 'neutral',
size = 'S',
fillStyle = 'bold',
...otherProps
} = props; // useProviderProps(props) in v3
let domRef = useDOMRef(ref);
Expand All @@ -140,7 +204,7 @@ function Badge(props: BadgeProps, ref: DOMRef<HTMLDivElement>) {
<span
{...filterDOMProps(otherProps)}
role="presentation"
className={(props.UNSAFE_className || '') + badge({variant, size}, props.styles)}
className={(props.UNSAFE_className || '') + badge({variant, size, fillStyle}, props.styles)}
ref={domRef}>
{
typeof children === 'string' || isTextOnly
Expand Down