adnbn-ui 0.0.1 → 0.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.prettierignore +3 -0
- package/.prettierrc +28 -0
- package/.storybook/main.ts +22 -0
- package/.storybook/preview.tsx +100 -0
- package/.storybook/styles/custom.scss +59 -0
- package/.storybook/styles/preview.css +58 -0
- package/.storybook/vitest.setup.ts +9 -0
- package/eslint.config.js +39 -0
- package/package.json +77 -2
- package/src/components/Avatar/Avatar.stories.tsx +118 -0
- package/src/components/Avatar/Avatar.tsx +65 -0
- package/src/components/Avatar/avatar.module.scss +77 -0
- package/src/components/Avatar/index.ts +2 -0
- package/src/components/BaseButton/BaseButton.tsx +36 -0
- package/src/components/BaseButton/base-button.module.scss +24 -0
- package/src/components/BaseButton/index.ts +2 -0
- package/src/components/Button/Button.stories.tsx +148 -0
- package/src/components/Button/Button.tsx +73 -0
- package/src/components/Button/button.module.scss +140 -0
- package/src/components/Button/index.ts +2 -0
- package/src/components/Checkbox/Checkbox.stories.tsx +180 -0
- package/src/components/Checkbox/Checkbox.tsx +71 -0
- package/src/components/Checkbox/checkbox.module.scss +82 -0
- package/src/components/Checkbox/index.ts +2 -0
- package/src/components/Dialog/Dialog.tsx +125 -0
- package/src/components/Dialog/dialog.module.scss +55 -0
- package/src/components/Dialog/index.ts +2 -0
- package/src/components/Drawer/Drawer.stories.tsx +89 -0
- package/src/components/Drawer/Drawer.tsx +57 -0
- package/src/components/Drawer/drawer.module.scss +170 -0
- package/src/components/Drawer/index.ts +2 -0
- package/src/components/Footer/Footer.stories.tsx +118 -0
- package/src/components/Footer/Footer.tsx +58 -0
- package/src/components/Footer/footer.module.scss +44 -0
- package/src/components/Footer/index.ts +2 -0
- package/src/components/Header/Header.stories.tsx +49 -0
- package/src/components/Header/Header.tsx +73 -0
- package/src/components/Header/header.module.scss +56 -0
- package/src/components/Header/index.ts +2 -0
- package/src/components/Highlight/Highlight.stories.tsx +83 -0
- package/src/components/Highlight/Highlight.tsx +40 -0
- package/src/components/Highlight/highlight.module.scss +47 -0
- package/src/components/Highlight/index.ts +2 -0
- package/src/components/Icon/Icon.tsx +46 -0
- package/src/components/Icon/icon.module.scss +17 -0
- package/src/components/Icon/index.ts +2 -0
- package/src/components/IconButton/IconButton.stories.tsx +179 -0
- package/src/components/IconButton/IconButton.tsx +65 -0
- package/src/components/IconButton/icon-button.module.scss +86 -0
- package/src/components/IconButton/index.ts +2 -0
- package/src/components/Layout/Layout.stories.tsx +88 -0
- package/src/components/Layout/Provider.tsx +47 -0
- package/src/components/Layout/context.ts +24 -0
- package/src/components/Layout/index.ts +2 -0
- package/src/components/Layout/layout.module.scss +17 -0
- package/src/components/List/List.stories.tsx +81 -0
- package/src/components/List/List.tsx +24 -0
- package/src/components/List/index.ts +2 -0
- package/src/components/List/list.module.scss +8 -0
- package/src/components/ListItem/ListItem.tsx +75 -0
- package/src/components/ListItem/index.ts +2 -0
- package/src/components/ListItem/list-item.module.scss +36 -0
- package/src/components/Modal/Modal.stories.tsx +95 -0
- package/src/components/Modal/Modal.tsx +94 -0
- package/src/components/Modal/index.ts +2 -0
- package/src/components/Modal/modal.module.scss +97 -0
- package/src/components/Odometer/Odometer.stories.tsx +66 -0
- package/src/components/Odometer/Odometer.tsx +45 -0
- package/src/components/Odometer/hooks/useOdometer.tsx +24 -0
- package/src/components/Odometer/index.ts +3 -0
- package/src/components/Odometer/odometer.module.scss +81 -0
- package/src/components/Odometer/odometr.d.ts +9 -0
- package/src/components/ScrollArea/ScrollArea.stories.tsx +58 -0
- package/src/components/ScrollArea/ScrollArea.tsx +63 -0
- package/src/components/ScrollArea/index.ts +2 -0
- package/src/components/ScrollArea/scroll-area.module.scss +54 -0
- package/src/components/SvgSprite/SvgSprite.tsx +21 -0
- package/src/components/SvgSprite/index.ts +2 -0
- package/src/components/Switch/Switch.stories.tsx +25 -0
- package/src/components/Switch/Switch.tsx +23 -0
- package/src/components/Switch/index.ts +2 -0
- package/src/components/Switch/switch.module.scss +65 -0
- package/src/components/Tag/Tag.stories.tsx +157 -0
- package/src/components/Tag/Tag.tsx +71 -0
- package/src/components/Tag/index.ts +2 -0
- package/src/components/Tag/tag.module.scss +118 -0
- package/src/components/TextArea/TextArea.stories.tsx +145 -0
- package/src/components/TextArea/TextArea.tsx +143 -0
- package/src/components/TextArea/index.ts +2 -0
- package/src/components/TextArea/text-area.module.scss +88 -0
- package/src/components/TextField/TextField.stories.tsx +177 -0
- package/src/components/TextField/TextField.tsx +162 -0
- package/src/components/TextField/index.ts +2 -0
- package/src/components/TextField/text-field.module.scss +129 -0
- package/src/components/Toast/Toast.stories.tsx +209 -0
- package/src/components/Toast/Toast.tsx +142 -0
- package/src/components/Toast/index.ts +2 -0
- package/src/components/Toast/toast.module.scss +267 -0
- package/src/components/Tooltip/Tooltip.stories.tsx +80 -0
- package/src/components/Tooltip/Tooltip.tsx +79 -0
- package/src/components/Tooltip/index.ts +2 -0
- package/src/components/Tooltip/tooltip.module.scss +93 -0
- package/src/components/View/View.stories.tsx +47 -0
- package/src/components/View/View.tsx +68 -0
- package/src/components/View/index.ts +2 -0
- package/src/components/View/view.module.scss +38 -0
- package/src/components/ViewDrawer/ViewDrawer.stories.tsx +75 -0
- package/src/components/ViewDrawer/ViewDrawer.tsx +24 -0
- package/src/components/ViewDrawer/index.ts +2 -0
- package/src/components/ViewModal/ViewModal.stories.tsx +68 -0
- package/src/components/ViewModal/ViewModal.tsx +24 -0
- package/src/components/ViewModal/index.ts +2 -0
- package/src/components/index.ts +29 -0
- package/src/components/types.ts +65 -0
- package/src/config/default.ts +3 -0
- package/src/config/index.ts +26 -0
- package/src/declaration.d.ts +8 -0
- package/src/index.ts +3 -0
- package/src/plugin/builder/ConfigBuilder.ts +32 -0
- package/src/plugin/builder/StyleBuilder.ts +34 -0
- package/src/plugin/builder/virtual.config.ts +7 -0
- package/src/plugin/finder/ConfigFinder.ts +26 -0
- package/src/plugin/finder/Finder.ts +76 -0
- package/src/plugin/finder/StyleFinder.ts +23 -0
- package/src/plugin/index.ts +70 -0
- package/src/plugin/types.ts +8 -0
- package/src/providers/UIProvider.tsx +26 -0
- package/src/providers/icons/IconsProvider.tsx +34 -0
- package/src/providers/icons/context.ts +22 -0
- package/src/providers/icons/index.ts +3 -0
- package/src/providers/index.ts +3 -0
- package/src/providers/theme/ThemeProvider.tsx +39 -0
- package/src/providers/theme/context.ts +30 -0
- package/src/providers/theme/index.ts +2 -0
- package/src/providers/theme/styles/default.scss +95 -0
- package/src/providers/theme/styles/reset.css +111 -0
- package/src/styles/mixins.scss +23 -0
- package/src/types/theme.ts +4 -0
- package/src/utils/index.ts +2 -0
- package/src/utils/react.ts +21 -0
- package/src/utils/utils.ts +12 -0
- package/tsconfig.json +18 -0
- package/vite.config.ts +11 -0
- package/vitest.workspace.ts +19 -0
- package/components/Button/index.ts +0 -0
@@ -0,0 +1,82 @@
|
|
1
|
+
$root: checkbox;
|
2
|
+
|
3
|
+
.#{$root} {
|
4
|
+
display: flex;
|
5
|
+
align-items: center;
|
6
|
+
justify-content: center;
|
7
|
+
cursor: pointer;
|
8
|
+
padding: 2px;
|
9
|
+
width: var(--checkbox-size, 18px);
|
10
|
+
height: var(--checkbox-size, 18px);
|
11
|
+
border-radius: var(--checkbox-border-radius, 4px);
|
12
|
+
color: var(--checkbox-color, #333);
|
13
|
+
border: var(--checkbox-border-width, 1px) solid var(--checkbox-border-color, #999);
|
14
|
+
will-change: background, color;
|
15
|
+
transition:
|
16
|
+
background var(--transition-speed-sm),
|
17
|
+
color var(--transition-speed-sm);
|
18
|
+
|
19
|
+
&:disabled {
|
20
|
+
opacity: var(--checkbox-disabled-opacity, 0.6);
|
21
|
+
cursor: default;
|
22
|
+
}
|
23
|
+
|
24
|
+
&:active:not(:disabled) {
|
25
|
+
transform: scale(var(--checkbox-scale, 0.98));
|
26
|
+
}
|
27
|
+
|
28
|
+
//Variants
|
29
|
+
&--classic {
|
30
|
+
color: var(--checkbox-classic-color, white);
|
31
|
+
background: var(--checkbox-classic-bg-color);
|
32
|
+
border: var(--checkbox-classic-border-width, 1px) solid var(--checkbox-classic-border-color, #999);
|
33
|
+
|
34
|
+
&[data-state="checked"],
|
35
|
+
&[data-state="indeterminate"] {
|
36
|
+
background: var(--checkbox-checked-bg-color, var(--primary-color));
|
37
|
+
border: none;
|
38
|
+
}
|
39
|
+
}
|
40
|
+
|
41
|
+
&--soft {
|
42
|
+
color: var(--checkbox-soft-color, white);
|
43
|
+
background: var(--checkbox-soft-bg-color, var(--secondary-color));
|
44
|
+
border: none;
|
45
|
+
}
|
46
|
+
|
47
|
+
//sizes
|
48
|
+
&--small-size {
|
49
|
+
width: var(--checkbox-size-sm, 16px);
|
50
|
+
height: var(--checkbox-size-sm, 16px);
|
51
|
+
}
|
52
|
+
|
53
|
+
&--medium-size {
|
54
|
+
width: var(--checkbox-size-md, 20px);
|
55
|
+
height: var(--checkbox-size-md, 20px);
|
56
|
+
}
|
57
|
+
|
58
|
+
&--large-size {
|
59
|
+
width: var(--checkbox-size-lg, 22px);
|
60
|
+
height: var(--checkbox-size-lg, 22px);
|
61
|
+
}
|
62
|
+
|
63
|
+
//Radius
|
64
|
+
&--small-radius {
|
65
|
+
border-radius: var(--checkbox-border-radius-sm, 2px);
|
66
|
+
}
|
67
|
+
|
68
|
+
&--large-radius {
|
69
|
+
border-radius: var(--checkbox-border-radius-lg, 6px);
|
70
|
+
}
|
71
|
+
|
72
|
+
&__indicator {
|
73
|
+
display: flex;
|
74
|
+
align-items: center;
|
75
|
+
justify-content: center;
|
76
|
+
|
77
|
+
& svg {
|
78
|
+
width: 100%;
|
79
|
+
height: 100%;
|
80
|
+
}
|
81
|
+
}
|
82
|
+
}
|
@@ -0,0 +1,125 @@
|
|
1
|
+
import React, {FC, memo, useEffect, useRef} from "react";
|
2
|
+
import classnames from "classnames";
|
3
|
+
import {
|
4
|
+
Content,
|
5
|
+
Description,
|
6
|
+
DialogContentProps,
|
7
|
+
DialogPortalProps,
|
8
|
+
DialogProps as DialogRootProps,
|
9
|
+
Overlay,
|
10
|
+
Portal,
|
11
|
+
Root,
|
12
|
+
Title,
|
13
|
+
} from "@radix-ui/react-dialog";
|
14
|
+
import {VisuallyHidden} from "radix-ui";
|
15
|
+
|
16
|
+
import {useComponentProps} from "../../providers";
|
17
|
+
import {cloneOrCreateElement} from "../../utils";
|
18
|
+
|
19
|
+
import styles from "./dialog.module.scss";
|
20
|
+
|
21
|
+
export interface DialogProps extends DialogRootProps, DialogPortalProps, DialogContentProps {
|
22
|
+
speed?: number;
|
23
|
+
description?: string;
|
24
|
+
fullscreen?: boolean;
|
25
|
+
className?: string;
|
26
|
+
overlayClassName?: string;
|
27
|
+
childrenClassName?: string;
|
28
|
+
}
|
29
|
+
|
30
|
+
export const dialogPropsKeys = new Set<keyof DialogProps>([
|
31
|
+
// Dialog keys
|
32
|
+
"speed",
|
33
|
+
"description",
|
34
|
+
"fullscreen",
|
35
|
+
"className",
|
36
|
+
"overlayClassName",
|
37
|
+
"childrenClassName",
|
38
|
+
|
39
|
+
// Extended Dialog keys
|
40
|
+
"open",
|
41
|
+
"defaultOpen",
|
42
|
+
"onOpenChange",
|
43
|
+
"modal",
|
44
|
+
"container",
|
45
|
+
"title",
|
46
|
+
]);
|
47
|
+
|
48
|
+
const Dialog: FC<DialogProps> = props => {
|
49
|
+
const {
|
50
|
+
speed = 200,
|
51
|
+
open,
|
52
|
+
defaultOpen,
|
53
|
+
onOpenChange,
|
54
|
+
modal,
|
55
|
+
children,
|
56
|
+
container,
|
57
|
+
title,
|
58
|
+
description,
|
59
|
+
className,
|
60
|
+
overlayClassName,
|
61
|
+
childrenClassName,
|
62
|
+
...other
|
63
|
+
} = {...useComponentProps("dialog"), ...props};
|
64
|
+
|
65
|
+
const timeoutId = useRef<ReturnType<typeof setTimeout> | undefined>(undefined);
|
66
|
+
const intervalId = useRef<ReturnType<typeof setInterval> | undefined>(undefined);
|
67
|
+
|
68
|
+
useEffect(() => {
|
69
|
+
clearInterval(intervalId.current);
|
70
|
+
clearTimeout(timeoutId.current);
|
71
|
+
|
72
|
+
if (open) {
|
73
|
+
const scrollbarWidth = window.innerWidth - document.documentElement.clientWidth;
|
74
|
+
document.body.style.overflow = "hidden";
|
75
|
+
document.body.style.boxSizing = "border-box";
|
76
|
+
document.body.style.setProperty("padding-right", `${scrollbarWidth}px`, "important");
|
77
|
+
} else {
|
78
|
+
intervalId.current = setInterval(() => {
|
79
|
+
const scrollbarWidth = window.innerWidth - document.documentElement.clientWidth;
|
80
|
+
if (scrollbarWidth) {
|
81
|
+
document.body.style.overflow = "";
|
82
|
+
document.body.style.paddingRight = "";
|
83
|
+
clearInterval(intervalId.current);
|
84
|
+
}
|
85
|
+
}, 10);
|
86
|
+
|
87
|
+
timeoutId.current = setTimeout(() => {
|
88
|
+
clearInterval(intervalId.current);
|
89
|
+
}, speed + 100);
|
90
|
+
}
|
91
|
+
|
92
|
+
return () => {
|
93
|
+
document.body.style.overflow = "";
|
94
|
+
};
|
95
|
+
}, [open, speed]);
|
96
|
+
|
97
|
+
return (
|
98
|
+
<Root open={open} defaultOpen={defaultOpen} onOpenChange={onOpenChange} modal={modal}>
|
99
|
+
<Portal container={container}>
|
100
|
+
<Overlay
|
101
|
+
className={classnames(styles["dialog-overlay"], overlayClassName)}
|
102
|
+
style={{animationDuration: `${speed}ms`}}
|
103
|
+
/>
|
104
|
+
<Content
|
105
|
+
className={classnames(styles["dialog-content"], className)}
|
106
|
+
style={{animationDuration: `${speed}ms`}}
|
107
|
+
{...other}
|
108
|
+
>
|
109
|
+
<VisuallyHidden.Root>
|
110
|
+
<Title>{title}</Title>
|
111
|
+
<Description>{description}</Description>
|
112
|
+
</VisuallyHidden.Root>
|
113
|
+
|
114
|
+
{cloneOrCreateElement(
|
115
|
+
children,
|
116
|
+
{className: classnames(styles["dialog-children"], childrenClassName)},
|
117
|
+
"div"
|
118
|
+
)}
|
119
|
+
</Content>
|
120
|
+
</Portal>
|
121
|
+
</Root>
|
122
|
+
);
|
123
|
+
};
|
124
|
+
|
125
|
+
export default memo(Dialog);
|
@@ -0,0 +1,55 @@
|
|
1
|
+
$root: dialog;
|
2
|
+
|
3
|
+
.#{$root} {
|
4
|
+
&-overlay {
|
5
|
+
position: fixed;
|
6
|
+
inset: 0;
|
7
|
+
z-index: 999;
|
8
|
+
background-color: var(--dialog-overlay-bg-color, #111);
|
9
|
+
opacity: var(--dialog-animation-overlay-opacity, 0.9);
|
10
|
+
animation-timing-function: ease-in-out;
|
11
|
+
|
12
|
+
&[data-state="open"] {
|
13
|
+
animation-name: overlayShow;
|
14
|
+
}
|
15
|
+
|
16
|
+
&[data-state="closed"] {
|
17
|
+
animation-name: overlayHide;
|
18
|
+
}
|
19
|
+
}
|
20
|
+
|
21
|
+
&-content {
|
22
|
+
box-sizing: border-box;
|
23
|
+
position: fixed;
|
24
|
+
z-index: 9999;
|
25
|
+
transition:
|
26
|
+
background-color var(--transition-speed-sm),
|
27
|
+
color var(--transition-speed-sm);
|
28
|
+
animation-timing-function: ease-in-out;
|
29
|
+
}
|
30
|
+
|
31
|
+
&-children {
|
32
|
+
display: flex;
|
33
|
+
flex-direction: column;
|
34
|
+
width: 100%;
|
35
|
+
height: 100%;
|
36
|
+
}
|
37
|
+
}
|
38
|
+
|
39
|
+
@keyframes overlayShow {
|
40
|
+
from {
|
41
|
+
opacity: 0;
|
42
|
+
}
|
43
|
+
to {
|
44
|
+
opacity: var(--dialog-animation-overlay-opacity, 0.9);
|
45
|
+
}
|
46
|
+
}
|
47
|
+
|
48
|
+
@keyframes overlayHide {
|
49
|
+
from {
|
50
|
+
opacity: var(--dialog-animation-overlay-opacity, 0.9);
|
51
|
+
}
|
52
|
+
to {
|
53
|
+
opacity: 0;
|
54
|
+
}
|
55
|
+
}
|
@@ -0,0 +1,89 @@
|
|
1
|
+
import {useState} from "react";
|
2
|
+
import {Meta} from "@storybook/react";
|
3
|
+
|
4
|
+
import {capitalizeFirstLetter, hideInTable} from "../../utils";
|
5
|
+
|
6
|
+
import {Button, List, ListItem} from "../index";
|
7
|
+
|
8
|
+
import DrawerComponent, {DrawerProps, DrawerSide} from "./Drawer";
|
9
|
+
|
10
|
+
const sides: DrawerSide[] = [DrawerSide.Left, DrawerSide.Top, DrawerSide.Bottom, DrawerSide.Right];
|
11
|
+
const items = [
|
12
|
+
{title: "Profile", icon: "👤"},
|
13
|
+
{title: "Messages", icon: "✉️"},
|
14
|
+
{title: "Notifications", icon: "🔔"},
|
15
|
+
{title: "Setting", icon: "⚙️"},
|
16
|
+
{title: "Help", icon: "❓"},
|
17
|
+
{title: "Logout", icon: "🚪"},
|
18
|
+
];
|
19
|
+
|
20
|
+
const meta: Meta<typeof DrawerComponent> = {
|
21
|
+
title: "Components/Drawer",
|
22
|
+
component: DrawerComponent,
|
23
|
+
tags: ["autodocs"],
|
24
|
+
argTypes: {
|
25
|
+
side: {
|
26
|
+
options: sides,
|
27
|
+
control: {type: "select"},
|
28
|
+
},
|
29
|
+
modal: {
|
30
|
+
description:
|
31
|
+
"The modality of the dialog. When set to true, interaction with outside elements will be disabled and only dialog content will be visible to screen readers.",
|
32
|
+
control: {type: "boolean"},
|
33
|
+
type: "boolean",
|
34
|
+
},
|
35
|
+
speed: {
|
36
|
+
type: "number",
|
37
|
+
},
|
38
|
+
className: hideInTable,
|
39
|
+
description: hideInTable,
|
40
|
+
overlayClassName: hideInTable,
|
41
|
+
childrenClassName: hideInTable,
|
42
|
+
},
|
43
|
+
};
|
44
|
+
|
45
|
+
export default meta;
|
46
|
+
|
47
|
+
export const Drawer = (props: DrawerProps & {label?: string}) => {
|
48
|
+
const [open, setOpen] = useState(false);
|
49
|
+
const {label = "Open Drawer", ...other} = props;
|
50
|
+
return (
|
51
|
+
<div>
|
52
|
+
<Button onClick={() => setOpen(true)}>{label}</Button>
|
53
|
+
<DrawerComponent open={open} onOpenChange={setOpen} {...other}>
|
54
|
+
<div
|
55
|
+
style={{
|
56
|
+
boxSizing: "border-box",
|
57
|
+
display: "flex",
|
58
|
+
flexDirection: "column",
|
59
|
+
justifyContent: "space-between",
|
60
|
+
height: "100%",
|
61
|
+
gap: "30px",
|
62
|
+
padding: "20px",
|
63
|
+
}}
|
64
|
+
>
|
65
|
+
<List style={{display: "flex", flexDirection: "column", gap: "15px", overflow: "auto"}}>
|
66
|
+
{items.map(({icon, title}) => (
|
67
|
+
<ListItem left={icon} primary={title} />
|
68
|
+
))}
|
69
|
+
</List>
|
70
|
+
<Button onClick={() => setOpen(false)} style={{width: "auto"}}>
|
71
|
+
Close
|
72
|
+
</Button>
|
73
|
+
</div>
|
74
|
+
</DrawerComponent>
|
75
|
+
</div>
|
76
|
+
);
|
77
|
+
};
|
78
|
+
|
79
|
+
export const Side = () => {
|
80
|
+
return (
|
81
|
+
<div className="grid-wrapper" style={{gridTemplateColumns: "repeat(4, auto)"}}>
|
82
|
+
{sides.map(side => (
|
83
|
+
<div key={side} className="item-card">
|
84
|
+
<Drawer side={side} label={`${capitalizeFirstLetter(side)} side`} />
|
85
|
+
</div>
|
86
|
+
))}
|
87
|
+
</div>
|
88
|
+
);
|
89
|
+
};
|
@@ -0,0 +1,57 @@
|
|
1
|
+
import React, {FC, memo} from "react";
|
2
|
+
import classnames from "classnames";
|
3
|
+
|
4
|
+
import {useComponentProps} from "../../providers";
|
5
|
+
import {cloneOrCreateElement} from "../../utils";
|
6
|
+
|
7
|
+
import {Dialog, DialogProps, dialogPropsKeys} from "../Dialog";
|
8
|
+
|
9
|
+
import styles from "./drawer.module.scss";
|
10
|
+
|
11
|
+
export enum DrawerSide {
|
12
|
+
Left = "left",
|
13
|
+
Right = "right",
|
14
|
+
Top = "top",
|
15
|
+
Bottom = "bottom",
|
16
|
+
}
|
17
|
+
|
18
|
+
export interface DrawerProps extends DialogProps {
|
19
|
+
side?: DrawerSide;
|
20
|
+
}
|
21
|
+
|
22
|
+
export const drawerPropsKeys = new Set<keyof DrawerProps>(["side", ...dialogPropsKeys]);
|
23
|
+
|
24
|
+
const Drawer: FC<DrawerProps> = props => {
|
25
|
+
const {
|
26
|
+
side = DrawerSide.Left,
|
27
|
+
fullscreen,
|
28
|
+
children,
|
29
|
+
className,
|
30
|
+
overlayClassName,
|
31
|
+
childrenClassName,
|
32
|
+
...other
|
33
|
+
} = {...useComponentProps("drawer"), ...props};
|
34
|
+
|
35
|
+
return (
|
36
|
+
<Dialog
|
37
|
+
{...other}
|
38
|
+
overlayClassName={classnames(styles["drawer-overlay"], overlayClassName)}
|
39
|
+
className={classnames(
|
40
|
+
styles["drawer-content"],
|
41
|
+
{
|
42
|
+
[styles["drawer-content--fullscreen"]]: fullscreen,
|
43
|
+
[styles[`drawer-content--${side}-side`]]: side,
|
44
|
+
},
|
45
|
+
className
|
46
|
+
)}
|
47
|
+
>
|
48
|
+
{cloneOrCreateElement(
|
49
|
+
children,
|
50
|
+
{className: classnames(styles["drawer-children"], childrenClassName)},
|
51
|
+
"div"
|
52
|
+
)}
|
53
|
+
</Dialog>
|
54
|
+
);
|
55
|
+
};
|
56
|
+
|
57
|
+
export default memo(Drawer);
|
@@ -0,0 +1,170 @@
|
|
1
|
+
$root: drawer;
|
2
|
+
|
3
|
+
.#{$root} {
|
4
|
+
&-overlay {
|
5
|
+
background-color: var(--drawer-overlay-bg-color, var(--dialog-overlay-bg-color, #111));
|
6
|
+
}
|
7
|
+
|
8
|
+
&-content {
|
9
|
+
padding: var(--drawer-padding, 0);
|
10
|
+
box-shadow: var(--drawer-box-shadow, 0 0 4px rgba(0, 0, 0, 0.5));
|
11
|
+
background-color: var(--drawer-bg-color, var(--bg-secondary-color));
|
12
|
+
|
13
|
+
&[data-state="open"] {
|
14
|
+
&.#{$root}-content--left-side {
|
15
|
+
animation-name: slideInLeft;
|
16
|
+
}
|
17
|
+
|
18
|
+
&.#{$root}-content--right-side {
|
19
|
+
animation-name: slideInRight;
|
20
|
+
}
|
21
|
+
|
22
|
+
&.#{$root}-content--top-side {
|
23
|
+
animation-name: slideInTop;
|
24
|
+
}
|
25
|
+
|
26
|
+
&.#{$root}-content--bottom-side {
|
27
|
+
animation-name: slideInBottom;
|
28
|
+
}
|
29
|
+
}
|
30
|
+
|
31
|
+
&[data-state="closed"] {
|
32
|
+
&.#{$root}-content--left-side {
|
33
|
+
animation-name: slideOutLeft;
|
34
|
+
}
|
35
|
+
|
36
|
+
&.#{$root}-content--right-side {
|
37
|
+
animation-name: slideOutRight;
|
38
|
+
}
|
39
|
+
|
40
|
+
&.#{$root}-content--top-side {
|
41
|
+
animation-name: slideOutTop;
|
42
|
+
}
|
43
|
+
|
44
|
+
&.#{$root}-content--bottom-side {
|
45
|
+
animation-name: slideOutBottom;
|
46
|
+
}
|
47
|
+
}
|
48
|
+
|
49
|
+
&--left-side {
|
50
|
+
left: 0;
|
51
|
+
top: 0;
|
52
|
+
bottom: 0;
|
53
|
+
width: var(--drawer-width, 90vw);
|
54
|
+
|
55
|
+
&.#{$root}-content--fullscreen {
|
56
|
+
width: 100%;
|
57
|
+
}
|
58
|
+
}
|
59
|
+
|
60
|
+
&--right-side {
|
61
|
+
right: 0;
|
62
|
+
top: 0;
|
63
|
+
bottom: 0;
|
64
|
+
width: var(--drawer-width, 90vw);
|
65
|
+
|
66
|
+
&.#{$root}-content--fullscreen {
|
67
|
+
width: 100%;
|
68
|
+
}
|
69
|
+
}
|
70
|
+
|
71
|
+
&--top-side {
|
72
|
+
top: 0;
|
73
|
+
left: 0;
|
74
|
+
right: 0;
|
75
|
+
height: var(--drawer-height, 90vh);
|
76
|
+
|
77
|
+
&.#{$root}-content--fullscreen {
|
78
|
+
height: 100%;
|
79
|
+
}
|
80
|
+
}
|
81
|
+
|
82
|
+
&--bottom-side {
|
83
|
+
bottom: 0;
|
84
|
+
left: 0;
|
85
|
+
right: 0;
|
86
|
+
height: var(--drawer-height, 90vh);
|
87
|
+
|
88
|
+
&.#{$root}-content--fullscreen {
|
89
|
+
height: 100%;
|
90
|
+
}
|
91
|
+
}
|
92
|
+
}
|
93
|
+
|
94
|
+
&-children {
|
95
|
+
display: flex;
|
96
|
+
flex-direction: column;
|
97
|
+
}
|
98
|
+
}
|
99
|
+
|
100
|
+
@keyframes slideInRight {
|
101
|
+
from {
|
102
|
+
transform: translateX(100%);
|
103
|
+
}
|
104
|
+
to {
|
105
|
+
transform: translateX(0);
|
106
|
+
}
|
107
|
+
}
|
108
|
+
|
109
|
+
@keyframes slideInLeft {
|
110
|
+
from {
|
111
|
+
transform: translateX(-100%);
|
112
|
+
}
|
113
|
+
to {
|
114
|
+
transform: translateX(0);
|
115
|
+
}
|
116
|
+
}
|
117
|
+
|
118
|
+
@keyframes slideInTop {
|
119
|
+
from {
|
120
|
+
transform: translateY(-100%);
|
121
|
+
}
|
122
|
+
to {
|
123
|
+
transform: translateY(0);
|
124
|
+
}
|
125
|
+
}
|
126
|
+
|
127
|
+
@keyframes slideInBottom {
|
128
|
+
from {
|
129
|
+
transform: translateY(100%);
|
130
|
+
}
|
131
|
+
to {
|
132
|
+
transform: translateY(0);
|
133
|
+
}
|
134
|
+
}
|
135
|
+
|
136
|
+
@keyframes slideOutRight {
|
137
|
+
from {
|
138
|
+
transform: translateX(0);
|
139
|
+
}
|
140
|
+
to {
|
141
|
+
transform: translateX(100%);
|
142
|
+
}
|
143
|
+
}
|
144
|
+
|
145
|
+
@keyframes slideOutLeft {
|
146
|
+
from {
|
147
|
+
transform: translateX(0);
|
148
|
+
}
|
149
|
+
to {
|
150
|
+
transform: translateX(-100%);
|
151
|
+
}
|
152
|
+
}
|
153
|
+
|
154
|
+
@keyframes slideOutTop {
|
155
|
+
from {
|
156
|
+
transform: translateY(0);
|
157
|
+
}
|
158
|
+
to {
|
159
|
+
transform: translateY(-100%);
|
160
|
+
}
|
161
|
+
}
|
162
|
+
|
163
|
+
@keyframes slideOutBottom {
|
164
|
+
from {
|
165
|
+
transform: translateY(0);
|
166
|
+
}
|
167
|
+
to {
|
168
|
+
transform: translateY(100%);
|
169
|
+
}
|
170
|
+
}
|
@@ -0,0 +1,118 @@
|
|
1
|
+
import {Meta, StoryObj} from "@storybook/react";
|
2
|
+
|
3
|
+
import {hideInTable} from "../../utils";
|
4
|
+
|
5
|
+
import {IconButton, IconButtonSize, IconButtonVariant} from "../index";
|
6
|
+
|
7
|
+
import FooterComponent from "./Footer";
|
8
|
+
|
9
|
+
const meta: Meta<typeof FooterComponent> = {
|
10
|
+
title: "Components/Footer",
|
11
|
+
component: FooterComponent,
|
12
|
+
tags: ["autodocs"],
|
13
|
+
argTypes: {
|
14
|
+
left: hideInTable,
|
15
|
+
right: hideInTable,
|
16
|
+
style: hideInTable,
|
17
|
+
children: hideInTable,
|
18
|
+
className: hideInTable,
|
19
|
+
leftClassName: hideInTable,
|
20
|
+
rightClassName: hideInTable,
|
21
|
+
childrenClassName: hideInTable,
|
22
|
+
},
|
23
|
+
decorators: [
|
24
|
+
Story => (
|
25
|
+
<div
|
26
|
+
style={{
|
27
|
+
display: "flex",
|
28
|
+
flexDirection: "column",
|
29
|
+
background: "var(--bg-secondary-color",
|
30
|
+
width: "380px",
|
31
|
+
height: "300px",
|
32
|
+
borderRadius: "10px",
|
33
|
+
}}
|
34
|
+
>
|
35
|
+
<span style={{flexGrow: 1}} />
|
36
|
+
<Story />
|
37
|
+
</div>
|
38
|
+
),
|
39
|
+
],
|
40
|
+
};
|
41
|
+
|
42
|
+
export default meta;
|
43
|
+
|
44
|
+
export const Footer: StoryObj<typeof FooterComponent> = {
|
45
|
+
args: {
|
46
|
+
shadow: true,
|
47
|
+
reverse: false,
|
48
|
+
style: {paddingTop: "20px"},
|
49
|
+
children: (
|
50
|
+
<div>
|
51
|
+
<div style={{display: "flex", gap: "20px"}}>
|
52
|
+
<IconButton style={{fontSize: "20px"}} tooltip={{content: "Change theme"}}>
|
53
|
+
🌓
|
54
|
+
</IconButton>
|
55
|
+
<IconButton style={{fontSize: "20px"}} tooltip={{content: "Rate Us"}}>
|
56
|
+
❤️
|
57
|
+
</IconButton>
|
58
|
+
</div>
|
59
|
+
<div style={{display: "flex", gap: "20px"}}>
|
60
|
+
<IconButton style={{fontSize: "20px"}} tooltip={{content: "Support Us"}}>
|
61
|
+
💲
|
62
|
+
</IconButton>
|
63
|
+
<IconButton style={{fontSize: "20px"}} tooltip={{content: "FAQ"}}>
|
64
|
+
❓
|
65
|
+
</IconButton>
|
66
|
+
</div>
|
67
|
+
</div>
|
68
|
+
),
|
69
|
+
},
|
70
|
+
};
|
71
|
+
|
72
|
+
export const FooterWithoutChildren: StoryObj<typeof FooterComponent> = {
|
73
|
+
args: {
|
74
|
+
shadow: true,
|
75
|
+
reverse: false,
|
76
|
+
style: {paddingTop: "20px"},
|
77
|
+
left: (
|
78
|
+
<div>
|
79
|
+
<IconButton
|
80
|
+
variant={IconButtonVariant.Contained}
|
81
|
+
size={IconButtonSize.Medium}
|
82
|
+
style={{fontSize: "20px"}}
|
83
|
+
tooltip={{content: "Change theme"}}
|
84
|
+
>
|
85
|
+
🌓
|
86
|
+
</IconButton>
|
87
|
+
<IconButton
|
88
|
+
variant={IconButtonVariant.Contained}
|
89
|
+
size={IconButtonSize.Medium}
|
90
|
+
style={{fontSize: "20px"}}
|
91
|
+
tooltip={{content: "Rate Us"}}
|
92
|
+
>
|
93
|
+
❤️
|
94
|
+
</IconButton>
|
95
|
+
</div>
|
96
|
+
),
|
97
|
+
right: (
|
98
|
+
<div>
|
99
|
+
<IconButton
|
100
|
+
variant={IconButtonVariant.Ghost}
|
101
|
+
size={IconButtonSize.Medium}
|
102
|
+
style={{fontSize: "20px"}}
|
103
|
+
tooltip={{content: "Support Us"}}
|
104
|
+
>
|
105
|
+
💲
|
106
|
+
</IconButton>
|
107
|
+
<IconButton
|
108
|
+
variant={IconButtonVariant.Ghost}
|
109
|
+
size={IconButtonSize.Medium}
|
110
|
+
style={{fontSize: "20px"}}
|
111
|
+
tooltip={{content: "FAQ"}}
|
112
|
+
>
|
113
|
+
❓
|
114
|
+
</IconButton>
|
115
|
+
</div>
|
116
|
+
),
|
117
|
+
},
|
118
|
+
};
|