Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
110 changes: 110 additions & 0 deletions apps/storybook/stories/SelectableCard.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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 (
<HStack gap={3}>
{options.map(option => (
<SelectableCard
key={option.id}
label={option.name}
isSelected={selected.has(option.id)}
onChange={isNow => toggle(option.id, isNow)}
width={260}>
<VStack gap={1}>
<Text type="body" weight="bold">
{option.name}
</Text>
<Text type="supporting" color="secondary">
{option.description}
</Text>
</VStack>
</SelectableCard>
))}
</HStack>
);
},
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 (
<VStack gap={2}>
{options.map(option => (
<SelectableCard
key={option.id}
label={option.name}
isSelected={selected.has(option.id)}
onChange={isNow => toggle(option.id, isNow)}
width={120}>
<VStack gap={1}>
<Text type="body" weight="bold">
{option.name}
</Text>
<Text type="supporting" color="secondary">
{option.description}
</Text>
</VStack>
</SelectableCard>
))}
</VStack>
);
},
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.',
},
},
},
};
Loading