From 5ae36ec9144ec82c5d50d85914357f04d1b29a1a Mon Sep 17 00:00:00 2001 From: Cindy Zhang Date: Sun, 29 Nov 2026 12:04:22 -0800 Subject: [PATCH] test(storybook): long-text and narrow-width SelectableCard stories Adds a Long Text story (long labels and descriptions that wrap, and one unbroken word that breaks across lines) and a Narrow Width story (cards at 120px, as in a side panel). Both carry the visual-baseline tag, so the visual gate covers wrapping and the selection ring at small sizes. --- .../stories/SelectableCard.stories.tsx | 110 ++++++++++++++++++ 1 file changed, 110 insertions(+) diff --git a/apps/storybook/stories/SelectableCard.stories.tsx b/apps/storybook/stories/SelectableCard.stories.tsx index e4044c707e2c1..c109674f984d4 100644 --- a/apps/storybook/stories/SelectableCard.stories.tsx +++ b/apps/storybook/stories/SelectableCard.stories.tsx @@ -276,3 +276,113 @@ export const Disabled: Story = { }, }, }; + +function useSelectedSet(initial: string[]) { + const [selected, setSelected] = useState(new Set(initial)); + const toggle = (id: string, isNow: boolean) => { + setSelected(prev => { + const next = new Set(prev); + if (isNow) { + next.add(id); + } else { + next.delete(id); + } + return next; + }); + }; + return [selected, toggle] as const; +} + +export const LongText: Story = { + name: 'Long Text', + tags: ['visual-baseline'], + render: () => { + const [selected, toggle] = useSelectedSet(['support']); + const options = [ + { + id: 'support', + name: 'Priority support with a dedicated onboarding specialist', + description: + 'Replies within one business hour, a named contact for your team, and a guided setup call for every new workspace you add this year.', + }, + { + id: 'export', + name: 'Nightly export to workspacearchive7f3c9a1e2b4d6c8e0f', + description: + 'Writes every project to the archive above. The name is one unbroken word, so it breaks across lines.', + }, + ]; + + return ( + + {options.map(option => ( + toggle(option.id, isNow)} + width={260}> + + + {option.name} + + + {option.description} + + + + ))} + + ); + }, + parameters: { + docs: { + description: { + story: + 'Long labels and descriptions wrap inside the card, and the selection ring stays on the card edge. An unbroken word breaks across lines instead of overflowing the card.', + }, + }, + }, +}; + +export const NarrowWidth: Story = { + name: 'Narrow Width', + tags: ['visual-baseline'], + render: () => { + const [selected, toggle] = useSelectedSet(['yearly']); + const options = [ + {id: 'monthly', name: 'Monthly', description: 'Billed every month'}, + {id: 'yearly', name: 'Yearly', description: 'Billed once a year'}, + ]; + + return ( + + {options.map(option => ( + toggle(option.id, isNow)} + width={120}> + + + {option.name} + + + {option.description} + + + + ))} + + ); + }, + parameters: { + docs: { + description: { + story: + 'Cards at a narrow width, as in a side panel: text wraps to more lines, and the ring and padding keep their size.', + }, + }, + }, +};