adnbn-ui 0.0.1 → 0.1.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.
Files changed (146) hide show
  1. package/.prettierignore +3 -0
  2. package/.prettierrc +28 -0
  3. package/.storybook/main.ts +22 -0
  4. package/.storybook/preview.tsx +100 -0
  5. package/.storybook/styles/custom.scss +59 -0
  6. package/.storybook/styles/preview.css +58 -0
  7. package/.storybook/vitest.setup.ts +9 -0
  8. package/README.md +1057 -0
  9. package/eslint.config.js +39 -0
  10. package/package.json +95 -4
  11. package/src/components/Avatar/Avatar.stories.tsx +118 -0
  12. package/src/components/Avatar/Avatar.tsx +65 -0
  13. package/src/components/Avatar/avatar.module.scss +77 -0
  14. package/src/components/Avatar/index.ts +2 -0
  15. package/src/components/BaseButton/BaseButton.tsx +36 -0
  16. package/src/components/BaseButton/base-button.module.scss +24 -0
  17. package/src/components/BaseButton/index.ts +2 -0
  18. package/src/components/Button/Button.stories.tsx +148 -0
  19. package/src/components/Button/Button.tsx +73 -0
  20. package/src/components/Button/button.module.scss +140 -0
  21. package/src/components/Button/index.ts +2 -0
  22. package/src/components/Checkbox/Checkbox.stories.tsx +180 -0
  23. package/src/components/Checkbox/Checkbox.tsx +71 -0
  24. package/src/components/Checkbox/checkbox.module.scss +82 -0
  25. package/src/components/Checkbox/index.ts +2 -0
  26. package/src/components/Dialog/Dialog.tsx +125 -0
  27. package/src/components/Dialog/dialog.module.scss +55 -0
  28. package/src/components/Dialog/index.ts +2 -0
  29. package/src/components/Drawer/Drawer.stories.tsx +89 -0
  30. package/src/components/Drawer/Drawer.tsx +57 -0
  31. package/src/components/Drawer/drawer.module.scss +170 -0
  32. package/src/components/Drawer/index.ts +2 -0
  33. package/src/components/Footer/Footer.stories.tsx +118 -0
  34. package/src/components/Footer/Footer.tsx +58 -0
  35. package/src/components/Footer/footer.module.scss +44 -0
  36. package/src/components/Footer/index.ts +2 -0
  37. package/src/components/Header/Header.stories.tsx +49 -0
  38. package/src/components/Header/Header.tsx +73 -0
  39. package/src/components/Header/header.module.scss +56 -0
  40. package/src/components/Header/index.ts +2 -0
  41. package/src/components/Highlight/Highlight.stories.tsx +83 -0
  42. package/src/components/Highlight/Highlight.tsx +40 -0
  43. package/src/components/Highlight/highlight.module.scss +47 -0
  44. package/src/components/Highlight/index.ts +2 -0
  45. package/src/components/Icon/Icon.tsx +46 -0
  46. package/src/components/Icon/icon.module.scss +17 -0
  47. package/src/components/Icon/index.ts +2 -0
  48. package/src/components/IconButton/IconButton.stories.tsx +179 -0
  49. package/src/components/IconButton/IconButton.tsx +65 -0
  50. package/src/components/IconButton/icon-button.module.scss +86 -0
  51. package/src/components/IconButton/index.ts +2 -0
  52. package/src/components/Layout/Layout.stories.tsx +88 -0
  53. package/src/components/Layout/Provider.tsx +47 -0
  54. package/src/components/Layout/context.ts +24 -0
  55. package/src/components/Layout/index.ts +2 -0
  56. package/src/components/Layout/layout.module.scss +17 -0
  57. package/src/components/List/List.stories.tsx +81 -0
  58. package/src/components/List/List.tsx +24 -0
  59. package/src/components/List/index.ts +2 -0
  60. package/src/components/List/list.module.scss +8 -0
  61. package/src/components/ListItem/ListItem.tsx +75 -0
  62. package/src/components/ListItem/index.ts +2 -0
  63. package/src/components/ListItem/list-item.module.scss +36 -0
  64. package/src/components/Modal/Modal.stories.tsx +95 -0
  65. package/src/components/Modal/Modal.tsx +94 -0
  66. package/src/components/Modal/index.ts +2 -0
  67. package/src/components/Modal/modal.module.scss +97 -0
  68. package/src/components/Odometer/Odometer.stories.tsx +66 -0
  69. package/src/components/Odometer/Odometer.tsx +45 -0
  70. package/src/components/Odometer/hooks/useOdometer.tsx +24 -0
  71. package/src/components/Odometer/index.ts +3 -0
  72. package/src/components/Odometer/odometer.module.scss +81 -0
  73. package/src/components/Odometer/odometr.d.ts +9 -0
  74. package/src/components/ScrollArea/ScrollArea.stories.tsx +58 -0
  75. package/src/components/ScrollArea/ScrollArea.tsx +63 -0
  76. package/src/components/ScrollArea/index.ts +2 -0
  77. package/src/components/ScrollArea/scroll-area.module.scss +54 -0
  78. package/src/components/SvgSprite/SvgSprite.tsx +21 -0
  79. package/src/components/SvgSprite/index.ts +2 -0
  80. package/src/components/Switch/Switch.stories.tsx +25 -0
  81. package/src/components/Switch/Switch.tsx +23 -0
  82. package/src/components/Switch/index.ts +2 -0
  83. package/src/components/Switch/switch.module.scss +65 -0
  84. package/src/components/Tag/Tag.stories.tsx +157 -0
  85. package/src/components/Tag/Tag.tsx +71 -0
  86. package/src/components/Tag/index.ts +2 -0
  87. package/src/components/Tag/tag.module.scss +118 -0
  88. package/src/components/TextArea/TextArea.stories.tsx +145 -0
  89. package/src/components/TextArea/TextArea.tsx +143 -0
  90. package/src/components/TextArea/index.ts +2 -0
  91. package/src/components/TextArea/text-area.module.scss +88 -0
  92. package/src/components/TextField/TextField.stories.tsx +177 -0
  93. package/src/components/TextField/TextField.tsx +162 -0
  94. package/src/components/TextField/index.ts +2 -0
  95. package/src/components/TextField/text-field.module.scss +129 -0
  96. package/src/components/Toast/Toast.stories.tsx +209 -0
  97. package/src/components/Toast/Toast.tsx +142 -0
  98. package/src/components/Toast/index.ts +2 -0
  99. package/src/components/Toast/toast.module.scss +267 -0
  100. package/src/components/Tooltip/Tooltip.stories.tsx +80 -0
  101. package/src/components/Tooltip/Tooltip.tsx +79 -0
  102. package/src/components/Tooltip/index.ts +2 -0
  103. package/src/components/Tooltip/tooltip.module.scss +93 -0
  104. package/src/components/View/View.stories.tsx +47 -0
  105. package/src/components/View/View.tsx +68 -0
  106. package/src/components/View/index.ts +2 -0
  107. package/src/components/View/view.module.scss +38 -0
  108. package/src/components/ViewDrawer/ViewDrawer.stories.tsx +75 -0
  109. package/src/components/ViewDrawer/ViewDrawer.tsx +24 -0
  110. package/src/components/ViewDrawer/index.ts +2 -0
  111. package/src/components/ViewModal/ViewModal.stories.tsx +68 -0
  112. package/src/components/ViewModal/ViewModal.tsx +24 -0
  113. package/src/components/ViewModal/index.ts +2 -0
  114. package/src/components/index.ts +29 -0
  115. package/src/components/types.ts +65 -0
  116. package/src/config/default.ts +3 -0
  117. package/src/config/index.ts +26 -0
  118. package/src/declaration.d.ts +8 -0
  119. package/src/index.ts +3 -0
  120. package/src/plugin/builder/ConfigBuilder.ts +32 -0
  121. package/src/plugin/builder/StyleBuilder.ts +34 -0
  122. package/src/plugin/builder/virtual.config.ts +7 -0
  123. package/src/plugin/finder/ConfigFinder.ts +26 -0
  124. package/src/plugin/finder/Finder.ts +76 -0
  125. package/src/plugin/finder/StyleFinder.ts +23 -0
  126. package/src/plugin/index.ts +70 -0
  127. package/src/plugin/types.ts +8 -0
  128. package/src/providers/UIProvider.tsx +26 -0
  129. package/src/providers/icons/IconsProvider.tsx +34 -0
  130. package/src/providers/icons/context.ts +22 -0
  131. package/src/providers/icons/index.ts +3 -0
  132. package/src/providers/index.ts +3 -0
  133. package/src/providers/theme/ThemeProvider.tsx +39 -0
  134. package/src/providers/theme/context.ts +30 -0
  135. package/src/providers/theme/index.ts +2 -0
  136. package/src/providers/theme/styles/default.scss +95 -0
  137. package/src/providers/theme/styles/reset.css +111 -0
  138. package/src/styles/mixins.scss +23 -0
  139. package/src/types/theme.ts +4 -0
  140. package/src/utils/index.ts +2 -0
  141. package/src/utils/react.ts +21 -0
  142. package/src/utils/utils.ts +12 -0
  143. package/tsconfig.json +18 -0
  144. package/vite.config.ts +11 -0
  145. package/vitest.workspace.ts +19 -0
  146. package/components/Button/index.ts +0 -0
