feat: add drawer playground
This commit is contained in:
parent
da1a53ba29
commit
c5bf58b558
@ -1,26 +1,13 @@
|
||||
import { TabProvider, TabTrigger, TabContent, TabList } from "@pswui/Tabs";
|
||||
import { Story } from "@/components/Story";
|
||||
import { LoadedCode, GITHUB_COMP, GITHUB_COMP_PREVIEW, GITHUB_STORY } from '@/components/LoadedCode';
|
||||
import { DrawerDemo } from "./DrawerBlocks/Preview";
|
||||
import Examples from "./DrawerBlocks/Examples";
|
||||
import Playground from "./DrawerBlocks/Playground";
|
||||
|
||||
# Drawer
|
||||
Displays a panel that slides out from the edge of the screen, typically used for navigation or additional content.
|
||||
|
||||
<TabProvider defaultName="preview">
|
||||
<TabList>
|
||||
<TabTrigger name="preview">Preview</TabTrigger>
|
||||
<TabTrigger name="code">Code</TabTrigger>
|
||||
</TabList>
|
||||
<TabContent name="preview">
|
||||
<Story layout="centered">
|
||||
<DrawerDemo />
|
||||
</Story>
|
||||
</TabContent>
|
||||
<TabContent name="code">
|
||||
<LoadedCode from={GITHUB_COMP_PREVIEW("Drawer")} />
|
||||
</TabContent>
|
||||
</TabProvider>
|
||||
<Playground />
|
||||
|
||||
## Installation
|
||||
|
||||
|
34
src/docs/components/DrawerBlocks/Playground.tsx
Normal file
34
src/docs/components/DrawerBlocks/Playground.tsx
Normal file
@ -0,0 +1,34 @@
|
||||
import type { TEMPLATE } from "@/components/LoadedCode";
|
||||
import { usePgProps } from "@/components/PgHooks";
|
||||
import { PlaygroundLayout } from "@/components/Playground";
|
||||
import { DrawerDemo, type DrawerDemoPlaygroundProps } from "./Preview";
|
||||
|
||||
interface TemplateProps extends TEMPLATE, DrawerDemoPlaygroundProps {}
|
||||
|
||||
export default function DrawerPlayground() {
|
||||
const [props, control] = usePgProps<TemplateProps>({
|
||||
DrawerRootProps: {
|
||||
closeThreshold: {
|
||||
type: "number",
|
||||
value: 0.3,
|
||||
},
|
||||
},
|
||||
DrawerContentProps: {
|
||||
position: {
|
||||
type: "select",
|
||||
options: ["top", "bottom", "left", "right"],
|
||||
value: "left",
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
return (
|
||||
<PlaygroundLayout
|
||||
compName="Drawer"
|
||||
control={control}
|
||||
props={props}
|
||||
>
|
||||
<DrawerDemo {...props} />
|
||||
</PlaygroundLayout>
|
||||
);
|
||||
}
|
@ -9,15 +9,34 @@ import {
|
||||
DrawerRoot,
|
||||
DrawerTrigger,
|
||||
} from "@pswui/Drawer";
|
||||
|
||||
export const DrawerDemo = () => {
|
||||
/* remove */
|
||||
export interface DrawerDemoPlaygroundProps {
|
||||
DrawerRootProps: {
|
||||
closeThreshold: number;
|
||||
};
|
||||
DrawerContentProps: {
|
||||
position: "top" | "bottom" | "left" | "right";
|
||||
};
|
||||
}
|
||||
/* end */
|
||||
/* replace */
|
||||
export function DrawerDemo({
|
||||
DrawerRootProps,
|
||||
DrawerContentProps,
|
||||
}: DrawerDemoPlaygroundProps) {
|
||||
/* with
|
||||
export function DrawerDemo() {
|
||||
*/
|
||||
return (
|
||||
<DrawerRoot>
|
||||
<DrawerRoot closeThreshold={DrawerRootProps.closeThreshold}>
|
||||
<DrawerTrigger>
|
||||
<Button>Open Drawer</Button>
|
||||
</DrawerTrigger>
|
||||
<DrawerOverlay className="z-[99]">
|
||||
<DrawerContent className="max-w-[320px]">
|
||||
<DrawerContent
|
||||
className="max-w-[320px]"
|
||||
position={DrawerContentProps.position}
|
||||
>
|
||||
<DrawerHeader>
|
||||
<h1 className="text-2xl font-bold">Drawer</h1>
|
||||
</DrawerHeader>
|
||||
@ -37,4 +56,4 @@ export const DrawerDemo = () => {
|
||||
</DrawerOverlay>
|
||||
</DrawerRoot>
|
||||
);
|
||||
};
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user