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,63 @@
|
|
1
|
+
import React, {FC, 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
|
+
thumbClassName?: string;
|
20
|
+
cornerClassName?: string;
|
21
|
+
viewportClassName?: string;
|
22
|
+
scrollbarClassName?: string;
|
23
|
+
}
|
24
|
+
|
25
|
+
const ScrollArea: FC<ScrollAreaProps> = props => {
|
26
|
+
const {
|
27
|
+
xOffset,
|
28
|
+
yOffset,
|
29
|
+
children,
|
30
|
+
className,
|
31
|
+
thumbClassName,
|
32
|
+
cornerClassName,
|
33
|
+
viewportClassName,
|
34
|
+
scrollbarClassName,
|
35
|
+
...other
|
36
|
+
} = {...useComponentProps("scrollArea"), ...props};
|
37
|
+
|
38
|
+
return (
|
39
|
+
<Root className={classnames(styles["scroll-area"], className)} {...other}>
|
40
|
+
<Viewport className={classnames(styles["scroll-area__viewport"], viewportClassName)}>{children}</Viewport>
|
41
|
+
|
42
|
+
<Scrollbar
|
43
|
+
orientation="vertical"
|
44
|
+
style={{padding: `0 ${xOffset}px`}}
|
45
|
+
className={classnames(styles["scroll-area__scrollbar"], scrollbarClassName)}
|
46
|
+
>
|
47
|
+
<Thumb className={classnames(styles["scroll-area__thumb"], thumbClassName)} />
|
48
|
+
</Scrollbar>
|
49
|
+
|
50
|
+
<Scrollbar
|
51
|
+
orientation="horizontal"
|
52
|
+
style={{padding: `${yOffset}px 0`}}
|
53
|
+
className={classnames(styles["scroll-area__scrollbar"], scrollbarClassName)}
|
54
|
+
>
|
55
|
+
<Thumb className={classnames(styles["scroll-area__thumb"], thumbClassName)} />
|
56
|
+
</Scrollbar>
|
57
|
+
|
58
|
+
<Corner className={classnames(styles["scroll-area__corner"], cornerClassName)} />
|
59
|
+
</Root>
|
60
|
+
);
|
61
|
+
};
|
62
|
+
|
63
|
+
export default memo(ScrollArea);
|
@@ -0,0 +1,54 @@
|
|
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
|
+
|
12
|
+
&__scrollbar {
|
13
|
+
display: flex;
|
14
|
+
user-select: none;
|
15
|
+
touch-action: none;
|
16
|
+
padding: var(--scroll-area-scrollbar-padding, 3px);
|
17
|
+
background: var(--scroll-area-scrollbar-bg-color, transparent);
|
18
|
+
transition: background var(--transition-speed-sm) ease-in-out;
|
19
|
+
|
20
|
+
&:hover {
|
21
|
+
background: var(--scroll-area-scrollbar-bg-color-hover, transparent);
|
22
|
+
}
|
23
|
+
|
24
|
+
&[data-orientation="vertical"] {
|
25
|
+
width: var(--scroll-area-scrollbar-size, 9px);
|
26
|
+
padding: 0 var(--scroll-area-scrollbar-offset, var(--scroll-area-scrollbar-x-offset, 2px));
|
27
|
+
}
|
28
|
+
|
29
|
+
&[data-orientation="horizontal"] {
|
30
|
+
flex-direction: column;
|
31
|
+
height: var(--scroll-area-scrollbar-size, 9px);
|
32
|
+
padding: var(--scroll-area-scrollbar-offset, var(--scroll-area-scrollbar-y-offset, 2px)) 0;
|
33
|
+
}
|
34
|
+
}
|
35
|
+
|
36
|
+
&__thumb {
|
37
|
+
flex: 1;
|
38
|
+
position: relative;
|
39
|
+
background: var(--scroll-area-thumb-bg-color);
|
40
|
+
border-radius: var(--scroll-area-thumb-border-radius, 100px);
|
41
|
+
|
42
|
+
&:hover {
|
43
|
+
background: var(--scroll-area-thumb-bg-color-hover, var(--scroll-area-thumb-bg-color));
|
44
|
+
}
|
45
|
+
}
|
46
|
+
|
47
|
+
&__corner {
|
48
|
+
background: var(--scroll-area-scrollbar-bg-color, transparent);
|
49
|
+
|
50
|
+
&:hover {
|
51
|
+
background: var(--scroll-area-scrollbar-bg-color-hover, transparent);
|
52
|
+
}
|
53
|
+
}
|
54
|
+
}
|
@@ -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,25 @@
|
|
1
|
+
import {Meta, StoryObj} from "@storybook/react";
|
2
|
+
|
3
|
+
import {hideInTable} from "../../utils";
|
4
|
+
|
5
|
+
import SwitchComponent from "./Switch";
|
6
|
+
|
7
|
+
const meta: Meta<typeof SwitchComponent> = {
|
8
|
+
title: "Components/Switch",
|
9
|
+
component: SwitchComponent,
|
10
|
+
tags: ["autodocs"],
|
11
|
+
argTypes: {
|
12
|
+
children: hideInTable,
|
13
|
+
className: hideInTable,
|
14
|
+
thumbClassName: hideInTable,
|
15
|
+
},
|
16
|
+
};
|
17
|
+
|
18
|
+
export default meta;
|
19
|
+
|
20
|
+
export const Switch: StoryObj<typeof SwitchComponent> = {
|
21
|
+
args: {
|
22
|
+
checked: true,
|
23
|
+
disabled: false,
|
24
|
+
},
|
25
|
+
};
|
@@ -0,0 +1,23 @@
|
|
1
|
+
import React, {FC, memo} 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: FC<SwitchProps> = props => {
|
14
|
+
const {className, thumbClassName, ...other} = {...useComponentProps("switch"), ...props};
|
15
|
+
|
16
|
+
return (
|
17
|
+
<Root {...other} className={classnames(styles["switch"], className)}>
|
18
|
+
<Thumb className={classnames(styles["switch__thumb"], thumbClassName)} />
|
19
|
+
</Root>
|
20
|
+
);
|
21
|
+
};
|
22
|
+
|
23
|
+
export default memo(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,157 @@
|
|
1
|
+
import {Meta, StoryObj} from "@storybook/react";
|
2
|
+
|
3
|
+
import {capitalizeFirstLetter} from "../../utils";
|
4
|
+
|
5
|
+
import TagComponent, {TagColor, TagRadius, TagSize, TagVariant} from "./Tag";
|
6
|
+
|
7
|
+
const variants: TagVariant[] = [TagVariant.Contained, TagVariant.Outlined, TagVariant.Soft];
|
8
|
+
const colors: (TagColor | "default")[] = ["default", TagColor.Primary, TagColor.Secondary, TagColor.Accent];
|
9
|
+
const sizes: (TagSize | "default")[] = [TagSize.Small, "default", TagSize.Medium, TagSize.Large];
|
10
|
+
const radius: (TagRadius | "default")[] = [TagRadius.Small, TagRadius.Medium, TagRadius.Large, "default"];
|
11
|
+
|
12
|
+
const meta: Meta<typeof TagComponent> = {
|
13
|
+
title: "Components/Tag",
|
14
|
+
component: TagComponent,
|
15
|
+
tags: ["autodocs"],
|
16
|
+
argTypes: {
|
17
|
+
variant: {
|
18
|
+
options: variants,
|
19
|
+
control: {type: "select"},
|
20
|
+
},
|
21
|
+
color: {
|
22
|
+
options: colors,
|
23
|
+
control: {type: "select"},
|
24
|
+
},
|
25
|
+
size: {
|
26
|
+
options: sizes,
|
27
|
+
control: {type: "select"},
|
28
|
+
},
|
29
|
+
radius: {
|
30
|
+
options: radius,
|
31
|
+
control: {type: "select"},
|
32
|
+
},
|
33
|
+
},
|
34
|
+
};
|
35
|
+
|
36
|
+
export default meta;
|
37
|
+
|
38
|
+
export const Tag: StoryObj<typeof TagComponent> = {
|
39
|
+
args: {
|
40
|
+
children: "Test",
|
41
|
+
variant: TagVariant.Contained,
|
42
|
+
color: TagColor.Primary,
|
43
|
+
clickable: false,
|
44
|
+
},
|
45
|
+
};
|
46
|
+
|
47
|
+
export const Variant = () => {
|
48
|
+
return (
|
49
|
+
<div className="grid-wrapper" style={{gridTemplateColumns: "repeat(3, auto)"}}>
|
50
|
+
{variants.map(variant => (
|
51
|
+
<div key={variant} className="item-card">
|
52
|
+
<TagComponent variant={variant} color={TagColor.Primary}>
|
53
|
+
{capitalizeFirstLetter(variant)}
|
54
|
+
</TagComponent>
|
55
|
+
</div>
|
56
|
+
))}
|
57
|
+
</div>
|
58
|
+
);
|
59
|
+
};
|
60
|
+
|
61
|
+
export const VariantDisabled = () => {
|
62
|
+
return (
|
63
|
+
<div className="grid-wrapper" style={{gridTemplateColumns: "repeat(3, auto)"}}>
|
64
|
+
{variants.map(variant => (
|
65
|
+
<div key={variant} className="item-card">
|
66
|
+
<TagComponent variant={variant} color={TagColor.Primary}>
|
67
|
+
{capitalizeFirstLetter(variant)}
|
68
|
+
</TagComponent>
|
69
|
+
</div>
|
70
|
+
))}
|
71
|
+
</div>
|
72
|
+
);
|
73
|
+
};
|
74
|
+
|
75
|
+
export const Size = () => {
|
76
|
+
return (
|
77
|
+
<div className="grid-wrapper" style={{gridTemplateColumns: "repeat(4, auto)"}}>
|
78
|
+
{sizes.map(size => (
|
79
|
+
<div key={size} className="item-card">
|
80
|
+
<TagComponent size={size !== "default" ? size : undefined} color={TagColor.Primary}>
|
81
|
+
{capitalizeFirstLetter(size)}
|
82
|
+
</TagComponent>
|
83
|
+
</div>
|
84
|
+
))}
|
85
|
+
</div>
|
86
|
+
);
|
87
|
+
};
|
88
|
+
|
89
|
+
export const Radius = () => {
|
90
|
+
return (
|
91
|
+
<div className="grid-wrapper" style={{gridTemplateColumns: "repeat(4, auto)"}}>
|
92
|
+
{radius.map(radius => (
|
93
|
+
<div key={radius} className="item-card">
|
94
|
+
<TagComponent radius={radius !== "default" ? radius : undefined} color={TagColor.Primary}>
|
95
|
+
{capitalizeFirstLetter(radius)}
|
96
|
+
</TagComponent>
|
97
|
+
</div>
|
98
|
+
))}
|
99
|
+
</div>
|
100
|
+
);
|
101
|
+
};
|
102
|
+
|
103
|
+
export const VariantColor = () => {
|
104
|
+
return (
|
105
|
+
<div className="grid-wrapper" style={{gridTemplateColumns: "repeat(4, auto)"}}>
|
106
|
+
{variants.map(variant =>
|
107
|
+
colors.map(color => (
|
108
|
+
<div key={`${variant}-${color}`}>
|
109
|
+
<TagComponent variant={variant} color={color !== "default" ? color : undefined}>
|
110
|
+
{capitalizeFirstLetter(color)}
|
111
|
+
</TagComponent>
|
112
|
+
</div>
|
113
|
+
))
|
114
|
+
)}
|
115
|
+
</div>
|
116
|
+
);
|
117
|
+
};
|
118
|
+
|
119
|
+
export const VariantSize = () => {
|
120
|
+
return (
|
121
|
+
<div className="grid-wrapper" style={{gridTemplateColumns: "repeat(4, auto)"}}>
|
122
|
+
{variants.map(variant =>
|
123
|
+
sizes.map(size => (
|
124
|
+
<div key={`${variant}-${size}`}>
|
125
|
+
<TagComponent
|
126
|
+
variant={variant}
|
127
|
+
size={size !== "default" ? size : undefined}
|
128
|
+
color={TagColor.Primary}
|
129
|
+
>
|
130
|
+
{capitalizeFirstLetter(size)}
|
131
|
+
</TagComponent>
|
132
|
+
</div>
|
133
|
+
))
|
134
|
+
)}
|
135
|
+
</div>
|
136
|
+
);
|
137
|
+
};
|
138
|
+
|
139
|
+
export const VariantRadius = () => {
|
140
|
+
return (
|
141
|
+
<div className="grid-wrapper" style={{gridTemplateColumns: "repeat(4, auto)"}}>
|
142
|
+
{variants.map(variant =>
|
143
|
+
radius.map(radius => (
|
144
|
+
<div key={`${variant}-${radius}`}>
|
145
|
+
<TagComponent
|
146
|
+
variant={variant}
|
147
|
+
radius={radius !== "default" ? radius : undefined}
|
148
|
+
color={TagColor.Primary}
|
149
|
+
>
|
150
|
+
{capitalizeFirstLetter(radius)}
|
151
|
+
</TagComponent>
|
152
|
+
</div>
|
153
|
+
))
|
154
|
+
)}
|
155
|
+
</div>
|
156
|
+
);
|
157
|
+
};
|
@@ -0,0 +1,71 @@
|
|
1
|
+
import React, {ComponentProps, FC, memo} from "react";
|
2
|
+
import classnames from "classnames";
|
3
|
+
import {useComponentProps} from "../../providers";
|
4
|
+
|
5
|
+
import styles from "./tag.module.scss";
|
6
|
+
|
7
|
+
export enum TagVariant {
|
8
|
+
Contained = "contained",
|
9
|
+
Outlined = "outlined",
|
10
|
+
Soft = "soft",
|
11
|
+
}
|
12
|
+
|
13
|
+
export enum TagColor {
|
14
|
+
Primary = "primary",
|
15
|
+
Secondary = "secondary",
|
16
|
+
Accent = "accent",
|
17
|
+
}
|
18
|
+
|
19
|
+
export enum TagSize {
|
20
|
+
Small = "small",
|
21
|
+
Medium = "medium",
|
22
|
+
Large = "large",
|
23
|
+
}
|
24
|
+
|
25
|
+
export enum TagRadius {
|
26
|
+
Small = "small",
|
27
|
+
Medium = "medium",
|
28
|
+
Large = "large",
|
29
|
+
}
|
30
|
+
|
31
|
+
export interface TagProps extends ComponentProps<"span"> {
|
32
|
+
size?: TagSize;
|
33
|
+
color?: TagColor;
|
34
|
+
radius?: TagRadius;
|
35
|
+
variant?: TagVariant;
|
36
|
+
clickable?: boolean;
|
37
|
+
}
|
38
|
+
|
39
|
+
const Tag: FC<TagProps> = props => {
|
40
|
+
const {
|
41
|
+
size,
|
42
|
+
color,
|
43
|
+
radius,
|
44
|
+
variant = TagVariant.Contained,
|
45
|
+
clickable,
|
46
|
+
children,
|
47
|
+
className,
|
48
|
+
...other
|
49
|
+
} = {...useComponentProps("tag"), ...props};
|
50
|
+
|
51
|
+
return (
|
52
|
+
<span
|
53
|
+
{...other}
|
54
|
+
className={classnames(
|
55
|
+
styles["tag"],
|
56
|
+
{
|
57
|
+
[styles[`tag--${variant}`]]: variant,
|
58
|
+
[styles[`tag--${radius}-radius`]]: radius,
|
59
|
+
[styles[`tag--${color}-color`]]: color,
|
60
|
+
[styles[`tag--${size}-size`]]: size,
|
61
|
+
[styles["tag--clickable"]]: clickable,
|
62
|
+
},
|
63
|
+
className
|
64
|
+
)}
|
65
|
+
>
|
66
|
+
{children}
|
67
|
+
</span>
|
68
|
+
);
|
69
|
+
};
|
70
|
+
|
71
|
+
export default memo(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, 1rem);
|
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
|
+
}
|