playbook_ui 14.11.1.pre.alpha.PLAY1751pbcontenttagpt25529 → 14.11.1.pre.alpha.PLAY17445539
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/app/pb_kits/playbook/pb_drawer/_drawer.scss +154 -177
- data/app/pb_kits/playbook/pb_drawer/_drawer.tsx +162 -264
- data/app/pb_kits/playbook/pb_drawer/context.ts +11 -0
- data/app/pb_kits/playbook/pb_drawer/docs/_drawer_behavior.jsx +38 -0
- data/app/pb_kits/playbook/pb_drawer/docs/_drawer_borders.jsx +3 -45
- data/app/pb_kits/playbook/pb_drawer/docs/_drawer_breakpoints.jsx +0 -1
- data/app/pb_kits/playbook/pb_drawer/docs/_drawer_default.jsx +9 -16
- data/app/pb_kits/playbook/pb_drawer/docs/_drawer_menu.jsx +44 -19
- data/app/pb_kits/playbook/pb_drawer/docs/_drawer_menu.md +21 -3
- data/app/pb_kits/playbook/pb_drawer/docs/_drawer_overlay.jsx +16 -21
- data/app/pb_kits/playbook/pb_drawer/docs/_drawer_sizes.jsx +2 -19
- data/app/pb_kits/playbook/pb_drawer/docs/example.yml +2 -1
- data/app/pb_kits/playbook/pb_drawer/docs/index.js +1 -0
- data/app/pb_kits/playbook/pb_drawer/drawer.test.jsx +5 -5
- data/app/pb_kits/playbook/pb_drawer/hooks/useBreakpoint.tsx +73 -0
- data/app/pb_kits/playbook/pb_drawer/hooks/useDrawerAnimation.tsx +21 -0
- data/app/pb_kits/playbook/pb_file_upload/file_upload.html.erb +6 -1
- data/app/pb_kits/playbook/pb_filter/filter.html.erb +5 -1
- data/app/pb_kits/playbook/pb_form_group/form_group.html.erb +6 -1
- data/app/pb_kits/playbook/pb_form_pill/form_pill.html.erb +1 -1
- data/dist/chunks/{_typeahead-TN5aDUj9.js → _typeahead-vFuUQM5F.js} +1 -1
- data/dist/chunks/_weekday_stacked-DG3A22sS.js +45 -0
- data/dist/chunks/vendor.js +1 -1
- data/dist/playbook-doc.js +1 -1
- data/dist/playbook-rails-react-bindings.js +1 -1
- data/dist/playbook-rails.js +1 -1
- data/dist/playbook.css +1 -1
- data/lib/playbook/version.rb +1 -1
- metadata +7 -3
- data/dist/chunks/_weekday_stacked-BcnpLG66.js +0 -45
@@ -1,230 +1,83 @@
|
|
1
|
-
import React, { useState, useEffect } from "react"
|
2
|
-
import classnames from "classnames"
|
1
|
+
import React, { useState, useEffect, useRef } from "react"
|
2
|
+
import classnames from "classnames"
|
3
3
|
|
4
4
|
import {
|
5
5
|
buildAriaProps,
|
6
6
|
buildCss,
|
7
7
|
buildDataProps,
|
8
8
|
buildHtmlProps,
|
9
|
-
} from "../utilities/props"
|
10
|
-
import { globalProps, globalInlineProps } from "../utilities/globalProps"
|
11
|
-
|
12
|
-
import {
|
9
|
+
} from "../utilities/props"
|
10
|
+
import { globalProps, globalInlineProps } from "../utilities/globalProps"
|
11
|
+
import { DrawerContext } from "./context"
|
12
|
+
import { useBreakpoint } from "./hooks/useBreakpoint"
|
13
13
|
|
14
14
|
type DrawerProps = {
|
15
|
-
aria?: { [key: string]: string }
|
16
|
-
behavior?: "floating" | "push"
|
17
|
-
border?: "full" | "none" | "right" | "left"
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
const Drawer = (props: DrawerProps): React.ReactElement => {
|
15
|
+
aria?: { [key: string]: string }
|
16
|
+
behavior?: "floating" | "push"
|
17
|
+
border?: "full" | "none" | "right" | "left"
|
18
|
+
breakpoint?: "none" | "xs" | "sm" | "md" | "lg" | "xl"
|
19
|
+
children: React.ReactNode | React.ReactNode[] | string
|
20
|
+
className?: string
|
21
|
+
data?: { [key: string]: string }
|
22
|
+
htmlOptions?: { [key: string]: string | number | boolean | (() => void) }
|
23
|
+
id?: string
|
24
|
+
triggerId?: string
|
25
|
+
onClose?: () => void
|
26
|
+
opened: boolean
|
27
|
+
overlay: boolean
|
28
|
+
placement?: "left" | "right" | "top" | "bottom"
|
29
|
+
size?: "xs" | "sm" | "md" | "lg" | "xl" | "full"
|
30
|
+
text?: string
|
31
|
+
withinElement?: boolean
|
32
|
+
}
|
33
|
+
|
34
|
+
const Drawer = (props: DrawerProps): React.ReactElement | null => {
|
37
35
|
const {
|
38
36
|
aria = {},
|
39
37
|
behavior = "floating",
|
40
38
|
border = "none",
|
41
|
-
|
42
|
-
closeBreakpoint = "none",
|
39
|
+
breakpoint = "none",
|
43
40
|
className,
|
44
41
|
data = {},
|
45
42
|
htmlOptions = {},
|
46
43
|
id,
|
47
44
|
size = "md",
|
48
45
|
children,
|
49
|
-
|
50
|
-
menuButtonID,
|
46
|
+
triggerId,
|
51
47
|
opened,
|
52
48
|
onClose,
|
53
49
|
overlay = true,
|
54
50
|
placement = "left",
|
55
51
|
withinElement = false,
|
56
|
-
} = props
|
57
|
-
|
58
|
-
const
|
59
|
-
const
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
"pl_",
|
69
|
-
"pr_",
|
70
|
-
"px_",
|
71
|
-
"py_",
|
72
|
-
].some((prefix) => globalPropsString.includes(prefix));
|
73
|
-
|
74
|
-
// If none of the prefixes are found, append 'p_sm' to the string
|
75
|
-
if (!containsPrefix) {
|
76
|
-
globalPropsString += " p_sm";
|
77
|
-
}
|
78
|
-
|
79
|
-
const drawerClassNames = {
|
80
|
-
base: `${classnames(
|
81
|
-
"pb_drawer",
|
82
|
-
buildCss("pb_drawer", size, placement),
|
83
|
-
{
|
84
|
-
drawer_border_full: border === "full",
|
85
|
-
drawer_border_right: border === "right",
|
86
|
-
drawer_border_left: border === "left",
|
87
|
-
pb_drawer_within_element: withinElement,
|
88
|
-
}
|
89
|
-
)} ${globalPropsString}`,
|
90
|
-
afterOpen: "pb_drawer_after_open",
|
91
|
-
beforeClose: "pb_drawer_before_close",
|
92
|
-
};
|
93
|
-
|
94
|
-
const fullHeightClassNames = () => {
|
95
|
-
if (!fullHeight) return null;
|
96
|
-
return `full_height_${placement}`;
|
97
|
-
};
|
98
|
-
|
99
|
-
const overlayClassNames = {
|
100
|
-
base: `pb_drawer${overlay ? "_overlay" : "_no_overlay"} ${
|
101
|
-
fullHeight !== null && fullHeightClassNames()
|
102
|
-
} ${!overlay ? "no-background" : ""}`,
|
103
|
-
afterOpen: "pb_drawer_overlay_after_open",
|
104
|
-
beforeClose: "pb_drawer_overlay_before_close",
|
105
|
-
};
|
106
|
-
|
107
|
-
const classes = classnames(buildCss("pb_drawer_wrapper"), className);
|
108
|
-
const dynamicInlineProps = globalInlineProps(props)
|
109
|
-
const [menuButtonOpened, setMenuButtonOpened] = useState(false);
|
110
|
-
const [triggerOpened, setTriggerOpened] = useState(false);
|
111
|
-
|
112
|
-
const breakpointWidths: Record<DrawerProps["openBreakpoint"], number> = {
|
113
|
-
none: 0,
|
114
|
-
xs: 575,
|
115
|
-
sm: 768,
|
116
|
-
md: 992,
|
117
|
-
lg: 1200,
|
118
|
-
xl: 1400,
|
119
|
-
};
|
120
|
-
|
121
|
-
const breakpointValues = {
|
122
|
-
none: 0,
|
123
|
-
xs: 575,
|
124
|
-
sm: 768,
|
125
|
-
md: 992,
|
126
|
-
lg: 1200,
|
127
|
-
xl: 1400,
|
128
|
-
}
|
129
|
-
|
130
|
-
const [isOpenBreakpointOpen, setIsOpenBreakpointOpen] = useState(false);
|
131
|
-
const [isUserClosed, setIsUserClosed] = useState(false);
|
132
|
-
|
133
|
-
useEffect(() => {
|
134
|
-
if (openBreakpoint === "none") return;
|
135
|
-
|
136
|
-
const handleResize = () => {
|
137
|
-
const width = window.innerWidth;
|
138
|
-
const openBreakpointWidth = breakpointWidths[openBreakpoint];
|
139
|
-
|
140
|
-
if (width <= openBreakpointWidth) {
|
141
|
-
setIsOpenBreakpointOpen(true);
|
142
|
-
} else {
|
143
|
-
setIsOpenBreakpointOpen(false);
|
144
|
-
setIsUserClosed(false); // Reset when the breakpoint condition changes
|
145
|
-
}
|
146
|
-
};
|
147
|
-
|
148
|
-
window.addEventListener("resize", handleResize);
|
149
|
-
|
150
|
-
// Call handler once on mount to set initial state
|
151
|
-
handleResize();
|
152
|
-
|
153
|
-
return () => {
|
154
|
-
window.removeEventListener("resize", handleResize);
|
155
|
-
};
|
156
|
-
}, [openBreakpoint]);
|
157
|
-
|
158
|
-
useEffect(() => {
|
159
|
-
if (closeBreakpoint === "none") return;
|
160
|
-
|
161
|
-
const handleResize = () => {
|
162
|
-
const width = window.innerWidth;
|
163
|
-
if (width >= breakpointValues[closeBreakpoint]) {
|
164
|
-
setIsOpenBreakpointOpen(true);
|
165
|
-
} else {
|
166
|
-
setIsOpenBreakpointOpen(false);
|
167
|
-
}
|
168
|
-
}
|
169
|
-
|
170
|
-
window.addEventListener("resize", handleResize);
|
171
|
-
|
172
|
-
handleResize();
|
173
|
-
|
174
|
-
return () => {
|
175
|
-
window.removeEventListener("resize", handleResize);
|
176
|
-
};
|
177
|
-
|
178
|
-
}, [closeBreakpoint]);
|
179
|
-
|
180
|
-
//hide menu button if breakpoint opens the drawer
|
181
|
-
useEffect(() => {
|
182
|
-
if (menuButtonID) {
|
183
|
-
const menuButton = document.getElementById(menuButtonID);
|
184
|
-
if (menuButton) {
|
185
|
-
if (isOpenBreakpointOpen) {
|
186
|
-
menuButton.style.display = 'none';
|
187
|
-
} else {
|
188
|
-
menuButton.style.display = '';
|
189
|
-
}
|
190
|
-
}
|
191
|
-
}
|
192
|
-
}, [menuButtonID, isOpenBreakpointOpen]);
|
193
|
-
|
194
|
-
// Reset isUserClosed when isBreakpointOpen changes
|
195
|
-
useEffect(() => {
|
196
|
-
if (isOpenBreakpointOpen) {
|
197
|
-
setIsUserClosed(false);
|
52
|
+
} = props
|
53
|
+
|
54
|
+
const drawerRef = useRef<HTMLDivElement>(null)
|
55
|
+
const [menuButtonOpened, setMenuButtonOpened] = useState(false)
|
56
|
+
const [shouldRender, setShouldRender] = useState(false)
|
57
|
+
const [isAnimating, setIsAnimating] = useState(false)
|
58
|
+
|
59
|
+
const { isOpenBreakpointOpen, isUserClosed, setIsUserClosed } = useBreakpoint(
|
60
|
+
{
|
61
|
+
openBreakpoint: breakpoint,
|
62
|
+
closeBreakpoint: breakpoint,
|
63
|
+
triggerId,
|
198
64
|
}
|
199
|
-
|
65
|
+
)
|
200
66
|
|
201
67
|
const modalIsOpened =
|
202
|
-
(isOpenBreakpointOpen && !isUserClosed) || menuButtonOpened || opened
|
68
|
+
(isOpenBreakpointOpen && !isUserClosed) || menuButtonOpened || opened
|
203
69
|
|
204
|
-
const [animationState, setAnimationState] = useState("");
|
205
|
-
|
206
|
-
useEffect(() => {
|
207
|
-
if (modalIsOpened) {
|
208
|
-
setAnimationState("afterOpen");
|
209
|
-
} else if (!modalIsOpened && animationState === "afterOpen") {
|
210
|
-
setAnimationState("beforeClose");
|
211
|
-
setTimeout(() => {
|
212
|
-
setAnimationState("");
|
213
|
-
}, 200);
|
214
|
-
}
|
215
|
-
}, [modalIsOpened]);
|
216
|
-
|
217
|
-
const isModalVisible = modalIsOpened || animationState === "beforeClose";
|
218
70
|
|
219
71
|
useEffect(() => {
|
220
72
|
if (withinElement) return;
|
221
73
|
|
222
|
-
const sizeMap:
|
74
|
+
const sizeMap: { [key: string]: string } = {
|
223
75
|
xl: "365px",
|
224
76
|
lg: "300px",
|
225
77
|
md: "250px",
|
226
78
|
sm: "200px",
|
227
79
|
xs: "64px",
|
80
|
+
full: "100%",
|
228
81
|
};
|
229
82
|
const body = document.querySelector("body");
|
230
83
|
if (modalIsOpened && behavior === "push" && body) {
|
@@ -244,98 +97,143 @@ const Drawer = (props: DrawerProps): React.ReactElement => {
|
|
244
97
|
}
|
245
98
|
}, [modalIsOpened, behavior, placement, size, withinElement]);
|
246
99
|
|
247
|
-
|
248
|
-
|
249
|
-
|
250
|
-
|
251
|
-
|
252
|
-
|
253
|
-
|
254
|
-
|
255
|
-
|
256
|
-
|
257
|
-
|
100
|
+
// Replace useDrawerAnimation with our new animation logic
|
101
|
+
useEffect(() => {
|
102
|
+
if (modalIsOpened) {
|
103
|
+
// Step 1: Mount component
|
104
|
+
setShouldRender(true)
|
105
|
+
|
106
|
+
// Step 2: Measure height and start animation
|
107
|
+
const timer = setTimeout(() => {
|
108
|
+
if (drawerRef.current) {
|
109
|
+
const height = drawerRef.current.scrollHeight;
|
110
|
+
drawerRef.current.style.setProperty('--drawer-height', `${height}px`);
|
111
|
+
}
|
112
|
+
setIsAnimating(true)
|
113
|
+
}, 10)
|
114
|
+
return () => clearTimeout(timer)
|
115
|
+
} else {
|
116
|
+
// Step 3: Start closing animation
|
117
|
+
setIsAnimating(false)
|
118
|
+
|
119
|
+
// Step 4: Unmount after animation completes
|
120
|
+
const timer = setTimeout(() => {
|
121
|
+
setShouldRender(false)
|
122
|
+
}, 250) // Match animation duration
|
123
|
+
return () => clearTimeout(timer)
|
124
|
+
}
|
125
|
+
}, [modalIsOpened])
|
258
126
|
|
127
|
+
// Remove the showElement/hideElement effect since we're handling visibility with CSS
|
259
128
|
useEffect(() => {
|
260
|
-
if (
|
261
|
-
const
|
129
|
+
if (drawerRef.current && modalIsOpened) {
|
130
|
+
const height = drawerRef.current.scrollHeight;
|
131
|
+
drawerRef.current.style.setProperty('--drawer-height', `${height}px`);
|
132
|
+
}
|
133
|
+
}, [modalIsOpened])
|
134
|
+
|
135
|
+
// Handle menu button click
|
136
|
+
useEffect(() => {
|
137
|
+
if (triggerId) {
|
138
|
+
const menuButton = document.getElementById(triggerId)
|
262
139
|
if (menuButton) {
|
263
140
|
const handleMenuButtonClick = () => {
|
264
141
|
if (modalIsOpened) {
|
265
|
-
|
266
|
-
|
267
|
-
setIsUserClosed(true);
|
142
|
+
setMenuButtonOpened(false)
|
143
|
+
setIsUserClosed(true)
|
268
144
|
} else {
|
269
|
-
|
270
|
-
|
271
|
-
setIsUserClosed(false);
|
145
|
+
setMenuButtonOpened(true)
|
146
|
+
setIsUserClosed(false)
|
272
147
|
}
|
273
|
-
}
|
274
|
-
menuButton.addEventListener("click", handleMenuButtonClick)
|
148
|
+
}
|
149
|
+
menuButton.addEventListener("click", handleMenuButtonClick)
|
275
150
|
return () => {
|
276
|
-
menuButton.removeEventListener("click", handleMenuButtonClick)
|
277
|
-
}
|
151
|
+
menuButton.removeEventListener("click", handleMenuButtonClick)
|
152
|
+
}
|
278
153
|
}
|
279
154
|
}
|
280
|
-
}, [
|
155
|
+
}, [triggerId, modalIsOpened])
|
156
|
+
|
157
|
+
const ariaProps = buildAriaProps(aria)
|
158
|
+
const dataProps = buildDataProps(data)
|
159
|
+
const htmlProps = buildHtmlProps(htmlOptions)
|
160
|
+
const dynamicInlineProps = globalInlineProps(props)
|
161
|
+
|
162
|
+
const drawerClasses = classnames(
|
163
|
+
"pb_drawer",
|
164
|
+
buildCss("pb_drawer", size as string, placement as string),
|
165
|
+
{
|
166
|
+
"drawer_border-full": border === "full",
|
167
|
+
"drawer_border-right": border === "right",
|
168
|
+
"drawer_border-left": border === "left",
|
169
|
+
pb_drawer_within_element: withinElement,
|
170
|
+
pb_drawer_collapsing: shouldRender && !isAnimating,
|
171
|
+
pb_drawer_after_open: isAnimating,
|
172
|
+
pb_drawer_before_close: !isAnimating && shouldRender,
|
173
|
+
},
|
174
|
+
withinElement ? "shadow_none" : "shadow_deepest",
|
175
|
+
globalProps(props),
|
176
|
+
className
|
177
|
+
)
|
178
|
+
|
179
|
+
const overlayClasses = classnames(
|
180
|
+
`pb_drawer${overlay ? "_overlay" : "_no_overlay"}`,
|
181
|
+
`drawer_content_${placement}`,
|
182
|
+
!overlay && "no-background",
|
183
|
+
{
|
184
|
+
pb_drawer_overlay_after_open: isAnimating,
|
185
|
+
pb_drawer_overlay_before_close: !isAnimating && shouldRender,
|
186
|
+
}
|
187
|
+
)
|
188
|
+
|
189
|
+
const api = {
|
190
|
+
onClose: () => {
|
191
|
+
if (triggerId) {
|
192
|
+
setMenuButtonOpened(false)
|
193
|
+
}
|
194
|
+
setIsUserClosed(true)
|
195
|
+
if (onClose) {
|
196
|
+
onClose()
|
197
|
+
}
|
198
|
+
},
|
199
|
+
}
|
200
|
+
|
201
|
+
const drawerContent = (
|
202
|
+
<div
|
203
|
+
className={drawerClasses}
|
204
|
+
onClick={(e) => e.stopPropagation()}
|
205
|
+
ref={drawerRef}
|
206
|
+
>
|
207
|
+
{children}
|
208
|
+
</div>
|
209
|
+
)
|
210
|
+
|
211
|
+
// Step 5: Only render when shouldRender is true
|
212
|
+
if (!shouldRender) return null
|
281
213
|
|
282
214
|
return (
|
283
|
-
<
|
215
|
+
<DrawerContext.Provider value={api}>
|
284
216
|
{withinElement ? (
|
285
|
-
|
286
|
-
<div
|
287
|
-
{...ariaProps}
|
288
|
-
{...dataProps}
|
289
|
-
{...htmlProps}
|
290
|
-
className={classnames(drawerClassNames.base, {
|
291
|
-
[drawerClassNames.afterOpen]:
|
292
|
-
animationState === "afterOpen",
|
293
|
-
[drawerClassNames.beforeClose]:
|
294
|
-
animationState === "beforeClose",
|
295
|
-
})}
|
296
|
-
id={id}
|
297
|
-
onClick={(e) => e.stopPropagation()}
|
298
|
-
style={dynamicInlineProps}
|
299
|
-
>
|
300
|
-
{children}
|
301
|
-
</div>
|
302
|
-
)
|
217
|
+
drawerContent
|
303
218
|
) : (
|
304
219
|
<div
|
305
220
|
{...ariaProps}
|
306
221
|
{...dataProps}
|
307
222
|
{...htmlProps}
|
308
|
-
className={
|
223
|
+
className={classnames(buildCss("pb_drawer_wrapper"), className)}
|
224
|
+
style={dynamicInlineProps}
|
309
225
|
>
|
310
|
-
|
311
|
-
|
312
|
-
|
313
|
-
|
314
|
-
|
315
|
-
|
316
|
-
|
317
|
-
})}
|
318
|
-
id={id}
|
319
|
-
onClick={overlay ? api.onClose : undefined}
|
320
|
-
>
|
321
|
-
<div
|
322
|
-
className={classnames(drawerClassNames.base, {
|
323
|
-
[drawerClassNames.afterOpen]:
|
324
|
-
animationState === "afterOpen",
|
325
|
-
[drawerClassNames.beforeClose]:
|
326
|
-
animationState === "beforeClose",
|
327
|
-
})}
|
328
|
-
onClick={(e) => e.stopPropagation()}
|
329
|
-
style={dynamicInlineProps}
|
330
|
-
>
|
331
|
-
{children}
|
332
|
-
</div>
|
333
|
-
</div>
|
334
|
-
)}
|
226
|
+
<div
|
227
|
+
className={overlayClasses}
|
228
|
+
id={id}
|
229
|
+
onClick={overlay ? api.onClose : undefined}
|
230
|
+
>
|
231
|
+
{drawerContent}
|
232
|
+
</div>
|
335
233
|
</div>
|
336
234
|
)}
|
337
|
-
</
|
338
|
-
)
|
339
|
-
}
|
235
|
+
</DrawerContext.Provider>
|
236
|
+
)
|
237
|
+
}
|
340
238
|
|
341
|
-
export default Drawer
|
239
|
+
export default Drawer
|
@@ -0,0 +1,38 @@
|
|
1
|
+
import React, { useState } from "react"
|
2
|
+
import { Button, Drawer, Flex } from "playbook-ui"
|
3
|
+
|
4
|
+
const useDrawer = (visible = false) => {
|
5
|
+
const [opened, setOpened] = useState(visible)
|
6
|
+
const toggle = () => setOpened(!opened)
|
7
|
+
|
8
|
+
return [opened, toggle]
|
9
|
+
}
|
10
|
+
|
11
|
+
const DrawerBehavior = () => {
|
12
|
+
const [drawerOpen, toggleDrawerOpen] = useDrawer()
|
13
|
+
|
14
|
+
return (
|
15
|
+
<>
|
16
|
+
<Flex wrap>
|
17
|
+
<Button id='sm'
|
18
|
+
marginRight='md'
|
19
|
+
onClick={toggleDrawerOpen}
|
20
|
+
>
|
21
|
+
{"Push Behavior"}
|
22
|
+
</Button>
|
23
|
+
</Flex>
|
24
|
+
<Flex>
|
25
|
+
<Drawer
|
26
|
+
behavior={"push"}
|
27
|
+
onClose={toggleDrawerOpen}
|
28
|
+
opened={drawerOpen}
|
29
|
+
size={"lg"}
|
30
|
+
>
|
31
|
+
Test me (Push Behavior)
|
32
|
+
</Drawer>
|
33
|
+
</Flex>
|
34
|
+
</>
|
35
|
+
)
|
36
|
+
}
|
37
|
+
|
38
|
+
export default DrawerBehavior
|
@@ -6,19 +6,15 @@ const DrawerBorders = () => {
|
|
6
6
|
const [openedBRightDrawer, setOpenedBRightDrawer] = useState(false);
|
7
7
|
const [openedBLeftDrawer, setOpenedBLeftDrawer] = useState(false);
|
8
8
|
const [openedBFullDrawer, setOpenedBFullDrawer] = useState(false);
|
9
|
-
const [openedBDefaultDrawer, setOpenedBDefaultDrawer] = useState(false);
|
10
|
-
const [openedBRoundedDrawer, setOpenedBRoundedDrawer] = useState(false);
|
11
9
|
|
12
10
|
// Toggle functions for each drawer
|
13
11
|
const toggleBRightDrawer = () => setOpenedBRightDrawer(!openedBRightDrawer);
|
14
12
|
const toggleBLeftDrawer = () => setOpenedBLeftDrawer(!openedBLeftDrawer);
|
15
13
|
const toggleBFullDrawer = () => setOpenedBFullDrawer(!openedBFullDrawer);
|
16
|
-
const toggleBDefaultDrawer = () => setOpenedBDefaultDrawer(!openedBDefaultDrawer);
|
17
|
-
const toggleBRoundedDrawer = () => setOpenedBRoundedDrawer(!openedBRoundedDrawer);
|
18
14
|
|
19
15
|
return (
|
20
16
|
<>
|
21
|
-
<Flex
|
17
|
+
<Flex
|
22
18
|
wrap
|
23
19
|
>
|
24
20
|
<Button marginRight="md"
|
@@ -36,23 +32,12 @@ const DrawerBorders = () => {
|
|
36
32
|
>
|
37
33
|
Drawer with border full
|
38
34
|
</Button>
|
39
|
-
<Button marginRight="md"
|
40
|
-
onClick={toggleBDefaultDrawer}
|
41
|
-
>
|
42
|
-
Default Drawer
|
43
|
-
</Button>
|
44
|
-
<Button marginRight="md"
|
45
|
-
onClick={toggleBRoundedDrawer}
|
46
|
-
>
|
47
|
-
Rounded Drawer
|
48
|
-
</Button>
|
49
35
|
</Flex>
|
50
36
|
|
51
37
|
{/* Drawers for each size */}
|
52
38
|
<Drawer
|
53
39
|
behavior="float"
|
54
40
|
border="right"
|
55
|
-
fullHeight
|
56
41
|
onClose={toggleBRightDrawer}
|
57
42
|
opened={openedBRightDrawer}
|
58
43
|
overlay={false}
|
@@ -64,11 +49,10 @@ const DrawerBorders = () => {
|
|
64
49
|
<Drawer
|
65
50
|
behavior="float"
|
66
51
|
border="left"
|
67
|
-
fullHeight
|
68
52
|
onClose={toggleBLeftDrawer}
|
69
53
|
opened={openedBLeftDrawer}
|
70
54
|
overlay={false}
|
71
|
-
placement="
|
55
|
+
placement="left"
|
72
56
|
size="lg"
|
73
57
|
>
|
74
58
|
This is a Drawer with border left
|
@@ -76,40 +60,14 @@ const DrawerBorders = () => {
|
|
76
60
|
<Drawer
|
77
61
|
behavior="float"
|
78
62
|
border="full"
|
79
|
-
fullHeight
|
80
63
|
onClose={toggleBFullDrawer}
|
81
64
|
opened={openedBFullDrawer}
|
82
65
|
overlay={false}
|
83
|
-
placement="
|
66
|
+
placement="left"
|
84
67
|
size="lg"
|
85
68
|
>
|
86
69
|
This is a Drawer with border full
|
87
70
|
</Drawer>
|
88
|
-
<Drawer
|
89
|
-
behavior="float"
|
90
|
-
fullHeight
|
91
|
-
onClose={toggleBDefaultDrawer}
|
92
|
-
opened={openedBDefaultDrawer}
|
93
|
-
overlay={false}
|
94
|
-
placement="right"
|
95
|
-
size="lg"
|
96
|
-
>
|
97
|
-
This is a Default Drawer
|
98
|
-
</Drawer>
|
99
|
-
<Drawer
|
100
|
-
behavior="float"
|
101
|
-
borderRadius="rounded"
|
102
|
-
fullHeight
|
103
|
-
onClose={toggleBRoundedDrawer}
|
104
|
-
opened={openedBRoundedDrawer}
|
105
|
-
overlay={false}
|
106
|
-
placement="right"
|
107
|
-
size="lg"
|
108
|
-
>
|
109
|
-
<div style={{ paddingTop: '100px', paddingLeft: '12px' }}>
|
110
|
-
This is a Rounded Drawer
|
111
|
-
</div>
|
112
|
-
</Drawer>
|
113
71
|
</>
|
114
72
|
);
|
115
73
|
};
|