addon-ui 0.3.0
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/README.md +1197 -0
- package/package.json +113 -0
- package/src/components/Avatar/Avatar.tsx +56 -0
- package/src/components/Avatar/avatar.module.scss +78 -0
- package/src/components/Avatar/index.ts +2 -0
- package/src/components/Avatar/types.ts +11 -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 +1 -0
- package/src/components/Button/Button.tsx +51 -0
- package/src/components/Button/button.module.scss +140 -0
- package/src/components/Button/index.ts +2 -0
- package/src/components/Button/types.ts +24 -0
- package/src/components/Checkbox/Checkbox.tsx +58 -0
- package/src/components/Checkbox/checkbox.module.scss +82 -0
- package/src/components/Checkbox/index.ts +2 -0
- package/src/components/Checkbox/types.ts +15 -0
- package/src/components/Dialog/Dialog.tsx +126 -0
- package/src/components/Dialog/dialog.module.scss +55 -0
- package/src/components/Dialog/index.ts +1 -0
- package/src/components/Drawer/Drawer.tsx +53 -0
- package/src/components/Drawer/drawer.module.scss +170 -0
- package/src/components/Drawer/index.ts +2 -0
- package/src/components/Drawer/types.ts +6 -0
- package/src/components/Footer/Footer.tsx +59 -0
- package/src/components/Footer/footer.module.scss +45 -0
- package/src/components/Footer/index.ts +1 -0
- package/src/components/Header/Header.tsx +74 -0
- package/src/components/Header/header.module.scss +56 -0
- package/src/components/Header/index.ts +1 -0
- package/src/components/Highlight/Highlight.tsx +36 -0
- package/src/components/Highlight/highlight.module.scss +48 -0
- package/src/components/Highlight/index.ts +2 -0
- package/src/components/Highlight/types.ts +5 -0
- package/src/components/Icon/Icon.tsx +46 -0
- package/src/components/Icon/icon.module.scss +17 -0
- package/src/components/Icon/index.ts +1 -0
- package/src/components/IconButton/IconButton.tsx +50 -0
- package/src/components/IconButton/icon-button.module.scss +86 -0
- package/src/components/IconButton/index.ts +2 -0
- package/src/components/IconButton/types.ts +17 -0
- package/src/components/Layout/Provider.tsx +60 -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.tsx +24 -0
- package/src/components/List/index.ts +1 -0
- package/src/components/List/list.module.scss +8 -0
- package/src/components/ListItem/ListItem.tsx +75 -0
- package/src/components/ListItem/index.ts +1 -0
- package/src/components/ListItem/list-item.module.scss +37 -0
- package/src/components/Modal/Modal.tsx +90 -0
- package/src/components/Modal/index.ts +2 -0
- package/src/components/Modal/modal.module.scss +97 -0
- package/src/components/Modal/types.ts +6 -0
- package/src/components/Odometer/Odometer.tsx +45 -0
- package/src/components/Odometer/hooks/useOdometer.tsx +24 -0
- package/src/components/Odometer/index.ts +2 -0
- package/src/components/Odometer/odometer.module.scss +81 -0
- package/src/components/Odometer/odometr.d.ts +9 -0
- package/src/components/ScrollArea/ScrollArea.tsx +75 -0
- package/src/components/ScrollArea/index.ts +1 -0
- package/src/components/ScrollArea/scroll-area.module.scss +58 -0
- package/src/components/SvgSprite/SvgSprite.tsx +21 -0
- package/src/components/SvgSprite/index.ts +1 -0
- package/src/components/Switch/Switch.tsx +24 -0
- package/src/components/Switch/index.ts +1 -0
- package/src/components/Switch/switch.module.scss +65 -0
- package/src/components/Tag/Tag.tsx +50 -0
- package/src/components/Tag/index.ts +2 -0
- package/src/components/Tag/tag.module.scss +118 -0
- package/src/components/Tag/types.ts +23 -0
- package/src/components/TextArea/TextArea.tsx +126 -0
- package/src/components/TextArea/index.ts +2 -0
- package/src/components/TextArea/text-area.module.scss +88 -0
- package/src/components/TextArea/types.ts +18 -0
- package/src/components/TextField/TextField.tsx +139 -0
- package/src/components/TextField/index.ts +2 -0
- package/src/components/TextField/text-field.module.scss +129 -0
- package/src/components/TextField/types.ts +24 -0
- package/src/components/Toast/Toast.tsx +124 -0
- package/src/components/Toast/index.ts +2 -0
- package/src/components/Toast/toast.module.scss +267 -0
- package/src/components/Toast/types.ts +20 -0
- package/src/components/Tooltip/Tooltip.tsx +82 -0
- package/src/components/Tooltip/index.ts +1 -0
- package/src/components/Tooltip/tooltip.module.scss +123 -0
- package/src/components/View/View.tsx +68 -0
- package/src/components/View/index.ts +1 -0
- package/src/components/View/view.module.scss +38 -0
- package/src/components/ViewDrawer/ViewDrawer.tsx +24 -0
- package/src/components/ViewDrawer/index.ts +1 -0
- package/src/components/ViewModal/ViewModal.tsx +24 -0
- package/src/components/ViewModal/index.ts +1 -0
- package/src/components/index.ts +27 -0
- package/src/components/types.ts +65 -0
- package/src/config/default.ts +3 -0
- package/src/config/index.ts +8 -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 +35 -0
- package/src/plugin/builder/virtual.config.ts +5 -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 +73 -0
- package/src/plugin/types.ts +8 -0
- package/src/providers/extra/ExtraProvider.tsx +13 -0
- package/src/providers/extra/context.ts +14 -0
- package/src/providers/extra/index.ts +2 -0
- package/src/providers/icons/IconsProvider.tsx +35 -0
- package/src/providers/icons/context.ts +20 -0
- package/src/providers/icons/index.ts +2 -0
- package/src/providers/index.ts +4 -0
- package/src/providers/theme/ThemeProvider.tsx +60 -0
- package/src/providers/theme/ThemeStorage.tsx +36 -0
- package/src/providers/theme/context.ts +30 -0
- package/src/providers/theme/index.ts +3 -0
- package/src/providers/ui/UIProvider.tsx +41 -0
- package/src/providers/ui/index.ts +1 -0
- package/src/providers/ui/styles/default.scss +95 -0
- package/src/providers/ui/styles/reset.scss +127 -0
- package/src/styles/mixins.scss +23 -0
- package/src/types/config.ts +15 -0
- package/src/types/theme.ts +11 -0
- package/src/utils/index.ts +2 -0
- package/src/utils/react.ts +21 -0
- package/src/utils/utils.ts +12 -0
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
@use "../../styles/mixins" as dir;
|
|
2
|
+
|
|
3
|
+
$root: modal;
|
|
4
|
+
|
|
5
|
+
.#{$root} {
|
|
6
|
+
&-overlay {
|
|
7
|
+
background-color: var(--modal-overlay-bg-color, var(--dialog-overlay-bg-color, #111));
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
&-content {
|
|
11
|
+
top: 50%;
|
|
12
|
+
left: 50%;
|
|
13
|
+
transform: translate(-50%, -50%);
|
|
14
|
+
width: var(--modal-width, 90vw);
|
|
15
|
+
max-width: var(--modal-max-width, 350px);
|
|
16
|
+
max-height: var(--modal-max-height, 85vh);
|
|
17
|
+
padding: var(--modal-padding, 0);
|
|
18
|
+
border-radius: var(--modal-border-radius, 10px);
|
|
19
|
+
box-shadow: var(--modal-box-shadow, 0 0 4px rgba(0, 0, 0, 0.5));
|
|
20
|
+
background-color: var(--modal-bg-color, var(--bg-primary-color));
|
|
21
|
+
transition:
|
|
22
|
+
background-color var(--transition-speed-sm),
|
|
23
|
+
color var(--transition-speed-sm);
|
|
24
|
+
|
|
25
|
+
&[data-state="open"] {
|
|
26
|
+
animation-name: contentShow;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
&[data-state="closed"] {
|
|
30
|
+
animation-name: contentHide;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
&--fullscreen {
|
|
34
|
+
max-width: 100%;
|
|
35
|
+
max-height: 100%;
|
|
36
|
+
width: 100%;
|
|
37
|
+
height: 100%;
|
|
38
|
+
border-radius: 0 !important;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
&--none-radius {
|
|
42
|
+
border-radius: 0;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
&--small-radius {
|
|
46
|
+
border-radius: var(--modal-border-radius-sm, 5px);
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
&--medium-radius {
|
|
50
|
+
border-radius: var(--modal-border-radius-sm, 15px);
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
&--large-radius {
|
|
54
|
+
border-radius: var(--modal-border-radius-sm, 20px);
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
&-children {
|
|
59
|
+
display: flex;
|
|
60
|
+
flex-direction: column;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
&-close {
|
|
64
|
+
position: absolute !important;
|
|
65
|
+
top: var(--modal-close-offset, 5px);
|
|
66
|
+
|
|
67
|
+
@include dir.ltr {
|
|
68
|
+
right: var(--modal-close-offset, 5px);
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
@include dir.rtl {
|
|
72
|
+
left: var(--modal-close-offset, 5px);
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
@keyframes contentShow {
|
|
78
|
+
from {
|
|
79
|
+
opacity: 0;
|
|
80
|
+
transform: translate(-50%, -48%) scale(var(--modal-animation-content-scale, 0.96));
|
|
81
|
+
}
|
|
82
|
+
to {
|
|
83
|
+
opacity: 1;
|
|
84
|
+
transform: translate(-50%, -50%) scale(1);
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
@keyframes contentHide {
|
|
89
|
+
from {
|
|
90
|
+
opacity: 1;
|
|
91
|
+
transform: translate(-50%, -50%) scale(1);
|
|
92
|
+
}
|
|
93
|
+
to {
|
|
94
|
+
opacity: 0;
|
|
95
|
+
transform: translate(-50%, -48%) scale(var(--modal-animation-content-scale, 0.96));
|
|
96
|
+
}
|
|
97
|
+
}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import React, {FC, memo, useRef} from "react";
|
|
2
|
+
|
|
3
|
+
import classNames from "classnames";
|
|
4
|
+
|
|
5
|
+
import {useComponentProps} from "../../providers";
|
|
6
|
+
|
|
7
|
+
import useOdometer, {OdometerOptions} from "./hooks/useOdometer";
|
|
8
|
+
|
|
9
|
+
import styles from "./odometer.module.scss";
|
|
10
|
+
|
|
11
|
+
export interface OdometerProps extends OdometerOptions {
|
|
12
|
+
value: number;
|
|
13
|
+
className?: string;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
const Odometer: FC<OdometerProps> = props => {
|
|
17
|
+
const {
|
|
18
|
+
value,
|
|
19
|
+
auto = false,
|
|
20
|
+
format = "d",
|
|
21
|
+
duration = 250,
|
|
22
|
+
className,
|
|
23
|
+
...other
|
|
24
|
+
} = {...useComponentProps("odometer"), ...props};
|
|
25
|
+
|
|
26
|
+
const targetRef = useRef(null);
|
|
27
|
+
|
|
28
|
+
useOdometer(targetRef, value, {
|
|
29
|
+
...other,
|
|
30
|
+
auto,
|
|
31
|
+
format,
|
|
32
|
+
duration,
|
|
33
|
+
});
|
|
34
|
+
|
|
35
|
+
return (
|
|
36
|
+
<span
|
|
37
|
+
ref={targetRef}
|
|
38
|
+
dir="ltr"
|
|
39
|
+
style={{"--speed": `${duration}ms`} as React.CSSProperties}
|
|
40
|
+
className={classNames(styles["odometer"], className)}
|
|
41
|
+
/>
|
|
42
|
+
);
|
|
43
|
+
};
|
|
44
|
+
|
|
45
|
+
export default memo(Odometer);
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import {RefObject, useEffect, useRef} from "react";
|
|
2
|
+
import Odometer from "odometer";
|
|
3
|
+
|
|
4
|
+
export interface OdometerOptions {
|
|
5
|
+
auto?: boolean;
|
|
6
|
+
format?: string;
|
|
7
|
+
duration?: number;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
export default (ref: RefObject<HTMLElement | null>, value: number, options: OdometerOptions = {}) => {
|
|
11
|
+
const od = useRef<Odometer | null>(null);
|
|
12
|
+
|
|
13
|
+
useEffect(() => {
|
|
14
|
+
if (ref.current === null) return;
|
|
15
|
+
|
|
16
|
+
od.current = new Odometer({...options, el: ref.current, value});
|
|
17
|
+
}, [ref, options, value]);
|
|
18
|
+
|
|
19
|
+
useEffect(() => {
|
|
20
|
+
od.current?.update(value);
|
|
21
|
+
}, [value]);
|
|
22
|
+
|
|
23
|
+
return od.current;
|
|
24
|
+
};
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
$root: odometer;
|
|
2
|
+
|
|
3
|
+
.#{$root} {
|
|
4
|
+
display: inline-block;
|
|
5
|
+
position: relative;
|
|
6
|
+
color: var(--odometer-color, var(--text-primary-color));
|
|
7
|
+
font-family: var(--odometer-font-family, var(--font-family)), sans-serif;
|
|
8
|
+
|
|
9
|
+
&-digit {
|
|
10
|
+
display: inline-block;
|
|
11
|
+
position: relative;
|
|
12
|
+
|
|
13
|
+
&-spacer {
|
|
14
|
+
display: inline-block;
|
|
15
|
+
visibility: hidden;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
&-inner {
|
|
19
|
+
text-align: left;
|
|
20
|
+
display: block;
|
|
21
|
+
position: absolute;
|
|
22
|
+
top: 0;
|
|
23
|
+
left: 0;
|
|
24
|
+
right: 0;
|
|
25
|
+
bottom: 0;
|
|
26
|
+
overflow: hidden;
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
&-ribbon {
|
|
31
|
+
display: block;
|
|
32
|
+
|
|
33
|
+
&-inner {
|
|
34
|
+
display: block;
|
|
35
|
+
-webkit-backface-visibility: hidden;
|
|
36
|
+
|
|
37
|
+
.#{$root}-animating-up & {
|
|
38
|
+
transition: transform var(--speed);
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
.#{$root}-animating-up.#{$root}-animating & {
|
|
42
|
+
transform: translateY(-100%);
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
.#{$root}-animating-down & {
|
|
46
|
+
transform: translateY(-100%);
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
.#{$root}-animating-down.#{$root}-animating & {
|
|
50
|
+
transition: transform var(--speed);
|
|
51
|
+
transform: translateY(0);
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
&-value {
|
|
57
|
+
display: block;
|
|
58
|
+
text-align: center;
|
|
59
|
+
transform: translateZ(0);
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
&-last-value {
|
|
63
|
+
position: absolute;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
&-inside {
|
|
67
|
+
transition:
|
|
68
|
+
all var(--speed),
|
|
69
|
+
color var(--transition-speed-sm);
|
|
70
|
+
|
|
71
|
+
&:before {
|
|
72
|
+
content: "";
|
|
73
|
+
width: 0;
|
|
74
|
+
display: inline-block;
|
|
75
|
+
color: inherit;
|
|
76
|
+
transition:
|
|
77
|
+
all var(--speed),
|
|
78
|
+
color var(--transition-speed-sm);
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
}
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
import React, {forwardRef, ForwardRefRenderFunction, memo} from "react";
|
|
2
|
+
import classnames from "classnames";
|
|
3
|
+
import {
|
|
4
|
+
Corner,
|
|
5
|
+
Root,
|
|
6
|
+
ScrollAreaProps as ScrollAreaRootProps,
|
|
7
|
+
Scrollbar,
|
|
8
|
+
Thumb,
|
|
9
|
+
Viewport,
|
|
10
|
+
} from "@radix-ui/react-scroll-area";
|
|
11
|
+
|
|
12
|
+
import {useComponentProps} from "../../providers";
|
|
13
|
+
|
|
14
|
+
import styles from "./scroll-area.module.scss";
|
|
15
|
+
|
|
16
|
+
export interface ScrollAreaProps extends ScrollAreaRootProps {
|
|
17
|
+
xOffset?: number;
|
|
18
|
+
yOffset?: number;
|
|
19
|
+
horizontalScroll?: boolean;
|
|
20
|
+
thumbClassName?: string;
|
|
21
|
+
cornerClassName?: string;
|
|
22
|
+
viewportClassName?: string;
|
|
23
|
+
scrollbarClassName?: string;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
const ScrollArea: ForwardRefRenderFunction<HTMLDivElement, ScrollAreaProps> = (props, ref) => {
|
|
27
|
+
const {
|
|
28
|
+
xOffset,
|
|
29
|
+
yOffset,
|
|
30
|
+
children,
|
|
31
|
+
className,
|
|
32
|
+
horizontalScroll,
|
|
33
|
+
thumbClassName,
|
|
34
|
+
cornerClassName,
|
|
35
|
+
viewportClassName,
|
|
36
|
+
scrollbarClassName,
|
|
37
|
+
...other
|
|
38
|
+
} = {...useComponentProps("scrollArea"), ...props};
|
|
39
|
+
|
|
40
|
+
return (
|
|
41
|
+
<Root ref={ref} className={classnames(styles["scroll-area"], className)} {...other}>
|
|
42
|
+
<Viewport
|
|
43
|
+
className={classnames(
|
|
44
|
+
styles["scroll-area__viewport"],
|
|
45
|
+
{
|
|
46
|
+
[styles["scroll-area__viewport--horizontal"]]: !horizontalScroll,
|
|
47
|
+
},
|
|
48
|
+
viewportClassName
|
|
49
|
+
)}
|
|
50
|
+
>
|
|
51
|
+
{children}
|
|
52
|
+
</Viewport>
|
|
53
|
+
|
|
54
|
+
<Scrollbar
|
|
55
|
+
orientation="vertical"
|
|
56
|
+
style={{padding: `0 ${xOffset}px`}}
|
|
57
|
+
className={classnames(styles["scroll-area__scrollbar"], scrollbarClassName)}
|
|
58
|
+
>
|
|
59
|
+
<Thumb className={classnames(styles["scroll-area__thumb"], thumbClassName)} />
|
|
60
|
+
</Scrollbar>
|
|
61
|
+
|
|
62
|
+
<Scrollbar
|
|
63
|
+
orientation="horizontal"
|
|
64
|
+
style={{padding: `${yOffset}px 0`}}
|
|
65
|
+
className={classnames(styles["scroll-area__scrollbar"], scrollbarClassName)}
|
|
66
|
+
>
|
|
67
|
+
<Thumb className={classnames(styles["scroll-area__thumb"], thumbClassName)} />
|
|
68
|
+
</Scrollbar>
|
|
69
|
+
|
|
70
|
+
<Corner className={classnames(styles["scroll-area__corner"], cornerClassName)} />
|
|
71
|
+
</Root>
|
|
72
|
+
);
|
|
73
|
+
};
|
|
74
|
+
|
|
75
|
+
export default memo(forwardRef(ScrollArea));
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {default as ScrollArea, type ScrollAreaProps} from "./ScrollArea";
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
$root: scroll-area;
|
|
2
|
+
|
|
3
|
+
.#{$root} {
|
|
4
|
+
box-sizing: border-box;
|
|
5
|
+
overflow: hidden;
|
|
6
|
+
|
|
7
|
+
&__viewport {
|
|
8
|
+
width: 100%;
|
|
9
|
+
height: 100%;
|
|
10
|
+
|
|
11
|
+
&--horizontal > div {
|
|
12
|
+
display: inherit !important;
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
&__scrollbar {
|
|
17
|
+
display: flex;
|
|
18
|
+
user-select: none;
|
|
19
|
+
touch-action: none;
|
|
20
|
+
padding: var(--scroll-area-scrollbar-padding, 3px);
|
|
21
|
+
background: var(--scroll-area-scrollbar-bg-color, transparent);
|
|
22
|
+
transition: background var(--transition-speed-sm) ease-in-out;
|
|
23
|
+
|
|
24
|
+
&:hover {
|
|
25
|
+
background: var(--scroll-area-scrollbar-bg-color-hover, transparent);
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
&[data-orientation="vertical"] {
|
|
29
|
+
width: var(--scroll-area-scrollbar-size, 9px);
|
|
30
|
+
padding: 0 var(--scroll-area-scrollbar-offset, var(--scroll-area-scrollbar-x-offset, 2px));
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
&[data-orientation="horizontal"] {
|
|
34
|
+
flex-direction: column;
|
|
35
|
+
height: var(--scroll-area-scrollbar-size, 9px);
|
|
36
|
+
padding: var(--scroll-area-scrollbar-offset, var(--scroll-area-scrollbar-y-offset, 2px)) 0;
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
&__thumb {
|
|
41
|
+
flex: 1;
|
|
42
|
+
position: relative;
|
|
43
|
+
background: var(--scroll-area-thumb-bg-color);
|
|
44
|
+
border-radius: var(--scroll-area-thumb-border-radius, 100px);
|
|
45
|
+
|
|
46
|
+
&:hover {
|
|
47
|
+
background: var(--scroll-area-thumb-bg-color-hover, var(--scroll-area-thumb-bg-color));
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
&__corner {
|
|
52
|
+
background: var(--scroll-area-scrollbar-bg-color, transparent);
|
|
53
|
+
|
|
54
|
+
&:hover {
|
|
55
|
+
background: var(--scroll-area-scrollbar-bg-color-hover, transparent);
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import React, {ComponentProps, FC, memo} from "react";
|
|
2
|
+
|
|
3
|
+
export interface SvgSpriteProps {
|
|
4
|
+
icons: Record<string, FC<ComponentProps<"svg">>>;
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
const SvgSprite: FC<SvgSpriteProps> = ({icons}) => {
|
|
8
|
+
return (
|
|
9
|
+
<svg style={{display: "none"}} aria-hidden="true">
|
|
10
|
+
<defs>
|
|
11
|
+
{Object.entries(icons).map(([name, Icon]) => (
|
|
12
|
+
<symbol id={name} key={name} viewBox="0 0 24 24">
|
|
13
|
+
<Icon />
|
|
14
|
+
</symbol>
|
|
15
|
+
))}
|
|
16
|
+
</defs>
|
|
17
|
+
</svg>
|
|
18
|
+
);
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
export default memo(SvgSprite);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {default as SvgSprite, type SvgSpriteProps} from "./SvgSprite";
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import React, {memo, forwardRef, ForwardRefRenderFunction} from "react";
|
|
2
|
+
import classnames from "classnames";
|
|
3
|
+
import {Root, SwitchProps as SwitchRootProps, Thumb} from "@radix-ui/react-switch";
|
|
4
|
+
|
|
5
|
+
import {useComponentProps} from "../../providers";
|
|
6
|
+
|
|
7
|
+
import styles from "./switch.module.scss";
|
|
8
|
+
|
|
9
|
+
export interface SwitchProps extends SwitchRootProps {
|
|
10
|
+
thumbClassName?: string;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
const Switch: ForwardRefRenderFunction<HTMLButtonElement, SwitchProps> = (props, ref) => {
|
|
14
|
+
const {className, thumbClassName, children, ...other} = {...useComponentProps("switch"), ...props};
|
|
15
|
+
|
|
16
|
+
return (
|
|
17
|
+
<Root ref={ref} {...other} className={classnames(styles["switch"], className)}>
|
|
18
|
+
<Thumb className={classnames(styles["switch__thumb"], thumbClassName)} />
|
|
19
|
+
{children}
|
|
20
|
+
</Root>
|
|
21
|
+
);
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
export default memo(forwardRef(Switch));
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {default as Switch, type SwitchProps} from "./Switch";
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
@use "../../styles/mixins" as dir;
|
|
2
|
+
|
|
3
|
+
@function switch-width() {
|
|
4
|
+
@return var(--switch-width, 36px);
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
@function switch-height() {
|
|
8
|
+
@return var(--switch-height, 22px);
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
@function switch-thumb-width() {
|
|
12
|
+
@return var(--switch-thumb-width, 18px);
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
@function switch-thumb-height() {
|
|
16
|
+
@return var(--switch-thumb-height, 18px);
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
$root: switch;
|
|
20
|
+
|
|
21
|
+
.#{$root} {
|
|
22
|
+
margin: 0;
|
|
23
|
+
padding: 0;
|
|
24
|
+
border: none;
|
|
25
|
+
box-sizing: border-box;
|
|
26
|
+
cursor: pointer;
|
|
27
|
+
position: relative;
|
|
28
|
+
width: switch-width();
|
|
29
|
+
height: switch-height();
|
|
30
|
+
border-radius: var(--switch-border-radius, 9999px);
|
|
31
|
+
background: var(--switch-bg-color, #bbb);
|
|
32
|
+
will-change: background;
|
|
33
|
+
transition: background var(--transition-speed-sm);
|
|
34
|
+
|
|
35
|
+
&[data-state="checked"] {
|
|
36
|
+
background-color: var(--switch-cheked-bg-color, var(--primary-color));
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
&:disabled {
|
|
40
|
+
opacity: var(--switch-disabled-opacity, 0.6);
|
|
41
|
+
cursor: default;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
&__thumb {
|
|
45
|
+
box-sizing: border-box;
|
|
46
|
+
display: block;
|
|
47
|
+
width: switch-thumb-width();
|
|
48
|
+
height: switch-thumb-height();
|
|
49
|
+
transform: translateX(calc((#{switch-height()} - #{switch-thumb-height()}) / 2));
|
|
50
|
+
background-color: var(--switch-thumb-bg-color, white);
|
|
51
|
+
border-radius: var(--switch-border-radius, 9999px);
|
|
52
|
+
will-change: transform;
|
|
53
|
+
transition: transform var(--transition-speed-sm) ease-in-out;
|
|
54
|
+
|
|
55
|
+
@include dir.rtl {
|
|
56
|
+
margin-right: calc(#{switch-width()} / 2);
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
&[data-state="checked"] {
|
|
60
|
+
transform: translateX(
|
|
61
|
+
calc(#{switch-width()} - #{switch-thumb-width()} - (#{switch-height()} - #{switch-thumb-height()}) / 2)
|
|
62
|
+
);
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import React, {ComponentProps, memo, forwardRef, ForwardRefRenderFunction} from "react";
|
|
2
|
+
import classnames from "classnames";
|
|
3
|
+
import {useComponentProps} from "../../providers";
|
|
4
|
+
|
|
5
|
+
import {TagVariant, TagColor, TagSize, TagRadius} from "./types";
|
|
6
|
+
|
|
7
|
+
import styles from "./tag.module.scss";
|
|
8
|
+
|
|
9
|
+
export interface TagProps extends ComponentProps<"span"> {
|
|
10
|
+
size?: TagSize;
|
|
11
|
+
color?: TagColor;
|
|
12
|
+
radius?: TagRadius;
|
|
13
|
+
variant?: TagVariant;
|
|
14
|
+
clickable?: boolean;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
const Tag: ForwardRefRenderFunction<HTMLSpanElement, TagProps> = (props, ref) => {
|
|
18
|
+
const {
|
|
19
|
+
size,
|
|
20
|
+
color,
|
|
21
|
+
radius,
|
|
22
|
+
variant = TagVariant.Contained,
|
|
23
|
+
clickable,
|
|
24
|
+
children,
|
|
25
|
+
className,
|
|
26
|
+
...other
|
|
27
|
+
} = {...useComponentProps("tag"), ...props};
|
|
28
|
+
|
|
29
|
+
return (
|
|
30
|
+
<span
|
|
31
|
+
ref={ref}
|
|
32
|
+
{...other}
|
|
33
|
+
className={classnames(
|
|
34
|
+
styles["tag"],
|
|
35
|
+
{
|
|
36
|
+
[styles[`tag--${variant}`]]: variant,
|
|
37
|
+
[styles[`tag--${radius}-radius`]]: radius,
|
|
38
|
+
[styles[`tag--${color}-color`]]: color,
|
|
39
|
+
[styles[`tag--${size}-size`]]: size,
|
|
40
|
+
[styles["tag--clickable"]]: clickable,
|
|
41
|
+
},
|
|
42
|
+
className
|
|
43
|
+
)}
|
|
44
|
+
>
|
|
45
|
+
{children}
|
|
46
|
+
</span>
|
|
47
|
+
);
|
|
48
|
+
};
|
|
49
|
+
|
|
50
|
+
export default memo(forwardRef(Tag));
|
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
$root: tag;
|
|
2
|
+
|
|
3
|
+
.#{$root} {
|
|
4
|
+
cursor: default;
|
|
5
|
+
display: inline-flex;
|
|
6
|
+
align-items: center;
|
|
7
|
+
justify-content: center;
|
|
8
|
+
font-size: var(--tag-font-size, 13px);
|
|
9
|
+
font-weight: var(--tag-font-weight, 500);
|
|
10
|
+
line-height: var(--tag-line-height, var(--line-height, 1 rem));
|
|
11
|
+
letter-spacing: var(--tag-letter-spacing, 0.5px);
|
|
12
|
+
padding: var(--tag-padding, 4px 8px);
|
|
13
|
+
border-radius: var(--tag-border-radius, 999px);
|
|
14
|
+
color: var(--tag-color, var(--text-secondary-color));
|
|
15
|
+
background: var(--tag-bg-color, var(--bg-secondary-color));
|
|
16
|
+
|
|
17
|
+
&--clickable {
|
|
18
|
+
cursor: pointer;
|
|
19
|
+
|
|
20
|
+
&:active {
|
|
21
|
+
transform: scale(var(--tag-scale, 0.98));
|
|
22
|
+
user-select: none;
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
// Variants
|
|
27
|
+
&--contained {
|
|
28
|
+
color: var(--tag-contained-color, var(--tag-color, var(--text-secondary-color)));
|
|
29
|
+
background: var(--tag-contained-bg-color, var(--tag-bg-color, var(--bg-secondary-color)));
|
|
30
|
+
border: none;
|
|
31
|
+
|
|
32
|
+
&.#{$root}--primary-color {
|
|
33
|
+
color: var(--tag-contained-primary-color, #fff);
|
|
34
|
+
background: var(--primary-color);
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
&.#{$root}--secondary-color {
|
|
38
|
+
color: var(--tag-contained-secondary-color, #fff);
|
|
39
|
+
background: var(--secondary-color);
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
&.#{$root}--accent-color {
|
|
43
|
+
color: var(--tag-contained-accent-color, #fff);
|
|
44
|
+
background: var(--accent-color);
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
&--outlined {
|
|
49
|
+
color: var(--tag-outlined-color, var(--tag-color, var(--text-secondary-color)));
|
|
50
|
+
border: var(--tag-border-width, 1px) solid
|
|
51
|
+
var(--tag-outlined-border-color, var(--tag-outlined-color, var(--text-secondary-color)));
|
|
52
|
+
background: none;
|
|
53
|
+
|
|
54
|
+
&.#{$root}--primary-color {
|
|
55
|
+
color: var(--primary-color);
|
|
56
|
+
border-color: var(--tag-outlined-border-primary-color, var(--primary-color));
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
&.#{$root}--secondary-color {
|
|
60
|
+
color: var(--secondary-color);
|
|
61
|
+
border-color: var(--tag-outlined-border-secondary-color, var(--secondary-color));
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
&.#{$root}--accent-color {
|
|
65
|
+
color: var(--accent-color);
|
|
66
|
+
border-color: var(--tag-outlined-border-accent-color, var(--accent-color));
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
&--soft {
|
|
71
|
+
color: var(--tag-soft-color, var(--tag-color, var(--text-secondary-color)));
|
|
72
|
+
background-color: color-mix(in srgb, white 30%, var(--tag-bg-color, var(--bg-secondary-color)));
|
|
73
|
+
|
|
74
|
+
&.#{$root}--primary-color {
|
|
75
|
+
color: var(--tag-soft-primary-color, #fff);
|
|
76
|
+
background-color: color-mix(in srgb, white 30%, var(--primary-color));
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
&.#{$root}--secondary-color {
|
|
80
|
+
color: var(--tag-soft-secondary-color, #fff);
|
|
81
|
+
background-color: color-mix(in srgb, white 30%, var(--secondary-color));
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
&.#{$root}--accent-color {
|
|
85
|
+
color: var(--tag-soft-accent-color, #fff);
|
|
86
|
+
background-color: color-mix(in srgb, white 30%, var(--accent-color));
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
// Sizes
|
|
91
|
+
&--small-size {
|
|
92
|
+
padding: var(--tag-padding, 3px 6px);
|
|
93
|
+
font-size: var(--tag-font-size-sm, 12px);
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
&--medium-size {
|
|
97
|
+
padding: var(--tag-padding, 5px 10px);
|
|
98
|
+
font-size: var(--tag-font-size-sm, 14px);
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
&--large-size {
|
|
102
|
+
padding: var(--tag-padding, 6px 12px);
|
|
103
|
+
font-size: var(--tag-font-size-sm, 16px);
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
//Radius
|
|
107
|
+
&--small-radius {
|
|
108
|
+
border-radius: var(--tag-border-radius-sm, 5px);
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
&--medium-radius {
|
|
112
|
+
border-radius: var(--tag-border-radius-md, 8px);
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
&--large-radius {
|
|
116
|
+
border-radius: var(--tag-border-radius-lg, 10px);
|
|
117
|
+
}
|
|
118
|
+
}
|