import { Meta, StoryObj } from "@storybook/react"; import React from "react"; import { Alert, AlertProps } from ":/components/Alert"; import { Button } from ":/components/Button"; import { VariantType } from ":/utils/VariantUtils"; const meta: Meta = { title: "Components/Alert", component: Alert, }; export default meta; type Story = StoryObj; export const All: Story = { render: (args) => { const customProps: AlertProps = { type: args.type ?? VariantType.INFO }; return (
); }, argTypes: { type: { options: ["info", "success", "warning", "error", "neutral"], }, }, }; export const Info: Story = { args: { children: "Alert component info", canClose: true, primaryLabel: "Primary", }, }; export const InfoWithTertiary: Story = { args: { children: "Alert component info", canClose: true, primaryLabel: "Primary", tertiaryLabel: "Tertiary", }, }; export const CustomButtons: Story = { args: { children: "Alert component info", canClose: true, buttons: (
), }, }; export const Success: Story = { args: { children: "Alert component Success", canClose: true, primaryLabel: "Primary", type: VariantType.SUCCESS, }, }; export const Warning: Story = { args: { children: "Alert component Warning", canClose: true, primaryLabel: "Primary", type: VariantType.WARNING, }, }; export const Error: Story = { args: { children: "Alert component Error", canClose: true, primaryLabel: "Primary", type: VariantType.ERROR, }, }; export const Neutral: Story = { args: { children: "Alert component Neutral", canClose: true, primaryLabel: "Primary", type: VariantType.NEUTRAL, }, }; export const InfoAdditionalInformation: Story = { args: { children: "Alert component info", additional: "Additional information", canClose: true, primaryLabel: "Primary", tertiaryLabel: "Tertiary ", }, }; export const Controlled: Story = { render: () => { const [closed, setClosed] = React.useState(false); return (
setClosed(true)} />
closed: {closed ? "true" : "false"}
); }, }; export const InfoExpandable: Story = { render: () => { return ( ); }, }; export const ExpandableControlled: Story = { render: () => { const [closed, setClosed] = React.useState(false); const [expanded, setExpanded] = React.useState(false); return (
setClosed(true)} expandable={true} expanded={expanded} onExpand={(value) => setExpanded(value)} />
closed: {closed ? "true" : "false"}
expanded: {expanded ? "true" : "false"}
); }, };