Files
o11y-components/apps/docs/stories/toggle-group-simple.stories.tsx
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, Italic, LayoutGrid, List, Underline } from '@signozhq/icons';
import { ToggleGroupSimple, type ToggleGroupSimpleItem } from '@signozhq/ui';
import type { Meta, StoryObj } from '@storybook/react-vite';
const meta: Meta<typeof ToggleGroupSimple> = {
title: 'Composed Components/ToggleGroup/ToggleGroupSimple',
component: ToggleGroupSimple,
argTypes: {
type: {
control: 'radio',
options: ['single', 'multiple'],
description: 'Whether one or multiple items can be selected.',
table: { category: 'Form', type: { summary: "'single' | 'multiple'" } },
},
defaultValue: {
control: 'text',
description: 'The value(s) of the item(s) that should be pressed when initially rendered.',
table: { category: 'Form', type: { summary: 'string | string[]' } },
},
value: {
control: false,
description: 'The controlled value(s). Use with onChange.',
table: { category: 'Form', type: { summary: 'string | string[]' } },
},
onChange: {
control: false,
description: 'Callback when the value changes.',
table: {
category: 'Events',
type: { summary: '(value: string) => void | (value: string[]) => void' },
},
},
items: {
control: false,
description: 'List of items to display.',
table: { category: 'Content', type: { summary: 'ToggleGroupSimpleItem[]' } },
},
size: {
control: 'radio',
options: ['default', 'sm', 'lg'],
description: 'The size of the toggle group.',
table: { category: 'Appearance', defaultValue: { summary: 'default' } },
},
color: {
control: 'select',
options: ['primary', 'destructive', 'warning', 'secondary', 'none'],
description: 'The color of the toggle group.',
table: { category: 'Appearance', defaultValue: { summary: 'secondary' } },
},
disabled: {
control: 'boolean',
description: 'Whether the group is disabled.',
table: { category: 'Behavior', defaultValue: { summary: 'false' } },
},
orientation: {
control: 'select',
options: ['horizontal', 'vertical'],
description: 'The orientation of the toggle group.',
table: { category: 'Layout' },
},
className: {
control: 'text',
description: 'Additional CSS classes.',
table: { category: 'Styling' },
},
},
parameters: {
layout: 'fullscreen',
design: [
{
name: 'Figma',
type: 'figma',
url: 'https://www.figma.com/design/egMidgk6VJDXTumxcCYUl1/Periscope---Primitives?node-id=12-757&p=f&t=DqcgJjfI3A74mvM2-0',
},
],
},
tags: ['autodocs'],
};
export default meta;
type Story = StoryObj<typeof ToggleGroupSimple>;
const labelItems: ToggleGroupSimpleItem[] = [
{ value: 'left', label: 'Left' },
{ value: 'center', label: 'Center' },
{ value: 'right', label: 'Right' },
];
const iconItems: ToggleGroupSimpleItem[] = [
{ value: 'bold', label: <Bold style={{ height: 12, width: 12 }} />, 'aria-label': 'Bold' },
{ value: 'italic', label: <Italic style={{ height: 12, width: 12 }} />, 'aria-label': 'Italic' },
{
value: 'underline',
label: <Underline style={{ height: 12, width: 12 }} />,
'aria-label': 'Underline',
},
];
const iconAndLabelItems: ToggleGroupSimpleItem[] = [
{
value: 'grid',
label: (
<>
<LayoutGrid style={{ height: 24, width: 24 }} /> Grid
</>
),
},
{
value: 'list',
label: (
<>
<List style={{ height: 24, width: 24 }} /> List
</>
),
},
];
export const Default: Story = {
args: {
type: 'single',
defaultValue: 'center',
size: 'default',
color: 'secondary',
disabled: false,
items: labelItems,
},
render: (args) => <ToggleGroupSimple {...args} />,
};
export const SingleWithLabels: Story = {
args: {
type: 'single',
defaultValue: 'center',
items: labelItems,
},
render: (args) => <ToggleGroupSimple {...args} />,
};
export const MultipleWithIcons: Story = {
args: {
type: 'multiple',
defaultValue: ['bold'],
items: iconItems,
},
render: (args) => <ToggleGroupSimple {...args} />,
};
export const SingleWithIconAndLabel: Story = {
args: {
type: 'single',
defaultValue: 'grid',
items: iconAndLabelItems,
},
render: (args) => <ToggleGroupSimple {...args} />,
};