|
1
|
import type { Meta, StoryObj } from "@storybook/react" |
|
2
|
import * as React from "react" |
|
3
|
|
|
4
|
import { Button } from "@/components/button" |
|
5
|
import { Text } from "@/components/text" |
|
6
|
import { useToggleState } from "./use-toggle-state" |
|
7
|
|
|
8
|
const Demo = () => { |
|
9
|
const { state, open, close, toggle } = useToggleState() |
|
10
|
|
|
11
|
return ( |
|
12
|
<div className="flex flex-col items-center gap-y-4"> |
|
13
|
<Text>State: {state ? "True" : "False"}</Text> |
|
14
|
<div className="flex items-center gap-x-4"> |
|
15
|
<Button onClick={open}>Open</Button> |
|
16
|
<Button onClick={close}>Close</Button> |
|
17
|
<Button onClick={toggle}>Toggle</Button> |
|
18
|
</div> |
|
19
|
</div> |
|
20
|
) |
|
21
|
} |
|
22
|
|
|
23
|
const meta: Meta<typeof Demo> = { |
|
24
|
title: "Hooks/useToggleState", |
|
25
|
component: Demo, |
|
26
|
parameters: { |
|
27
|
layout: "centered", |
|
28
|
}, |
|
29
|
} |
|
30
|
|
|
31
|
export default meta |
|
32
|
|
|
33
|
type Story = StoryObj<typeof Demo> |
|
34
|
|
|
35
|
export const Default: Story = {} |