diff --git a/frontend/documentation/components/Chip.stories.tsx b/frontend/documentation/components/Chip.stories.tsx index 6261d8b0ba7b..b13a76a4afe8 100644 --- a/frontend/documentation/components/Chip.stories.tsx +++ b/frontend/documentation/components/Chip.stories.tsx @@ -29,6 +29,14 @@ export const Accent: Story = { args: { children: '"hello"', variant: 'accent' }, } +export const Success: Story = { + args: { children: 'View feature', variant: 'success' }, +} + +export const Warning: Story = { + args: { children: '1/2', variant: 'warning' }, +} + export const Sizes: Story = { render: () => (
@@ -56,6 +64,8 @@ export const Group: Story = {
Development Staging + Live + Paused undefined}>Production
), diff --git a/frontend/web/components/base/Chip/Chip.scss b/frontend/web/components/base/Chip/Chip.scss index a521448124f6..3f14717314d3 100644 --- a/frontend/web/components/base/Chip/Chip.scss +++ b/frontend/web/components/base/Chip/Chip.scss @@ -13,6 +13,14 @@ border-color: var(--color-border-action); } + &--success { + border-color: var(--color-border-success); + } + + &--warning { + border-color: var(--color-border-warning); + } + // Sizes (default is the base above). &--sm { padding: 3px 8px; diff --git a/frontend/web/components/base/Chip/Chip.tsx b/frontend/web/components/base/Chip/Chip.tsx index 8407b5cd9f3f..b03f87386546 100644 --- a/frontend/web/components/base/Chip/Chip.tsx +++ b/frontend/web/components/base/Chip/Chip.tsx @@ -6,7 +6,12 @@ import { toHexColour } from 'common/utils/hexColour' import './Chip.scss' export type ChipSize = 'default' | 'sm' | 'xs' -export type ChipVariant = 'neutral' | 'accent' | 'tinted' +export type ChipVariant = + | 'neutral' + | 'accent' + | 'success' + | 'warning' + | 'tinted' type TokenVariant = Exclude // 'tinted' takes a 6-digit hex colour; the token variants take none. @@ -37,6 +42,8 @@ export type ChipProps = ChipVariantProps & { const VARIANT_UTILITIES: Record = { accent: 'bg-surface-action-subtle text-action', neutral: 'bg-surface-subtle text-default', + success: 'bg-surface-success text-success', + warning: 'bg-surface-warning text-warning', } // Token-based chip primitive. Uses `ds-chip` rather than the legacy `.chip` @@ -78,9 +85,11 @@ const Chip = ({ { 'ds-chip--accent': !tint && tokenVariant === 'accent', 'ds-chip--clickable': interactive, + 'ds-chip--success': !tint && tokenVariant === 'success', 'ds-chip--tinted': !!tint, - [`ds-chip--${size}`]: size !== 'default', 'ds-chip--truncate': truncate, + [`ds-chip--${size}`]: size !== 'default', + 'ds-chip--warning': !tint && tokenVariant === 'warning', }, className, )}