Files
o11y-components/apps/docs/stories/dropdown-menu-sub.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

133 lines
3.6 KiB
TypeScript

import { Link, Settings } from '@signozhq/icons';
import {
Button,
DropdownMenu,
DropdownMenuContent,
DropdownMenuItem,
DropdownMenuSub,
DropdownMenuSubContent,
DropdownMenuSubTrigger,
DropdownMenuTrigger,
} from '@signozhq/ui';
import type { Meta, StoryObj } from '@storybook/react-vite';
import * as React from 'react';
function SubMenuFrame({
subProps,
children,
}: {
subProps: { defaultOpen?: boolean; open?: boolean; onOpenChange?: (open: boolean) => void };
children: React.ReactNode;
}) {
return (
<div style={{ padding: 32 }}>
<DropdownMenu>
<DropdownMenuTrigger asChild>
<Button variant="solid" color="secondary">
Open menu
</Button>
</DropdownMenuTrigger>
<DropdownMenuContent>
<DropdownMenuItem>Profile</DropdownMenuItem>
<DropdownMenuItem>Settings</DropdownMenuItem>
<DropdownMenuSub {...subProps}>{children}</DropdownMenuSub>
</DropdownMenuContent>
</DropdownMenu>
</div>
);
}
const meta: Meta<typeof DropdownMenuSub> = {
title: 'Primitive Components/DropdownMenu/DropdownMenuSub',
component: DropdownMenuSub,
argTypes: {
defaultOpen: {
control: 'boolean',
description: 'The open state of the submenu when initially rendered.',
table: { category: 'State', type: { summary: 'boolean' } },
},
open: {
control: 'boolean',
description: 'The controlled open state. Must be used together with onOpenChange.',
table: { category: 'State', type: { summary: 'boolean' } },
},
children: {
control: false,
description: 'DropdownMenuSubTrigger and DropdownMenuSubContent.',
table: { category: 'Content' },
},
onOpenChange: { control: false, table: { category: 'Events' } },
},
parameters: {
layout: 'fullscreen',
},
tags: ['autodocs'],
};
export default meta;
type Story = StoryObj<typeof DropdownMenuSub>;
export const Default: Story = {
args: {
defaultOpen: false,
},
render: (args) => (
<SubMenuFrame
subProps={{
defaultOpen: args.defaultOpen,
}}
>
<DropdownMenuSubTrigger leftIcon={<Settings style={{ height: 16, width: 16 }} />}>
More Options
</DropdownMenuSubTrigger>
<DropdownMenuSubContent sideOffset={4}>
<DropdownMenuItem leftIcon={<Link style={{ height: 16, width: 16 }} />}>
Sub Item 1
</DropdownMenuItem>
<DropdownMenuItem>Sub Item 2</DropdownMenuItem>
<DropdownMenuItem>Sub Item 3</DropdownMenuItem>
</DropdownMenuSubContent>
</SubMenuFrame>
),
};
export const DefaultOpen: Story = {
args: {
defaultOpen: true,
},
render: (args) => (
<SubMenuFrame subProps={{ defaultOpen: args.defaultOpen }}>
<DropdownMenuSubTrigger leftIcon={<Settings style={{ height: 16, width: 16 }} />}>
More Options
</DropdownMenuSubTrigger>
<DropdownMenuSubContent sideOffset={4}>
<DropdownMenuItem leftIcon={<Link style={{ height: 16, width: 16 }} />}>
Sub Item 1
</DropdownMenuItem>
<DropdownMenuItem>Sub Item 2</DropdownMenuItem>
<DropdownMenuItem>Sub Item 3</DropdownMenuItem>
</DropdownMenuSubContent>
</SubMenuFrame>
),
};
export const Controlled: Story = {
render: () => {
const [open, setOpen] = React.useState(false);
return (
<SubMenuFrame subProps={{ open, onOpenChange: setOpen }}>
<DropdownMenuSubTrigger leftIcon={<Settings style={{ height: 16, width: 16 }} />}>
More Options
</DropdownMenuSubTrigger>
<DropdownMenuSubContent sideOffset={4}>
<DropdownMenuItem leftIcon={<Link style={{ height: 16, width: 16 }} />}>
Sub Item 1
</DropdownMenuItem>
<DropdownMenuItem>Sub Item 2</DropdownMenuItem>
<DropdownMenuItem>Sub Item 3</DropdownMenuItem>
</DropdownMenuSubContent>
</SubMenuFrame>
);
},
};