-
Notifications
You must be signed in to change notification settings - Fork 120
Expand file tree
/
Copy pathDropdown.stories.tsx
More file actions
160 lines (152 loc) · 4.49 KB
/
Dropdown.stories.tsx
File metadata and controls
160 lines (152 loc) · 4.49 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
import { Meta, StoryFn as Story } from '@storybook/react'
import React from 'react'
import Dropdown, { DropdownProps } from '.'
import Badge from '../Badge'
import Button from '../Button'
import Card from '../Card/'
import Navbar from '../Navbar'
export default {
title: 'Actions/Dropdown',
component: Dropdown,
argTypes: {
item: {
control: false,
},
},
} as Meta
export const Default: Story<DropdownProps> = (args) => {
return (
<div className="my-32">
<Dropdown {...args}>
<Dropdown.Toggle>Click</Dropdown.Toggle>
<Dropdown.Menu className="w-52">
<Dropdown.Item>Item 1</Dropdown.Item>
<Dropdown.Item>Item 2</Dropdown.Item>
</Dropdown.Menu>
</Dropdown>
</div>
)
}
export const AsCard: Story<DropdownProps> = (args) => {
return (
<div className="my-32">
<Dropdown {...args}>
<Dropdown.Toggle>Click</Dropdown.Toggle>
<Dropdown.Menu className="card card-compact w-64 p-2 shadow bg-primary text-primary-content m-1">
<Card.Body>
<Card.Title tag={'h3'}>Card title!</Card.Title>
<p>you can use any element as a dropdown.</p>
</Card.Body>
</Dropdown.Menu>
</Dropdown>
</div>
)
}
export const InNavbar: Story<DropdownProps> = ({ dataTheme, ...args }) => {
return (
<Navbar
className="my-32 px-2 font-sans bg-base-300 rounded-box"
dataTheme={dataTheme}
>
<Navbar.Start className="px-2 lg:flex-none">
<span className="text-lg font-bold">daisyUI</span>
</Navbar.Start>
<Navbar.End>
<Button color="ghost" dataTheme={dataTheme}>
Button
</Button>
<Dropdown {...args} dataTheme={dataTheme}>
<Dropdown.Toggle className="btn btn-ghost rounded-btn" button={false}>
Dropdown
</Dropdown.Toggle>
<Dropdown.Menu className="w-52 mt-4">
<Dropdown.Item>Item 1</Dropdown.Item>
<Dropdown.Item>Item 2</Dropdown.Item>
</Dropdown.Menu>
</Dropdown>
</Navbar.End>
</Navbar>
)
}
InNavbar.args = {
end: true,
}
export const ButtonToggle: Story<DropdownProps> = (args) => {
return (
<div className="my-32">
<Dropdown {...args}>
<Dropdown.Toggle size="xl" color="success" variant="dash">
Click
</Dropdown.Toggle>
<Dropdown.Menu className="w-52">
<Dropdown.Item>Item 1</Dropdown.Item>
<Dropdown.Item>Item 2</Dropdown.Item>
</Dropdown.Menu>
</Dropdown>
</div>
)
}
export const LabelToggle: Story<DropdownProps> = (args) => {
return (
<div className="my-32">
<Dropdown {...args}>
<Dropdown.Toggle button={false}>Click</Dropdown.Toggle>
<Dropdown.Menu className="w-52">
<Dropdown.Item>Item 1</Dropdown.Item>
<Dropdown.Item>Item 2</Dropdown.Item>
</Dropdown.Menu>
</Dropdown>
</div>
)
}
export const UnstyledCustomToggle: Story<DropdownProps> = (args) => {
return (
<div className="my-32">
<Dropdown {...args}>
<Dropdown.Toggle unstyled>
<Badge color="primary" variant="outline" className="cursor-pointer">
Any component can be a toggle, even a {`<Badge>`}!
</Badge>
</Dropdown.Toggle>
<Dropdown.Menu className="w-52">
<Dropdown.Item>Item 1</Dropdown.Item>
<Dropdown.Item>Item 2</Dropdown.Item>
</Dropdown.Menu>
</Dropdown>
</div>
)
}
export const Helper: Story<DropdownProps> = (args) => {
return (
<div className="my-32 font-sans">
A normal text and a helper dropdown
<Dropdown {...args}>
<Dropdown.Toggle
button={false}
className="btn btn-circle btn-ghost btn-xs text-info"
>
<svg
xmlns="http://www.w3.org/2000/svg"
fill="none"
viewBox="0 0 24 24"
className="w-4 h-4 stroke-current"
>
<path
strokeLinecap="round"
strokeLinejoin="round"
strokeWidth="2"
d="M13 16h-1v-4h-1m1-4h.01M21 12a9 9 0 11-18 0 9 9 0 0118 0z"
></path>
</svg>
</Dropdown.Toggle>
<Dropdown.Menu className="card compact w-64 !p-0 shadow bg-base-100 rounded-box">
<Card.Body>
<Card.Title tag={'h2'}>You needed more info?</Card.Title>
<p>Here is a description!</p>
</Card.Body>
</Dropdown.Menu>
</Dropdown>
</div>
)
}
Helper.args = { end: true }