/* ! * (c) Copyright 2026 Palantir Technologies Inc. All rights reserved. */ import type { Meta, StoryObj } from "@storybook/react-vite"; import { DashedPaddedContainer, storybookLayoutDecorator, StoryLabel } from "@storybook-common"; import { Colors } from "@blueprintjs/colors"; import { Home } from "@blueprintjs/icons"; import { Flex } from "@blueprintjs/labs"; import { H1, H2, H3, H4, H5, H6 } from "../html/html"; import { Tag } from "../tag/tag"; import { EntityTitle } from "./entityTitle"; const HEADINGS = [ { heading: H1, label: "H1" }, { heading: H2, label: "H2" }, { heading: H3, label: "H3" }, { heading: H4, label: "H4" }, { heading: H5, label: "H5" }, { heading: H6, label: "H6" }, ] as const satisfies ReadonlyArray<{ heading: React.FC; label: string }>; const meta: Meta = { title: "Core/EntityTitle", component: EntityTitle, decorators: [storybookLayoutDecorator], tags: ["autodocs"], args: { title: "Entity Title", icon: undefined, heading: undefined, ellipsize: false, fill: false, loading: false, }, argTypes: { title: { control: "text", }, icon: { control: "text", table: { disable: true }, }, heading: { control: "select", options: ["Text", ...HEADINGS.map(h => h.label)], mapping: { Text: undefined, ...Object.fromEntries(HEADINGS.map(({ label, heading }) => [label, heading])), }, }, ellipsize: { control: "boolean", }, fill: { control: "boolean", }, loading: { control: "boolean", }, subtitle: { control: "text", }, }, } satisfies Meta; export default meta; type Story = StoryObj; /** * A basic entity title with default styling. */ export const Default: Story = { args: { title: "Entity Title", }, }; /** * Use the `heading` prop to control the size of the entity title by rendering it as an HTML heading element. */ export const HeadingsExample: Story = { name: "Heading", argTypes: { heading: { table: { disable: true } }, title: { table: { disable: true } }, }, render: args => ( {HEADINGS.map(({ heading, label }) => ( ))} ), }; /** * Use the `icon` prop to render an icon alongside the title. */ export const IconExample: Story = { name: "Icon", argTypes: { title: { table: { disable: true } }, }, render: args => ( } title="Element icon" /> ), }; /** * Use the `fill` prop to make the entity title expand to fill its container. */ export const FillExample: Story = { name: "Fill", argTypes: { fill: { table: { disable: true } }, title: { table: { disable: true } }, }, render: args => (
), }; /** * Use the `ellipsize` prop to truncate long titles with an ellipsis when they overflow their container. */ export const EllipsizeExample: Story = { name: "Ellipsize", argTypes: { ellipsize: { table: { disable: true } }, title: { table: { disable: true } }, }, decorators: [ Story => ( ), ], render: args => (
), }; /** * Use the `loading` prop to show a skeleton loading state. */ export const LoadingExample: Story = { name: "Loading", argTypes: { loading: { table: { disable: true } }, title: { table: { disable: true } }, }, render: args => (
), }; /** * Use the `tags` prop to render `Tag` components alongside the title. */ export const TagsExample: Story = { name: "Tags", argTypes: { title: { table: { disable: true } }, }, render: args => (
Draft} />
), }; /** * Use the `subtitle` prop to render secondary descriptive text below the title. */ export const SubtitleExample: Story = { name: "Subtitle", argTypes: { title: { table: { disable: true } }, }, render: args => ( ), }; /** * Interactive playground with all props togglable via Storybook controls. */ export const Playground: Story = { args: { title: "Playground Entity", icon: "document", heading: undefined, ellipsize: false, fill: false, loading: false, }, };