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,58 @@
|
|
1
|
+
import React, {ComponentProps, FC, memo, ReactNode} from "react";
|
2
|
+
import classnames from "classnames";
|
3
|
+
|
4
|
+
import {cloneOrCreateElement} from "../../utils";
|
5
|
+
import {useComponentProps} from "../../providers";
|
6
|
+
|
7
|
+
import styles from "./footer.module.scss";
|
8
|
+
|
9
|
+
export interface FooterProps extends ComponentProps<"footer"> {
|
10
|
+
left?: ReactNode;
|
11
|
+
right?: ReactNode;
|
12
|
+
shadow?: boolean;
|
13
|
+
reverse?: boolean;
|
14
|
+
leftClassName?: string;
|
15
|
+
rightClassName?: string;
|
16
|
+
childrenClassName?: string;
|
17
|
+
}
|
18
|
+
|
19
|
+
const Footer: FC<FooterProps> = props => {
|
20
|
+
const {
|
21
|
+
left,
|
22
|
+
right,
|
23
|
+
shadow,
|
24
|
+
reverse,
|
25
|
+
children,
|
26
|
+
className,
|
27
|
+
leftClassName,
|
28
|
+
rightClassName,
|
29
|
+
childrenClassName,
|
30
|
+
...other
|
31
|
+
} = {...useComponentProps("footer"), ...props};
|
32
|
+
|
33
|
+
return (
|
34
|
+
<footer
|
35
|
+
{...other}
|
36
|
+
className={classnames(
|
37
|
+
styles["footer"],
|
38
|
+
{
|
39
|
+
[styles["footer--shadow"]]: shadow,
|
40
|
+
[styles["footer--reverse"]]: reverse,
|
41
|
+
},
|
42
|
+
className
|
43
|
+
)}
|
44
|
+
>
|
45
|
+
{cloneOrCreateElement(
|
46
|
+
children,
|
47
|
+
{className: classnames(styles["footer-children"], childrenClassName)},
|
48
|
+
"div"
|
49
|
+
)}
|
50
|
+
{!children &&
|
51
|
+
cloneOrCreateElement(left, {className: classnames(styles["footer-left"], leftClassName)}, "div")}
|
52
|
+
{!children &&
|
53
|
+
cloneOrCreateElement(right, {className: classnames(styles["footer-right"], rightClassName)}, "div")}
|
54
|
+
</footer>
|
55
|
+
);
|
56
|
+
};
|
57
|
+
|
58
|
+
export default memo(Footer);
|
@@ -0,0 +1,44 @@
|
|
1
|
+
$root: footer;
|
2
|
+
|
3
|
+
.#{$root} {
|
4
|
+
box-sizing: border-box;
|
5
|
+
display: flex;
|
6
|
+
justify-content: space-between;
|
7
|
+
width: 100%;
|
8
|
+
padding: var(--footer-padding, var(--side-padding-sm));
|
9
|
+
padding-top: 0;
|
10
|
+
background-color: var(--footer-background-color, transparent);
|
11
|
+
transition:
|
12
|
+
background-color var(--transition-speed-sm),
|
13
|
+
box-shadow var(--transition-speed-sm);
|
14
|
+
|
15
|
+
&--shadow {
|
16
|
+
box-shadow: var(--footer-box-shadow, 0px -4px 4px 0px rgba(0, 0, 0, 0.03));
|
17
|
+
}
|
18
|
+
|
19
|
+
&--reverse {
|
20
|
+
flex-direction: row-reverse;
|
21
|
+
}
|
22
|
+
|
23
|
+
&-children {
|
24
|
+
width: 100%;
|
25
|
+
display: flex;
|
26
|
+
justify-content: space-between;
|
27
|
+
|
28
|
+
.#{$root}--reverse & {
|
29
|
+
flex-direction: row-reverse;
|
30
|
+
}
|
31
|
+
}
|
32
|
+
|
33
|
+
&-left {
|
34
|
+
display: flex;
|
35
|
+
align-items: center;
|
36
|
+
gap: var(--footer-left-gap, var(--footer-gap, 15px));
|
37
|
+
}
|
38
|
+
|
39
|
+
&-right {
|
40
|
+
display: flex;
|
41
|
+
align-items: center;
|
42
|
+
gap: var(--footer-right-gap, var(--footer-gap, 15px));
|
43
|
+
}
|
44
|
+
}
|
@@ -0,0 +1,49 @@
|
|
1
|
+
import {Meta, StoryObj} from "@storybook/react";
|
2
|
+
|
3
|
+
import {hideInTable} from "../../utils";
|
4
|
+
|
5
|
+
import HeaderComponent from "./Header";
|
6
|
+
|
7
|
+
const meta: Meta<typeof HeaderComponent> = {
|
8
|
+
title: "Components/Header",
|
9
|
+
component: HeaderComponent,
|
10
|
+
tags: ["autodocs"],
|
11
|
+
argTypes: {
|
12
|
+
before: hideInTable,
|
13
|
+
after: hideInTable,
|
14
|
+
children: hideInTable,
|
15
|
+
className: hideInTable,
|
16
|
+
wrapClassName: hideInTable,
|
17
|
+
titleClassName: hideInTable,
|
18
|
+
beforeClassName: hideInTable,
|
19
|
+
afterClassName: hideInTable,
|
20
|
+
subtitleClassName: hideInTable,
|
21
|
+
childrenClassName: hideInTable,
|
22
|
+
},
|
23
|
+
decorators: [
|
24
|
+
Story => (
|
25
|
+
<div
|
26
|
+
style={{background: "var(--bg-secondary-color", width: "380px", height: "300px", borderRadius: "10px"}}
|
27
|
+
>
|
28
|
+
<Story />
|
29
|
+
</div>
|
30
|
+
),
|
31
|
+
],
|
32
|
+
};
|
33
|
+
|
34
|
+
export default meta;
|
35
|
+
|
36
|
+
export const Header: StoryObj<typeof HeaderComponent> = {
|
37
|
+
args: {
|
38
|
+
title: "Volume Up Plus",
|
39
|
+
subtitle: "Adjust the current tab's volume with the slider. Switch to any audio tab in one click.",
|
40
|
+
},
|
41
|
+
};
|
42
|
+
|
43
|
+
export const WithLogo: StoryObj<typeof HeaderComponent> = {
|
44
|
+
args: {
|
45
|
+
title: "Volume Up Plus",
|
46
|
+
subtitle: "Adjust the current tab's volume with the slider. Switch to any audio tab in one click.",
|
47
|
+
before: "❤️",
|
48
|
+
},
|
49
|
+
};
|
@@ -0,0 +1,73 @@
|
|
1
|
+
import React, {ComponentProps, FC, memo, ReactNode} from "react";
|
2
|
+
import classnames from "classnames";
|
3
|
+
|
4
|
+
import {cloneOrCreateElement} from "../../utils";
|
5
|
+
import {useComponentProps} from "../../providers";
|
6
|
+
|
7
|
+
import styles from "./header.module.scss";
|
8
|
+
|
9
|
+
export interface HeaderProps extends Omit<ComponentProps<"header">, "title"> {
|
10
|
+
title?: ReactNode;
|
11
|
+
before?: ReactNode;
|
12
|
+
after?: ReactNode;
|
13
|
+
subtitle?: ReactNode;
|
14
|
+
wrapClassName?: string;
|
15
|
+
titleClassName?: string;
|
16
|
+
beforeClassName?: string;
|
17
|
+
afterClassName?: string;
|
18
|
+
subtitleClassName?: string;
|
19
|
+
childrenClassName?: string;
|
20
|
+
alignCenter?: boolean;
|
21
|
+
}
|
22
|
+
|
23
|
+
const Header: FC<HeaderProps> = props => {
|
24
|
+
const {
|
25
|
+
title,
|
26
|
+
before,
|
27
|
+
after,
|
28
|
+
subtitle,
|
29
|
+
className,
|
30
|
+
wrapClassName,
|
31
|
+
titleClassName,
|
32
|
+
beforeClassName,
|
33
|
+
afterClassName,
|
34
|
+
subtitleClassName,
|
35
|
+
childrenClassName,
|
36
|
+
alignCenter = true,
|
37
|
+
children,
|
38
|
+
...other
|
39
|
+
} = {...useComponentProps("header"), ...props};
|
40
|
+
|
41
|
+
return (
|
42
|
+
<header
|
43
|
+
{...other}
|
44
|
+
className={classnames(
|
45
|
+
styles["header"],
|
46
|
+
{
|
47
|
+
[styles["header--center"]]: alignCenter,
|
48
|
+
},
|
49
|
+
className
|
50
|
+
)}
|
51
|
+
>
|
52
|
+
{(title || subtitle) && (
|
53
|
+
<div className={classnames(styles["header__wrap"], wrapClassName)}>
|
54
|
+
<h1 className={classnames(styles["header__title"], titleClassName)}>
|
55
|
+
{cloneOrCreateElement(before, {className: beforeClassName})}
|
56
|
+
{title}
|
57
|
+
{cloneOrCreateElement(after, {className: afterClassName})}
|
58
|
+
</h1>
|
59
|
+
|
60
|
+
{cloneOrCreateElement(
|
61
|
+
subtitle,
|
62
|
+
{className: classnames(styles["header__subtitle"], subtitleClassName)},
|
63
|
+
"h2"
|
64
|
+
)}
|
65
|
+
</div>
|
66
|
+
)}
|
67
|
+
|
68
|
+
{cloneOrCreateElement(children, {className: childrenClassName}, "div")}
|
69
|
+
</header>
|
70
|
+
);
|
71
|
+
};
|
72
|
+
|
73
|
+
export default memo(Header);
|
@@ -0,0 +1,56 @@
|
|
1
|
+
$root: header;
|
2
|
+
|
3
|
+
.#{$root} {
|
4
|
+
display: flex;
|
5
|
+
flex-direction: column;
|
6
|
+
width: 100%;
|
7
|
+
box-sizing: border-box;
|
8
|
+
gap: var(--header-gap, 10px);
|
9
|
+
padding: var(--header-padding, var(--side-padding-sm));
|
10
|
+
padding-bottom: 0;
|
11
|
+
|
12
|
+
&__wrap {
|
13
|
+
display: flex;
|
14
|
+
flex-direction: column;
|
15
|
+
overflow: hidden;
|
16
|
+
white-space: nowrap;
|
17
|
+
gap: var(--header-wrap-gap, 10px);
|
18
|
+
}
|
19
|
+
|
20
|
+
&__title,
|
21
|
+
&__subtitle {
|
22
|
+
margin: 0;
|
23
|
+
overflow: hidden;
|
24
|
+
text-overflow: ellipsis;
|
25
|
+
}
|
26
|
+
|
27
|
+
&__title {
|
28
|
+
display: flex;
|
29
|
+
align-items: center;
|
30
|
+
gap: var(--header-title-gap, 12px);
|
31
|
+
color: var(--header-title-color, var(--text-primary-color));
|
32
|
+
font-size: var(--header-title-font-size, 25px);
|
33
|
+
font-family: var(--header-title-font-family, var(--font-family)), "sans-serif";
|
34
|
+
font-weight: var(--header-title-font-weight, 700);
|
35
|
+
line-height: var(--header-title-line-height, 120%);
|
36
|
+
will-change: color;
|
37
|
+
transition: color var(--transition-speed);
|
38
|
+
|
39
|
+
.#{$root}--center & {
|
40
|
+
justify-content: center;
|
41
|
+
}
|
42
|
+
}
|
43
|
+
|
44
|
+
&__subtitle {
|
45
|
+
color: var(--header-subtitle-color, var(--text-secondary-color));
|
46
|
+
font-size: var(--header-subtitle-font-size, 14px);
|
47
|
+
font-family: var(--header-subtitle-font-family, var(--font-family)), "sans-serif";
|
48
|
+
font-weight: var(--header-subtitle-font-weight, 400);
|
49
|
+
line-height: var(--header-subtitle-line-height, 120%);
|
50
|
+
white-space: wrap;
|
51
|
+
|
52
|
+
.#{$root}--center & {
|
53
|
+
text-align: center;
|
54
|
+
}
|
55
|
+
}
|
56
|
+
}
|
@@ -0,0 +1,83 @@
|
|
1
|
+
import {Meta, StoryObj} from "@storybook/react";
|
2
|
+
|
3
|
+
import {capitalizeFirstLetter, hideInTable} from "../../utils";
|
4
|
+
|
5
|
+
import HighlightComponent, {HighlightColor} from "./Highlight";
|
6
|
+
|
7
|
+
const colors: (HighlightColor | "default")[] = [
|
8
|
+
"default",
|
9
|
+
HighlightColor.Primary,
|
10
|
+
HighlightColor.Secondary,
|
11
|
+
HighlightColor.Accent,
|
12
|
+
];
|
13
|
+
const searchWords = ["Adjust", "volume", "switch", "audio"];
|
14
|
+
const textToHighlight = "Adjust the current tab's volume with the slider. Switch to any audio tab in one click";
|
15
|
+
|
16
|
+
const meta: Meta<typeof HighlightComponent> = {
|
17
|
+
title: "Components/Highlighter",
|
18
|
+
component: HighlightComponent,
|
19
|
+
tags: ["autodocs"],
|
20
|
+
argTypes: {
|
21
|
+
color: {
|
22
|
+
options: colors,
|
23
|
+
control: {type: "select"},
|
24
|
+
},
|
25
|
+
searchWords: {
|
26
|
+
description:
|
27
|
+
"Array of search words. String search terms are automatically cast to RegExps unless autoEscape is true.",
|
28
|
+
},
|
29
|
+
activeIndex: {
|
30
|
+
description: "Specify the match index that should be actively highlighted. Use along with activeClassName",
|
31
|
+
},
|
32
|
+
caseSensitive: {
|
33
|
+
description: "Search should be case sensitive; defaults to false",
|
34
|
+
},
|
35
|
+
textToHighlight: {
|
36
|
+
description: "Text to highlight matches in",
|
37
|
+
},
|
38
|
+
|
39
|
+
style: hideInTable,
|
40
|
+
children: hideInTable,
|
41
|
+
className: hideInTable,
|
42
|
+
},
|
43
|
+
decorators: [
|
44
|
+
Story => (
|
45
|
+
<div style={{color: "var(--text-primary-color"}}>
|
46
|
+
<Story />
|
47
|
+
</div>
|
48
|
+
),
|
49
|
+
],
|
50
|
+
};
|
51
|
+
|
52
|
+
export default meta;
|
53
|
+
|
54
|
+
export const Highlight: StoryObj<typeof HighlightComponent> = {
|
55
|
+
args: {
|
56
|
+
searchWords,
|
57
|
+
textToHighlight,
|
58
|
+
color: undefined,
|
59
|
+
activeIndex: 0,
|
60
|
+
caseSensitive: true,
|
61
|
+
},
|
62
|
+
};
|
63
|
+
|
64
|
+
export const Color = () => {
|
65
|
+
return (
|
66
|
+
<div>
|
67
|
+
{colors.map(color => (
|
68
|
+
<div key={color} style={{margin: "20px", display: "flex", alignItems: "center"}}>
|
69
|
+
<span className="item-card__title" style={{width: "150px"}}>
|
70
|
+
{capitalizeFirstLetter(color)} color
|
71
|
+
</span>
|
72
|
+
|
73
|
+
<HighlightComponent
|
74
|
+
searchWords={searchWords}
|
75
|
+
textToHighlight={textToHighlight}
|
76
|
+
color={color !== "default" ? color : undefined}
|
77
|
+
activeIndex={0}
|
78
|
+
/>
|
79
|
+
</div>
|
80
|
+
))}
|
81
|
+
</div>
|
82
|
+
);
|
83
|
+
};
|
@@ -0,0 +1,40 @@
|
|
1
|
+
import React, {FC, memo} from "react";
|
2
|
+
import classnames from "classnames";
|
3
|
+
import Highlighter, {HighlighterProps} from "react-highlight-words";
|
4
|
+
|
5
|
+
import {useComponentProps} from "../../providers";
|
6
|
+
|
7
|
+
import styles from "./highlight.module.scss";
|
8
|
+
|
9
|
+
export enum HighlightColor {
|
10
|
+
Primary = "primary",
|
11
|
+
Secondary = "secondary",
|
12
|
+
Accent = "accent",
|
13
|
+
}
|
14
|
+
|
15
|
+
export interface HighlightProps extends HighlighterProps {
|
16
|
+
color?: HighlightColor;
|
17
|
+
}
|
18
|
+
|
19
|
+
const Highlight: FC<HighlightProps> = props => {
|
20
|
+
const {color, activeClassName, highlightClassName, ...other} = {
|
21
|
+
...useComponentProps("highlight"),
|
22
|
+
...props,
|
23
|
+
};
|
24
|
+
|
25
|
+
return (
|
26
|
+
<Highlighter
|
27
|
+
highlightClassName={classnames(
|
28
|
+
styles["highlight"],
|
29
|
+
{
|
30
|
+
[styles[`highlight--${color}-color`]]: color,
|
31
|
+
},
|
32
|
+
highlightClassName
|
33
|
+
)}
|
34
|
+
activeClassName={classnames(styles["highlight--active"], activeClassName)}
|
35
|
+
{...other}
|
36
|
+
/>
|
37
|
+
);
|
38
|
+
};
|
39
|
+
|
40
|
+
export default memo(Highlight);
|
@@ -0,0 +1,47 @@
|
|
1
|
+
$root: highlight;
|
2
|
+
|
3
|
+
.#{$root} {
|
4
|
+
font-size: var(--highlight-font-size, inherit);
|
5
|
+
font-weight: var(--highlight-font-weight, inherit);
|
6
|
+
font-family: var(--highlight-font-family, inherit), sans-serif;
|
7
|
+
color: var(--highlight-color, #fff);
|
8
|
+
background-color: var(--highlight-bg-color, #ffd60a);
|
9
|
+
padding: var(--highlight-y-padding, 2px) var(--highlight-x-padding, 3px);
|
10
|
+
margin: 0 calc(-1 * var(--highlight-x-padding, 3px));
|
11
|
+
border-radius: var(--highlight-border-radius, 2px);
|
12
|
+
|
13
|
+
&--primary-color {
|
14
|
+
color: var(--highlight-primary-color, #fff);
|
15
|
+
background-color: var(--primary-color);
|
16
|
+
}
|
17
|
+
|
18
|
+
&--secondary-color {
|
19
|
+
color: var(--highlight-secondary-color, #fff);
|
20
|
+
background-color: var(--secondary-color);
|
21
|
+
}
|
22
|
+
|
23
|
+
&--accent-color {
|
24
|
+
color: var(--highlight-accent-color, #fff);
|
25
|
+
background-color: var(--accent-color);
|
26
|
+
}
|
27
|
+
|
28
|
+
&--active {
|
29
|
+
color: var(--highlight-active-color, var(--highlight-color, #fff));
|
30
|
+
background-color: var(--highlight-active-bg-color, #ff801f);
|
31
|
+
|
32
|
+
&.#{$root}--primary-color {
|
33
|
+
color: var(--highlight-active-primary-color, var(--highlight-primary-color, #fff));
|
34
|
+
background-color: color-mix(in srgb, black 40%, var(--primary-color));
|
35
|
+
}
|
36
|
+
|
37
|
+
&.#{$root}--secondary-color {
|
38
|
+
color: var(--highlight-active-secondary-color, var(--highlight-secondary-color, #fff));
|
39
|
+
background-color: color-mix(in srgb, black 40%, var(--secondary-color));
|
40
|
+
}
|
41
|
+
|
42
|
+
&.#{$root}--accent-color {
|
43
|
+
color: var(--highlight-active-accent-color, var(--highlight-accent-color, #fff));
|
44
|
+
background-color: color-mix(in srgb, black 40%, var(--accent-color));
|
45
|
+
}
|
46
|
+
}
|
47
|
+
}
|
@@ -0,0 +1,46 @@
|
|
1
|
+
import React, {FC, memo, useEffect, ComponentProps} from "react";
|
2
|
+
import classnames from "classnames";
|
3
|
+
import {useComponentProps, useIcons} from "../../providers";
|
4
|
+
|
5
|
+
import styles from "./icon.module.scss";
|
6
|
+
|
7
|
+
export interface IconProps extends ComponentProps<"svg"> {
|
8
|
+
name: string;
|
9
|
+
size?: number;
|
10
|
+
}
|
11
|
+
|
12
|
+
const Icon: FC<IconProps> = props => {
|
13
|
+
const {
|
14
|
+
name,
|
15
|
+
className,
|
16
|
+
size = 24,
|
17
|
+
width = size,
|
18
|
+
height = size,
|
19
|
+
...other
|
20
|
+
} = {...useComponentProps("icon"), ...props};
|
21
|
+
|
22
|
+
const {icons, registerIcon} = useIcons();
|
23
|
+
|
24
|
+
useEffect(() => icons[name] && registerIcon(name), [name, icons, registerIcon]);
|
25
|
+
|
26
|
+
if (!icons[name]) {
|
27
|
+
console.warn(`Icon "${name}" not found.`);
|
28
|
+
|
29
|
+
return (
|
30
|
+
<span
|
31
|
+
className={styles["icon--default"]}
|
32
|
+
style={{fontSize: `${width}px`, lineHeight: `${width}px`, width, height}}
|
33
|
+
>
|
34
|
+
⁇
|
35
|
+
</span>
|
36
|
+
);
|
37
|
+
}
|
38
|
+
|
39
|
+
return (
|
40
|
+
<svg className={classnames(styles["icon"], className)} width={width} height={height} {...other}>
|
41
|
+
<use href={`#${name}`} />
|
42
|
+
</svg>
|
43
|
+
);
|
44
|
+
};
|
45
|
+
|
46
|
+
export default memo(Icon);
|
@@ -0,0 +1,17 @@
|
|
1
|
+
.icon {
|
2
|
+
color: var(--icon-color);
|
3
|
+
transition:
|
4
|
+
transform var(--transition-speed-sm),
|
5
|
+
color var(--transition-speed-sm);
|
6
|
+
|
7
|
+
&:hover {
|
8
|
+
color: var(--icon-color-hover);
|
9
|
+
transform: scale(var(--icon-scale, 1));
|
10
|
+
}
|
11
|
+
|
12
|
+
&--default {
|
13
|
+
display: flex;
|
14
|
+
align-items: center;
|
15
|
+
justify-content: center;
|
16
|
+
}
|
17
|
+
}
|