import { Meta, StoryObj } from '@storybook/react-webpack5'; import { Sentiment } from '../common'; import SentimentSurface from '../sentimentSurface'; import StatusIcon, { StatusIconSentiment } from './StatusIcon'; const sentiments = [ Sentiment.POSITIVE, Sentiment.NEGATIVE, Sentiment.WARNING, Sentiment.NEUTRAL, Sentiment.PENDING, ] as const; const sizes = [16, 24, 32, 40, 48, 56, 72] as const; const label: Record = { positive: 'Positive', negative: 'Negative', warning: 'Warning', neutral: 'Neutral', pending: 'Pending', }; export default { component: StatusIcon, title: 'Other/StatusIcon', } satisfies Meta; type Story = StoryObj; export const Playground: Story = { args: { size: 40, }, }; /** * All available sentiments at the selected size. */ export const Sentiments: Story = { argTypes: { sentiment: { table: { disable: true } }, }, render: ({ size }) => (
{sentiments.map((sentiment) => (
{label[sentiment]}
))}
), }; /** * All available sizes at the selected sentiment. */ export const Sizes: Story = { argTypes: { size: { table: { disable: true } }, }, render: ({ sentiment }) => (
{sizes.map((size) => (
{size}
))}
), }; /** * `StatusIcon` is sentiment-aware and will automatically adjust its colours when placed inside * a [SentimentSurface](?path=/docs/foundations-sentimentsurface--docs) component — no extra * props needed. Each row below is a `SentimentSurface` at either `base` or `elevated` emphasis (and a last row with no sentiment for reference). */ export const SentimentAwareness: Story = { argTypes: { sentiment: { table: { disable: true } }, }, render: ({ size }) => { const surfaceSentiments = ['success', 'warning', 'negative', 'neutral'] as const; return (
{surfaceSentiments.flatMap((sentiment) => [
{sentiment} (base)
,
{sentiment} (elevated)
, ])} {/* Row without a SentimentSurface wrapper */}
none
); }, parameters: { docs: { source: { type: 'dynamic' }, canvas: { sourceState: 'hidden' }, }, }, };