import type { Meta, StoryObj } from '@storybook/react-vite'; import { CircleCheckIcon, InfoIcon, OctagonXIcon, TriangleAlertIcon } from 'lucide-react'; import { Alert, AlertDescription, AlertTitle } from './alert'; const meta = { title: 'Components/Alert', component: Alert, parameters: { layout: 'centered', docs: { description: { component: 'Inline message about the state of the page. It carries `role="alert"`, so screen readers announce it the moment it appears — do not use it for static explanatory copy.\n\nStatus comes from `colorPalette`, not a separate `status` prop: `red` for errors, `green` for success, `yellow` for warnings, `secondary` for information, and `primary` for the emphasised informational treatment CBAR calls `info-secondary`.', }, }, }, tags: ['autodocs'], argTypes: { variant: { control: 'select', options: [ 'solid', 'subtle', 'surface', 'outline', 'default', 'destructive', 'success', 'warning', ], }, colorPalette: { control: 'select', options: ['primary', 'secondary', 'tertiary', 'black', 'red', 'green', 'yellow'], }, size: { control: 'inline-radio', options: ['sm', 'md', 'lg'] }, }, decorators: [ (Story) => (
), ], } satisfies Meta; export default meta; type Story = StoryObj; export const Default: Story = { render: () => ( Scheduled maintenance The API will be read-only on Sunday from 02:00 UTC. ), }; /** The four fill treatments, held on one palette so only the treatment moves. */ export const Variants: Story = { render: () => (
{(['solid', 'subtle', 'surface', 'outline'] as const).map((variant) => ( {variant} You can revert this change for 30 days. ))}
), }; /** How the palettes read as statuses — the axis that replaces a `status` prop. */ export const Statuses: Story = { render: () => (
Payment failed Update your card to avoid losing access. Deployment finished Version 2.4.0 is live in production. Approaching your quota You have used 92% of this month's credits. Heads up Maintenance is scheduled for Sunday. Policy update The revised terms take effect next month.
), }; /** Padding, text size and icon move together. */ export const Sizes: Story = { render: () => (
{(['sm', 'md', 'lg'] as const).map((size) => ( Size {size} The API will be read-only on Sunday. ))}
), }; /** The pre-CBAR shorthands still work, and pin their own colour. */ export const Shorthands: Story = { render: () => (
Heads up You can revert this change for 30 days. Deployment finished Version 2.4.0 is live in production. Approaching your quota You have used 92% of this month's credits. Payment failed Update your card to avoid losing access.
), }; export const TitleOnly: Story = { render: () => ( Your changes have been saved. ), };