@@ -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,2 @@
1
+ export {default as Header} from "./Header";
2
+ export type {HeaderProps} from "./Header";
@@ -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,2 @@
1
+ export {default as Highlight, HighlightColor} from "./Highlight";
2
+ export type {HighlightProps} from "./Highlight";
@@ -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
+ }
@@ -0,0 +1,2 @@
1
+ export {default as Icon} from "./Icon";
2
+ export type {IconProps} from "./Icon";
@@ -0,0 +1,179 @@
1
+ import {Meta, StoryObj} from "@storybook/react";
2
+
3
+ import {capitalizeFirstLetter, hideInTable} from "../../utils";
4
+
5
+ import IconButtonComponent, {IconButtonRadius, IconButtonSize, IconButtonVariant} from "./IconButton";
6
+
7
+ const variants: (IconButtonVariant | "default")[] = [
8
+ "default",
9
+ IconButtonVariant.Contained,
10
+ IconButtonVariant.Outlined,
11
+ IconButtonVariant.Ghost,
12
+ ];
13
+ const sizes: (IconButtonSize | "default")[] = [
14
+ IconButtonSize.Small,
15
+ "default",
16
+ IconButtonSize.Medium,
17
+ IconButtonSize.Large,
18
+ ];
19
+ const radius: (IconButtonRadius | "default")[] = [
20
+ IconButtonRadius.Small,
21
+ IconButtonRadius.Medium,
22
+ IconButtonRadius.Large,
23
+ "default",
24
+ ];
25
+
26
+ const meta: Meta<typeof IconButtonComponent> = {
27
+ title: "Components/IconButton",
28
+ component: IconButtonComponent,
29
+ tags: ["autodocs"],
30
+ argTypes: {
31
+ variant: {
32
+ options: variants,
33
+ control: {type: "select"},
34
+ },
35
+ size: {
36
+ options: sizes,
37
+ control: {type: "select"},
38
+ },
39
+ radius: {
40
+ options: radius,
41
+ control: {type: "select"},
42
+ },
43
+
44
+ after: hideInTable,
45
+ before: hideInTable,
46
+ children: hideInTable,
47
+ afterClassName: hideInTable,
48
+ beforeClassName: hideInTable,
49
+ childrenClassName: hideInTable,
50
+ },
51
+ };
52
+
53
+ export default meta;
54
+
55
+ const icon = (
56
+ <svg width="24" height="24" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
57
+ <path
58
+ d="M12.0002 2L15.1037 8.72839L22.4618 9.60081L17.0218 14.6316L18.4658 21.8992L12.0002 18.28L5.53456 21.8992L6.97862 14.6316L1.53857 9.60081L8.89669 8.72839L12.0002 2Z"
59
+ stroke="currentColor"
60
+ stroke-width="2.4"
61
+ stroke-linejoin="round"
62
+ />
63
+ </svg>
64
+ );
65
+
66
+ export const IconButton: StoryObj<typeof IconButtonComponent> = {
67
+ args: {
68
+ children: icon,
69
+ disabled: false,
70
+ tooltip: {
71
+ content: "Rate Us",
72
+ },
73
+ },
74
+ };
75
+
76
+ export const Variant = () => {
77
+ return (
78
+ <div className="grid-wrapper" style={{gridTemplateColumns: "repeat(5, auto)"}}>
79
+ {variants.map(variant => (
80
+ <div key={variant} className="item-card">
81
+ <span className="item-card__title">{capitalizeFirstLetter(variant)}</span>
82
+ <IconButtonComponent variant={variant !== "default" ? variant : undefined}>
83
+ {icon}
84
+ </IconButtonComponent>
85
+ </div>
86
+ ))}
87
+ </div>
88
+ );
89
+ };
90
+
91
+ export const VariantDisabled = () => {
92
+ return (
93
+ <div className="grid-wrapper" style={{gridTemplateColumns: "repeat(5, auto)"}}>
94
+ {variants.map(variant => (
95
+ <div key={variant} className="item-card">
96
+ <span className="item-card__title">{capitalizeFirstLetter(variant)}</span>
97
+ <IconButtonComponent disabled variant={variant !== "default" ? variant : undefined}>
98
+ {icon}
99
+ </IconButtonComponent>
100
+ </div>
101
+ ))}
102
+ </div>
103
+ );
104
+ };
105
+
106
+ export const Size = () => {
107
+ return (
108
+ <div className="grid-wrapper" style={{gridTemplateColumns: "repeat(4, auto)"}}>
109
+ {sizes.map(size => (
110
+ <div key={size} className="item-card">
111
+ <span className="item-card__title">{capitalizeFirstLetter(size)}</span>
112
+ <IconButtonComponent
113
+ size={size !== "default" ? size : undefined}
114
+ variant={IconButtonVariant.Contained}
115
+ >
116
+ {icon}
117
+ </IconButtonComponent>
118
+ </div>
119
+ ))}
120
+ </div>
121
+ );
122
+ };
123
+
124
+ export const Radius = () => {
125
+ return (
126
+ <div className="grid-wrapper" style={{gridTemplateColumns: "repeat(4, auto)"}}>
127
+ {radius.map(radius => (
128
+ <div key={radius} className="item-card">
129
+ <span className="item-card__title">{capitalizeFirstLetter(radius)}</span>
130
+ <IconButtonComponent
131
+ radius={radius !== "default" ? radius : undefined}
132
+ variant={IconButtonVariant.Contained}
133
+ >
134
+ {icon}
135
+ </IconButtonComponent>
136
+ </div>
137
+ ))}
138
+ </div>
139
+ );
140
+ };
141
+
142
+ export const VariantSize = () => {
143
+ return (
144
+ <div className="grid-wrapper" style={{gridTemplateColumns: "repeat(4, auto)"}}>
145
+ {variants.map(variant =>
146
+ sizes.map(size => (
147
+ <div key={`${variant}-${size}`}>
148
+ <IconButtonComponent
149
+ variant={variant !== "default" ? variant : undefined}
150
+ size={size !== "default" ? size : undefined}
151
+ >
152
+ {icon}
153
+ </IconButtonComponent>
154
+ </div>
155
+ ))
156
+ )}
157
+ </div>
158
+ );
159
+ };
160
+
161
+ export const SizeRadius = () => {
162
+ return (
163
+ <div className="grid-wrapper" style={{gridTemplateColumns: "repeat(4, auto)"}}>
164
+ {sizes.map(size =>
165
+ radius.map(radius => (
166
+ <div key={`${radius}-${size}`} className="item-card">
167
+ <IconButtonComponent
168
+ variant={IconButtonVariant.Contained}
169
+ radius={radius !== "default" ? radius : undefined}
170
+ size={size !== "default" ? size : undefined}
171
+ >
172
+ {icon}
173
+ </IconButtonComponent>
174
+ </div>
175
+ ))
176
+ )}
177
+ </div>
178
+ );
179
+ };
@@ -0,0 +1,65 @@
1
+ import React, {FC, memo} from "react";
2
+ import classnames from "classnames";
3
+
4
+ import {Tooltip, TooltipProps} from "../Tooltip";
5
+ import {BaseButton, BaseButtonProps} from "../BaseButton";
6
+
7
+ import {useComponentProps} from "../../providers";
8
+
9
+ import styles from "./icon-button.module.scss";
10
+
11
+ export enum IconButtonVariant {
12
+ Contained = "contained",
13
+ Outlined = "outlined",
14
+ Ghost = "ghost",
15
+ }
16
+
17
+ export enum IconButtonSize {
18
+ Small = "small",
19
+ Medium = "medium",
20
+ Large = "large",
21
+ }
22
+
23
+ export enum IconButtonRadius {
24
+ Small = "small",
25
+ Medium = "medium",
26
+ Large = "large",
27
+ }
28
+
29
+ export interface IconButtonProps extends BaseButtonProps {
30
+ size?: IconButtonSize;
31
+ radius?: IconButtonRadius;
32
+ variant?: IconButtonVariant;
33
+ tooltip?: Omit<TooltipProps, "children">;
34
+ }
35
+
36
+ const IconButton: FC<IconButtonProps> = props => {
37
+ const {size, radius, variant, tooltip, className, children, ...other} = {
38
+ ...useComponentProps("iconButton"),
39
+ ...props,
40
+ };
41
+
42
+ const iconButton = (
43
+ <BaseButton
44
+ {...other}
45
+ className={classnames(
46
+ styles["icon-button"],
47
+ {
48
+ [styles[`icon-button--${variant}`]]: variant,
49
+ [styles[`icon-button--${size}-size`]]: size,
50
+ [styles[`icon-button--${radius}-radius`]]: radius,
51
+ },
52
+ className
53
+ )}
54
+ >
55
+ {children}
56
+ </BaseButton>
57
+ );
58
+ if (tooltip) {
59
+ return <Tooltip {...tooltip}>{iconButton}</Tooltip>;
60
+ }
61
+
62
+ return iconButton;
63
+ };
64
+
65
+ export default memo(IconButton);
@@ -0,0 +1,86 @@
1
+ $root: icon-button;
2
+
3
+ .#{$root} {
4
+ border-radius: var(--icon-button-border-radius, 100%);
5
+ padding: var(--icon-button-padding, 5px);
6
+ width: var(--icon-button-size, 25px);
7
+ height: var(--icon-button-size, 25px);
8
+ color: var(--icon-button-color);
9
+ background: none;
10
+
11
+ &:hover:not(:disabled) {
12
+ color: var(--icon-button-color-hover);
13
+ }
14
+
15
+ &:active:not(:disabled) {
16
+ transform: scale(var(--icon-button-scale, 0.95));
17
+ }
18
+
19
+ &:disabled {
20
+ opacity: var(--icon-button-disabled-opacity, 0.75);
21
+ cursor: default;
22
+ }
23
+
24
+ // Variants
25
+ &--contained {
26
+ color: var(--icon-button-contained-color, var(--icon-button-color));
27
+ background: var(--icon-button-contained-bg-color, var(--icon-button-bg-color));
28
+
29
+ &:hover:not(:disabled) {
30
+ color: var(--icon-button-contained-color-hover, var(--icon-button-color-hover));
31
+ background-color: var(--icon-button-contained-bg-color-hover, var(--icon-button-bg-color-hover));
32
+ }
33
+ }
34
+
35
+ &--outlined {
36
+ color: var(--icon-button-outlined-color, var(--icon-button-color));
37
+ border-width: var(--icon-button-border-width, 1px);
38
+ border-color: var(--icon-button-border-color);
39
+ border-style: solid;
40
+ background: none;
41
+
42
+ &:hover:not(:disabled) {
43
+ color: var(--icon-button-outlined-color-hover, var(--icon-button-color-hover));
44
+ background-color: var(--icon-button-outlined-bg-color-hover, var(--icon-button-bg-color-hover));
45
+ }
46
+ }
47
+
48
+ &--ghost {
49
+ color: var(--icon-button-ghost-color, var(--icon-button-color));
50
+ background-color: transparent;
51
+
52
+ &:hover:not(:disabled) {
53
+ color: var(--icon-button-ghost-color-hover, var(--icon-button-color-hover));
54
+ background-color: var(--icon-button-ghost-bg-color-hover, var(--icon-button-bg-color-hover));
55
+ }
56
+ }
57
+
58
+ // Sizes
59
+ &--small-size {
60
+ width: var(--icon-button-size-sm, 20px);
61
+ height: var(--icon-button-size-sm, 20px);
62
+ }
63
+
64
+ &--medium-size {
65
+ width: var(--icon-button-size-md, 35px);
66
+ height: var(--icon-button-size-md, 35px);
67
+ }
68
+
69
+ &--large-size {
70
+ width: var(--icon-button-size-lg, 45px);
71
+ height: var(--icon-button-size-lg, 45px);
72
+ }
73
+
74
+ //Radius
75
+ &--small-radius {
76
+ border-radius: var(--icon-button-border-radius-sm, 20%);
77
+ }
78
+
79
+ &--medium-radius {
80
+ border-radius: var(--icon-button-border-radius-md, 30%);
81
+ }
82
+
83
+ &--large-radius {
84
+ border-radius: var(--icon-button-border-radius-lg, 40%);
85
+ }
86
+ }
@@ -0,0 +1,2 @@
1
+ export {default as IconButton, IconButtonVariant, IconButtonRadius, IconButtonSize} from "./IconButton";
2
+ export type {IconButtonProps} from "./IconButton";