|
| 1 | +import type { Meta, StoryObj } from "@storybook/react-vite"; |
| 2 | +import React from "react"; |
| 3 | +import { VStack } from "../layout/stack"; |
| 4 | +import { Link } from "../link"; |
| 5 | +import { renderStoriesForChromatic } from "../util/renderStoriesForChromatic"; |
| 6 | +import { InlineMessage } from "./index"; |
| 7 | + |
| 8 | +const meta: Meta<typeof InlineMessage> = { |
| 9 | + title: "ds-react/InlineMessage", |
| 10 | + component: InlineMessage, |
| 11 | + parameters: { |
| 12 | + chromatic: { disable: true }, |
| 13 | + }, |
| 14 | +}; |
| 15 | + |
| 16 | +export default meta; |
| 17 | + |
| 18 | +type Story = StoryObj<typeof InlineMessage>; |
| 19 | + |
| 20 | +const variants = ["info", "success", "warning", "error"] as const; |
| 21 | + |
| 22 | +export const Default: Story = { |
| 23 | + render: (props) => { |
| 24 | + return ( |
| 25 | + <InlineMessage variant={props.variant ?? "warning"}> |
| 26 | + {props.children ?? "InlineMessage content"} |
| 27 | + </InlineMessage> |
| 28 | + ); |
| 29 | + }, |
| 30 | + |
| 31 | + args: { |
| 32 | + children: "Id elit esse enim reprehenderit enim nisi veniam nostrud.", |
| 33 | + variant: "warning", |
| 34 | + }, |
| 35 | + argTypes: { |
| 36 | + variant: { |
| 37 | + control: { type: "select" }, |
| 38 | + options: variants, |
| 39 | + }, |
| 40 | + }, |
| 41 | +}; |
| 42 | + |
| 43 | +export const SizeSmall: Story = { |
| 44 | + render: () => { |
| 45 | + return ( |
| 46 | + <InlineMessage variant="warning" size="small"> |
| 47 | + <DemoContent /> |
| 48 | + </InlineMessage> |
| 49 | + ); |
| 50 | + }, |
| 51 | +}; |
| 52 | + |
| 53 | +export const Compositions: Story = { |
| 54 | + render: () => { |
| 55 | + return ( |
| 56 | + <VStack gap="space-16"> |
| 57 | + {variants.map((variant) => ( |
| 58 | + <InlineMessage variant={variant} key={variant}> |
| 59 | + <DemoContent /> |
| 60 | + </InlineMessage> |
| 61 | + ))} |
| 62 | + </VStack> |
| 63 | + ); |
| 64 | + }, |
| 65 | +}; |
| 66 | + |
| 67 | +export const WrappingTitle: Story = { |
| 68 | + render: () => { |
| 69 | + return ( |
| 70 | + <InlineMessage variant="warning"> |
| 71 | + <DemoContent /> |
| 72 | + </InlineMessage> |
| 73 | + ); |
| 74 | + }, |
| 75 | +}; |
| 76 | + |
| 77 | +export const AsLink: Story = { |
| 78 | + render: () => { |
| 79 | + return ( |
| 80 | + <InlineMessage variant="warning" as={Link} href="#"> |
| 81 | + This is a link inside the InlineMessage |
| 82 | + </InlineMessage> |
| 83 | + ); |
| 84 | + }, |
| 85 | +}; |
| 86 | + |
| 87 | +export const Chromatic = renderStoriesForChromatic({ |
| 88 | + Default, |
| 89 | + Compositions, |
| 90 | + WrappingTitle, |
| 91 | + SizeSmall, |
| 92 | +}); |
| 93 | + |
| 94 | +export const ChromaticLight = renderStoriesForChromatic({ |
| 95 | + Default, |
| 96 | + Compositions, |
| 97 | + WrappingTitle, |
| 98 | + SizeSmall, |
| 99 | +}); |
| 100 | +ChromaticLight.globals = { theme: "light", mode: "darkside" }; |
| 101 | + |
| 102 | +export const ChromaticDark = renderStoriesForChromatic({ |
| 103 | + Default, |
| 104 | + Compositions, |
| 105 | + WrappingTitle, |
| 106 | + SizeSmall, |
| 107 | +}); |
| 108 | +ChromaticDark.globals = { theme: "dark", mode: "darkside" }; |
| 109 | + |
| 110 | +function DemoContent() { |
| 111 | + return ( |
| 112 | + <span> |
| 113 | + Lorem ipsum dolor, sit amet consectetur adipisicing elit. Iure unde, |
| 114 | + repudiandae, deleniti exercitationem quod aut veniam sint officiis |
| 115 | + necessitatibus nulla nostrum voluptatem <Link href="#">Test</Link>{" "} |
| 116 | + facilis! Commodi, nobis tempora quibusdam temporibus nulla quam. |
| 117 | + </span> |
| 118 | + ); |
| 119 | +} |
0 commit comments