/* * (c) Copyright 2026 Palantir Technologies Inc. All rights reserved. */ import type { Meta, StoryObj } from "@storybook/react-vite"; import { storybookLayoutDecorator } from "@storybook-common"; import type React from "react"; import { Flex } from "@blueprintjs/labs"; import { Intent } from "../../common"; import { Toast } from "./toast"; const disabledArgs = ["timeout", "className", "action", "onDismiss", "message"] as const satisfies ReadonlyArray< keyof React.ComponentProps >; const meta: Meta = { title: "Core/Overlays/Toast", component: Toast, decorators: [storybookLayoutDecorator], args: { intent: Intent.NONE, icon: undefined, isCloseButtonShown: true, timeout: 0, }, argTypes: { intent: { control: "select", options: Object.values(Intent), }, icon: { control: "text", }, isCloseButtonShown: { control: "boolean", }, ...disabledArgs.reduce( (acc, argName) => { acc[argName] = { table: { disable: true } }; return acc; }, {} as Record<(typeof disabledArgs)[number], { table: { disable: boolean } }>, ), }, } satisfies Meta; export default meta; type Story = StoryObj; /** * A basic toast with default styling and a close button. */ export const Default: Story = { args: { message: "This is a toast message", }, }; /** * Use the `intent` prop to apply a semantic color that conveys the purpose or status of the toast. */ export const IntentExample: Story = { name: "Intent", argTypes: { intent: { table: { disable: true } }, }, render: args => ( {Object.values(Intent).map(intent => ( ))} ), }; /** * Use the `icon` prop to render a Blueprint icon before the message. */ export const IconExample: Story = { name: "Icons", argTypes: { icon: { table: { disable: true } }, intent: { table: { disable: true } }, }, render: args => ( ), }; /** * Use the `action` prop to render an {@link AnchorButton} alongside the message. * The action accepts `ActionProps & LinkProps`, supporting text, icons, and links. */ export const ActionExample: Story = { name: "Action", argTypes: { isCloseButtonShown: { table: { disable: true } }, intent: { table: { disable: true } }, }, render: args => ( ), }; /** * Interactive playground for experimenting with toast props. */ export const Playground: Story = { args: { message: "Playground toast message", icon: "info-sign", intent: Intent.PRIMARY, isCloseButtonShown: true, action: { text: "Undo", }, }, };