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
161
162
163
164
165
166
167
168
169
170
171
172
173
|
// @ts-nocheck
import { onMount } from "solid-js"
import * as mod from "./dialog"
import { Button } from "./button"
import { useDialog } from "../context/dialog"
const docs = `### Overview
Dialog content wrapper used with the DialogProvider for modal flows.
Provide concise title/description and keep body focused.
### API
- Optional: \`title\`, \`description\`, \`action\`.
- \`size\`: normal | large | x-large.
- \`fit\` and \`transition\` control layout and animation.
### Variants and states
- Sizes and optional header/action controls.
### Behavior
- Intended to be rendered via \`useDialog().show\`.
### Accessibility
- TODO: confirm focus trapping and aria attributes from Kobalte Dialog.
### Theming/tokens
- Uses \`data-component="dialog"\` and slot attributes.
`
export default {
title: "UI/Dialog",
id: "components-dialog",
component: mod.Dialog,
tags: ["autodocs"],
parameters: {
docs: {
description: {
component: docs,
},
},
},
}
export const Basic = {
render: () => {
const dialog = useDialog()
const open = () =>
dialog.show(() => (
<mod.Dialog title="Dialog" description="Description">
Dialog body content.
</mod.Dialog>
))
onMount(open)
return (
<Button variant="secondary" onClick={open}>
Open dialog
</Button>
)
},
}
export const Sizes = {
render: () => {
const dialog = useDialog()
return (
<div style={{ display: "flex", gap: "12px" }}>
<Button
variant="secondary"
onClick={() =>
dialog.show(() => (
<mod.Dialog title="Normal" description="Normal size">
Normal dialog content.
</mod.Dialog>
))
}
>
Normal
</Button>
<Button
variant="secondary"
onClick={() =>
dialog.show(() => (
<mod.Dialog size="large" title="Large" description="Large size">
Large dialog content.
</mod.Dialog>
))
}
>
Large
</Button>
<Button
variant="secondary"
onClick={() =>
dialog.show(() => (
<mod.Dialog size="x-large" title="Extra large" description="X-large size">
X-large dialog content.
</mod.Dialog>
))
}
>
X-Large
</Button>
</div>
)
},
}
export const Transition = {
render: () => {
const dialog = useDialog()
return (
<Button
variant="secondary"
onClick={() =>
dialog.show(() => (
<mod.Dialog title="Transition" description="Animated" transition>
Transition enabled.
</mod.Dialog>
))
}
>
Open transition dialog
</Button>
)
},
}
export const CustomAction = {
render: () => {
const dialog = useDialog()
return (
<Button
variant="secondary"
onClick={() =>
dialog.show(() => (
<mod.Dialog
title="Custom action"
description="Dialog with a custom header action"
action={<Button variant="ghost">Help</Button>}
>
Dialog body content.
</mod.Dialog>
))
}
>
Open action dialog
</Button>
)
},
}
export const Fit = {
render: () => {
const dialog = useDialog()
return (
<Button
variant="secondary"
onClick={() =>
dialog.show(() => (
<mod.Dialog title="Fit content" fit>
Dialog fits its content.
</mod.Dialog>
))
}
>
Open fit dialog
</Button>
)
},
}
|