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

157 lines
3.7 KiB
TypeScript

import {
Button,
ButtonColor,
ButtonVariant,
Drawer,
DrawerCloseButton,
DrawerContent,
DrawerDescription,
DrawerFooter,
DrawerHeader,
DrawerTitle,
DrawerTrigger,
} from '@signozhq/ui';
import type { Meta, StoryObj } from '@storybook/react-vite';
import { AnimatePresence } from 'motion/react';
import React from 'react';
import { overlayArgTypes } from './shared/dialog-drawer-arg-types.js';
const meta: Meta<typeof Drawer> = {
title: 'Primitive Components/Drawer',
component: Drawer,
argTypes: overlayArgTypes,
parameters: {
layout: 'fullscreen',
},
};
export default meta;
type Story = StoryObj<typeof Drawer>;
const DrawerPositionVariant = ({
args,
direction,
}: {
args: Story['args'];
direction: 'left' | 'right' | 'top' | 'bottom';
}) => {
const [open, setOpen] = React.useState<boolean | undefined>(false);
return (
<Drawer
{...args}
open={args?.open ?? open}
onOpenChange={(next) => {
setOpen(next);
args?.onOpenChange?.(next);
}}
>
<DrawerTrigger asChild>
<Button variant={ButtonVariant.Solid} color={ButtonColor.Primary}>
From {direction}
</Button>
</DrawerTrigger>
<AnimatePresence>
{open && (
<DrawerContent key={`drawer-${direction}`} direction={direction} forceMount>
<DrawerHeader>
<DrawerTitle>Drawer from {direction}</DrawerTitle>
<DrawerCloseButton />
</DrawerHeader>
<DrawerDescription>
Drawer content goes here. Use the primitive drawer components for full control.
</DrawerDescription>
<DrawerFooter>
<Button
variant={ButtonVariant.Ghost}
color="secondary"
onClick={() => setOpen(false)}
>
Cancel
</Button>
<Button
variant={ButtonVariant.Solid}
color={ButtonColor.Primary}
onClick={() => setOpen(false)}
>
Confirm
</Button>
</DrawerFooter>
</DrawerContent>
)}
</AnimatePresence>
</Drawer>
);
};
export const Default: Story = {
args: {
defaultOpen: false,
},
render: (args) => (
<div style={{ display: 'flex', flexWrap: 'wrap', gap: 16, padding: 32 }}>
{(['left', 'right', 'top', 'bottom'] as const).map((dir) => (
<DrawerPositionVariant key={dir} args={args} direction={dir} />
))}
</div>
),
};
export const WithoutOverlay: Story = {
args: {
...Default.args,
},
render: (args) => {
const [open, setOpen] = React.useState<boolean | undefined>(args.open ?? args.defaultOpen);
return (
<Drawer
{...args}
open={args.open ?? open}
onOpenChange={(next) => {
setOpen(next);
args.onOpenChange?.(next);
}}
>
<DrawerTrigger asChild>
<Button variant={ButtonVariant.Solid} color={ButtonColor.Primary}>
Open drawer without overlay
</Button>
</DrawerTrigger>
<AnimatePresence>
{open && (
<DrawerContent key="drawer-no-overlay" showOverlay={false} forceMount>
<DrawerHeader>
<DrawerTitle>Drawer without overlay</DrawerTitle>
<DrawerCloseButton />
</DrawerHeader>
<DrawerDescription>
<p style={{ fontSize: 14, lineHeight: 20, fontWeight: 400 }}>
This variant keeps the background interactive by disabling the overlay while the
drawer is open.
</p>
</DrawerDescription>
<DrawerFooter>
<Button
variant={ButtonVariant.Ghost}
color="secondary"
onClick={() => setOpen(false)}
>
Cancel
</Button>
<Button
variant={ButtonVariant.Solid}
color={ButtonColor.Primary}
onClick={() => setOpen(false)}
>
Confirm
</Button>
</DrawerFooter>
</DrawerContent>
)}
</AnimatePresence>
</Drawer>
);
},
};