Files
zeekay 464e1eece0 State a version once
A version written into a manifest is written into every manifest that wants it,
which is how eslint came to exist in a hundred and four forms across this estate
and how a package came to resolve twice at run time. The catalog moves the number
out of the manifest: a manifest names the package, the workspace names the
version.

Four are held below their latest because the newer release cannot be used, and
the reason is recorded rather than the version alone: @noble/hashes 2 renamed
every subpath the web3 stack imports, @splinetool/runtime 2 depends on a package
that was never published, @dynamic-labs 5.4.1 the same, and react-resizable-panels
3 points its types condition at the bundle.
2026-09-15 11:45:32 -07:00

156 lines
4.0 KiB
TypeScript

import { Bold } from '@signozhq/icons';
import { Toggle, type ToggleColor } from '@signozhq/ui';
import type { Meta, StoryObj } from '@storybook/react-vite';
const meta: Meta<typeof Toggle> = {
title: 'Primitive Components/Toggle',
component: Toggle,
argTypes: {
value: {
control: 'boolean',
description: 'The controlled state of the toggle.',
table: { category: 'State', type: { summary: 'boolean' } },
},
defaultValue: {
control: 'boolean',
description:
'The state of the toggle when initially rendered. Use when you do not need to control the state.',
table: {
category: 'State',
type: { summary: 'boolean' },
defaultValue: { summary: 'false' },
},
},
onChange: {
control: false,
description: 'The callback that fires when the state of the toggle changes.',
table: { category: 'Events', type: { summary: '(value: boolean) => void' } },
},
size: {
control: 'radio',
options: ['default', 'sm', 'lg'],
description: 'The size of the toggle.',
table: {
category: 'Appearance',
type: { summary: "'default' | 'sm' | 'lg'" },
defaultValue: { summary: 'default' },
},
},
color: {
control: 'select',
options: ['primary', 'destructive', 'warning', 'secondary', 'none'],
description: 'The color variant of the toggle.',
table: {
category: 'Appearance',
type: { summary: 'ToggleColor' },
defaultValue: { summary: 'secondary' },
},
},
disabled: {
control: 'boolean',
description: 'When true, prevents the user from interacting with the toggle.',
table: { category: 'Behavior', defaultValue: { summary: 'false' } },
},
className: {
control: 'text',
description: 'Additional CSS classes.',
table: { category: 'Styling' },
},
testId: {
control: 'text',
description: 'The testId for testing purposes.',
table: { category: 'Testing' },
},
},
parameters: {
layout: 'fullscreen',
tags: ['autodocs'],
},
};
export default meta;
type Story = StoryObj<typeof Toggle>;
export const Default: Story = {
args: {
defaultValue: false,
size: 'default',
color: 'secondary',
disabled: false,
},
render: (args) => (
<Toggle {...args} aria-label="Toggle bold">
<Bold style={{ height: 12, width: 12 }} />
</Toggle>
),
};
export const Pressed: Story = {
args: {
defaultValue: true,
size: 'default',
color: 'secondary',
disabled: false,
},
render: (args) => (
<Toggle {...args} aria-label="Toggle bold">
<Bold style={{ height: 12, width: 12 }} />
</Toggle>
),
};
export const Disabled: Story = {
args: {
defaultValue: false,
disabled: true,
},
render: (args) => (
<Toggle {...args} aria-label="Toggle bold">
<Bold style={{ height: 12, width: 12 }} />
</Toggle>
),
};
const colors: ToggleColor[] = ['primary', 'destructive', 'warning', 'secondary', 'none'];
export const AllColors: Story = {
render: () => (
<div style={{ display: 'flex', flexWrap: 'wrap', gap: 16 }}>
{colors.map((color) => (
<div
key={color}
style={{ display: 'flex', flexDirection: 'column', alignItems: 'center', gap: 8 }}
>
<span style={{ fontSize: 14, lineHeight: 1.42857, textTransform: 'capitalize' }}>
{color}
</span>
<div style={{ display: 'flex', gap: 8 }}>
<Toggle defaultValue={false} color={color} aria-label={`${color} off`}>
<Bold style={{ height: 12, width: 12 }} />
</Toggle>
<Toggle defaultValue={true} color={color} aria-label={`${color} on`}>
<Bold style={{ height: 12, width: 12 }} />
</Toggle>
</div>
</div>
))}
</div>
),
};
export const AllSizes: Story = {
render: () => (
<div style={{ display: 'flex', alignItems: 'center', gap: 16 }}>
<Toggle size="sm" aria-label="Small">
<Bold style={{ height: 12, width: 12 }} />
</Toggle>
<Toggle size="default" aria-label="Default">
<Bold style={{ height: 12, width: 12 }} />
</Toggle>
<Toggle size="lg" aria-label="Large">
<Bold style={{ height: 12, width: 12 }} />
</Toggle>
</div>
),
};