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,140 @@
1
+ $root: button;
2
+
3
+ .#{$root} {
4
+ font-family: var(--button-font-family, var(--font-family)), sans-serif;
5
+ font-weight: var(--button-font-weight, 500);
6
+ font-size: var(--button-font-size, var(--font-size, 14px));
7
+ letter-spacing: var(--button-letter-spacing, 0.5px);
8
+ line-height: var(--button-line-height, var(--line-height, 14px));
9
+ height: var(--button-height, 34px);
10
+ border-radius: var(--button-border-radius, 10px);
11
+ padding: var(--button-padding, 0 16px);
12
+
13
+ &:active:not(:disabled) {
14
+ transform: scale(var(--button-scale, 0.98));
15
+ }
16
+
17
+ &:disabled {
18
+ opacity: var(--button-disabled-opacity, 0.75);
19
+ cursor: default;
20
+ }
21
+
22
+ // Variants
23
+ &--contained {
24
+ color: var(--button-contained-text-color, var(--bg-primary-color));
25
+ background: var(--button-contained-bg-color, var(--text-primary-color));
26
+
27
+ &.#{$root}--primary-color {
28
+ color: #fff;
29
+ background: var(--primary-color);
30
+ }
31
+
32
+ &.#{$root}--secondary-color {
33
+ color: #fff;
34
+ background: var(--secondary-color);
35
+ }
36
+
37
+ &.#{$root}--accent-color {
38
+ color: #fff;
39
+ background: var(--accent-color);
40
+ }
41
+ }
42
+
43
+ &--outlined {
44
+ color: var(--button-outlined-text-color, var(--text-primary-color));
45
+ border: 1px solid var(--button-outlined-border-color, var(--button-outlined-text-color, var(--text-primary-color)));
46
+ background: none;
47
+
48
+ &:hover {
49
+ background-color: var(--button-outlined-bg-color-hover);
50
+ }
51
+
52
+ &:active {
53
+ background-color: var(--button-outlined-bg-color-active);
54
+ }
55
+
56
+ &.#{$root}--primary-color {
57
+ color: var(--primary-color);
58
+ border-color: var(--button-outlined-border-primary-color);
59
+ }
60
+
61
+ &.#{$root}--secondary-color {
62
+ color: var(--secondary-color);
63
+ border-color: var(--button-outlined-border-secondary-color);
64
+ }
65
+
66
+ &.#{$root}--accent-color {
67
+ color: var(--accent-color);
68
+ border-color: var(--button-outlined-border-accent-color);
69
+ }
70
+ }
71
+
72
+ &--text {
73
+ color: var(--button-text-text-color, var(--text-primary-color));
74
+ background-color: transparent;
75
+
76
+ &:hover {
77
+ color: var(--button-text-text-color-hover, var(--text-secondary-color));
78
+ }
79
+
80
+ &:active {
81
+ color: var(--button-text-text-color-active, var(--text-secondary-color));
82
+ }
83
+
84
+ &.#{$root}--primary-color {
85
+ color: var(--primary-color);
86
+ }
87
+
88
+ &.#{$root}--secondary-color {
89
+ color: var(--secondary-color);
90
+ }
91
+
92
+ &.#{$root}--accent-color {
93
+ color: var(--accent-color);
94
+ }
95
+ }
96
+
97
+ // Sizes
98
+ &--small-size {
99
+ height: var(--button-height-sm, 24px);
100
+ font-size: var(--button-font-size-sm, 12px);
101
+ }
102
+
103
+ &--medium-size {
104
+ height: var(--button-height-md, 44px);
105
+ font-size: var(--button-font-size-sm, 16px);
106
+ }
107
+
108
+ &--large-size {
109
+ height: var(--button-height-lg, 54px);
110
+ min-width: 95px;
111
+ font-size: var(--button-font-size-sm, 18px);
112
+ }
113
+
114
+ //Radius
115
+ &--small-radius {
116
+ border-radius: var(--button-border-radius-sm, 5px);
117
+ }
118
+
119
+ &--medium-radius {
120
+ border-radius: var(--button-border-radius-md, 12px);
121
+ }
122
+
123
+ &--large-radius {
124
+ border-radius: var(--button-border-radius-lg, 15px);
125
+ }
126
+
127
+ &--full-radius {
128
+ border-radius: var(--button-height, 999px);
129
+ }
130
+
131
+ &__text {
132
+ position: relative;
133
+ z-index: 3;
134
+ white-space: nowrap;
135
+ text-overflow: ellipsis;
136
+ overflow: hidden;
137
+ max-width: var(--button-max-width, 160px);
138
+ line-height: initial;
139
+ }
140
+ }
@@ -0,0 +1,2 @@
1
+ export {default as Button, ButtonVariant, ButtonRadius, ButtonColor, ButtonSize} from "./Button";
2
+ export type {ButtonProps} from "./Button";
@@ -0,0 +1,180 @@
1
+ import {useState} from "react";
2
+ import {Meta, StoryObj} from "@storybook/react";
3
+
4
+ import {capitalizeFirstLetter, hideInTable} from "../../utils";
5
+
6
+ import CheckboxComponent, {CheckboxRadius, CheckboxSize, CheckboxVariant, CheckedState} from "./Checkbox";
7
+
8
+ const variants: (CheckboxVariant | "default")[] = ["default", CheckboxVariant.Classic, CheckboxVariant.Soft];
9
+ const size: (CheckboxSize | "default")[] = [CheckboxSize.Small, "default", CheckboxSize.Medium, CheckboxSize.Large];
10
+ const radius: (CheckboxRadius | "default")[] = [CheckboxRadius.Small, "default", CheckboxRadius.Large];
11
+
12
+ const meta: Meta<typeof CheckboxComponent> = {
13
+ title: "Components/Checkbox",
14
+ component: CheckboxComponent,
15
+ tags: ["autodocs"],
16
+ argTypes: {
17
+ checked: {
18
+ options: [true, false, "indeterminate"],
19
+ control: {type: "select"},
20
+ },
21
+ variant: {
22
+ options: variants,
23
+ control: {type: "select"},
24
+ },
25
+ size: {
26
+ options: size,
27
+ control: {type: "select"},
28
+ },
29
+ radius: {
30
+ options: radius,
31
+ control: {type: "select"},
32
+ },
33
+
34
+ checkedIcon: hideInTable,
35
+ indeterminateIcon: hideInTable,
36
+ children: hideInTable,
37
+ className: hideInTable,
38
+ indicatorClassName: hideInTable,
39
+ },
40
+ };
41
+
42
+ export default meta;
43
+
44
+ export const Checkbox: StoryObj<typeof CheckboxComponent> = {
45
+ args: {
46
+ checked: true,
47
+ disabled: false,
48
+ variant: CheckboxVariant.Classic,
49
+ },
50
+ };
51
+
52
+ export const CheckboxClickable = () => {
53
+ const [checked, setChecked] = useState<CheckedState>("indeterminate");
54
+
55
+ return <CheckboxComponent variant={CheckboxVariant.Classic} checked={checked} onCheckedChange={setChecked} />;
56
+ };
57
+
58
+ export const Variant = () => {
59
+ return (
60
+ <div className="grid-wrapper" style={{gridTemplateColumns: "repeat(3, auto)"}}>
61
+ {variants.map(variant => (
62
+ <span key={variant} className="item-card__title">
63
+ {capitalizeFirstLetter(variant)}
64
+ </span>
65
+ ))}
66
+
67
+ {variants.map(variant => (
68
+ <div key={variant} className="item-card">
69
+ <CheckboxComponent variant={variant !== "default" ? variant : undefined} checked={false} />
70
+ </div>
71
+ ))}
72
+
73
+ {variants.map(variant => (
74
+ <div key={variant} className="item-card">
75
+ <CheckboxComponent variant={variant !== "default" ? variant : undefined} checked={true} />
76
+ </div>
77
+ ))}
78
+
79
+ {variants.map(variant => (
80
+ <div key={variant} className="item-card">
81
+ <CheckboxComponent variant={variant !== "default" ? variant : undefined} checked="indeterminate" />
82
+ </div>
83
+ ))}
84
+ </div>
85
+ );
86
+ };
87
+
88
+ export const VariantDisabled = () => {
89
+ return (
90
+ <div className="grid-wrapper" style={{gridTemplateColumns: "repeat(3, auto)"}}>
91
+ {variants.map(variant => (
92
+ <span key={variant} className="item-card__title">
93
+ {capitalizeFirstLetter(variant)}
94
+ </span>
95
+ ))}
96
+
97
+ {variants.map(variant => (
98
+ <div key={variant} className="item-card">
99
+ <CheckboxComponent disabled variant={variant !== "default" ? variant : undefined} checked={false} />
100
+ </div>
101
+ ))}
102
+
103
+ {variants.map(variant => (
104
+ <div key={variant} className="item-card">
105
+ <CheckboxComponent disabled variant={variant !== "default" ? variant : undefined} checked={true} />
106
+ </div>
107
+ ))}
108
+
109
+ {variants.map(variant => (
110
+ <div key={variant} className="item-card">
111
+ <CheckboxComponent
112
+ disabled
113
+ variant={variant !== "default" ? variant : undefined}
114
+ checked="indeterminate"
115
+ />
116
+ </div>
117
+ ))}
118
+ </div>
119
+ );
120
+ };
121
+
122
+ export const Size = () => {
123
+ return (
124
+ <div className="grid-wrapper" style={{gridTemplateColumns: "repeat(4, auto)"}}>
125
+ {size.map(size => (
126
+ <span key={size} className="item-card__title">
127
+ {capitalizeFirstLetter(size)}
128
+ </span>
129
+ ))}
130
+
131
+ {size.map(size => (
132
+ <div key={size} className="item-card">
133
+ <CheckboxComponent size={size !== "default" ? size : undefined} checked={false} />
134
+ </div>
135
+ ))}
136
+
137
+ {size.map(size => (
138
+ <div key={size} className="item-card">
139
+ <CheckboxComponent size={size !== "default" ? size : undefined} checked={true} />
140
+ </div>
141
+ ))}
142
+
143
+ {size.map(size => (
144
+ <div key={size} className="item-card">
145
+ <CheckboxComponent size={size !== "default" ? size : undefined} checked="indeterminate" />
146
+ </div>
147
+ ))}
148
+ </div>
149
+ );
150
+ };
151
+
152
+ export const Radius = () => {
153
+ return (
154
+ <div className="grid-wrapper" style={{gridTemplateColumns: "repeat(3, auto)"}}>
155
+ {radius.map(radius => (
156
+ <span key={radius} className="item-card__title">
157
+ {capitalizeFirstLetter(radius)}
158
+ </span>
159
+ ))}
160
+
161
+ {radius.map(radius => (
162
+ <div key={radius} className="item-card">
163
+ <CheckboxComponent radius={radius !== "default" ? radius : undefined} checked={false} />
164
+ </div>
165
+ ))}
166
+
167
+ {radius.map(radius => (
168
+ <div key={radius} className="item-card">
169
+ <CheckboxComponent radius={radius !== "default" ? radius : undefined} checked={true} />
170
+ </div>
171
+ ))}
172
+
173
+ {radius.map(radius => (
174
+ <div key={radius} className="item-card">
175
+ <CheckboxComponent radius={radius !== "default" ? radius : undefined} checked="indeterminate" />
176
+ </div>
177
+ ))}
178
+ </div>
179
+ );
180
+ };
@@ -0,0 +1,71 @@
1
+ import React, {FC, memo, ReactElement} from "react";
2
+ import classnames from "classnames";
3
+ import {CheckboxProps as CheckboxRootProps, Indicator, Root} from "@radix-ui/react-checkbox";
4
+
5
+ import {useComponentProps} from "../../providers";
6
+
7
+ import styles from "./checkbox.module.scss";
8
+
9
+ export type {CheckedState} from "@radix-ui/react-checkbox";
10
+
11
+ export enum CheckboxVariant {
12
+ Classic = "classic",
13
+ Soft = "soft",
14
+ }
15
+
16
+ export enum CheckboxSize {
17
+ Small = "small",
18
+ Medium = "medium",
19
+ Large = "large",
20
+ }
21
+
22
+ export enum CheckboxRadius {
23
+ Small = "small",
24
+ Large = "large",
25
+ }
26
+
27
+ export interface CheckboxProps extends CheckboxRootProps {
28
+ indicatorClassName?: string;
29
+ size?: CheckboxSize;
30
+ radius?: CheckboxRadius;
31
+ variant?: CheckboxVariant;
32
+ checkedIcon?: ReactElement;
33
+ indeterminateIcon?: ReactElement;
34
+ }
35
+
36
+ const Checkbox: FC<CheckboxProps> = props => {
37
+ const {
38
+ checked,
39
+ size,
40
+ radius,
41
+ variant,
42
+ className,
43
+ indicatorClassName,
44
+ checkedIcon = "✔",
45
+ indeterminateIcon = "―",
46
+ ...other
47
+ } = {...useComponentProps("checkbox"), ...props};
48
+
49
+ return (
50
+ <Root
51
+ {...other}
52
+ checked={checked}
53
+ className={classnames(
54
+ styles["checkbox"],
55
+ {
56
+ [styles[`checkbox--${variant}`]]: variant,
57
+ [styles[`checkbox--${radius}-radius`]]: radius,
58
+ [styles[`checkbox--${size}-size`]]: size,
59
+ },
60
+ className
61
+ )}
62
+ >
63
+ <Indicator className={classnames(styles["checkbox__indicator"], indicatorClassName)}>
64
+ {checked === "indeterminate" && indeterminateIcon}
65
+ {checked === true && checkedIcon}
66
+ </Indicator>
67
+ </Root>
68
+ );
69
+ };
70
+
71
+ export default memo(Checkbox);
@@ -0,0 +1,82 @@
1
+ $root: checkbox;
2
+
3
+ .#{$root} {
4
+ display: flex;
5
+ align-items: center;
6
+ justify-content: center;
7
+ cursor: pointer;
8
+ padding: 2px;
9
+ width: var(--checkbox-size, 18px);
10
+ height: var(--checkbox-size, 18px);
11
+ border-radius: var(--checkbox-border-radius, 4px);
12
+ color: var(--checkbox-color, #333);
13
+ border: var(--checkbox-border-width, 1px) solid var(--checkbox-border-color, #999);
14
+ will-change: background, color;
15
+ transition:
16
+ background var(--transition-speed-sm),
17
+ color var(--transition-speed-sm);
18
+
19
+ &:disabled {
20
+ opacity: var(--checkbox-disabled-opacity, 0.6);
21
+ cursor: default;
22
+ }
23
+
24
+ &:active:not(:disabled) {
25
+ transform: scale(var(--checkbox-scale, 0.98));
26
+ }
27
+
28
+ //Variants
29
+ &--classic {
30
+ color: var(--checkbox-classic-color, white);
31
+ background: var(--checkbox-classic-bg-color);
32
+ border: var(--checkbox-classic-border-width, 1px) solid var(--checkbox-classic-border-color, #999);
33
+
34
+ &[data-state="checked"],
35
+ &[data-state="indeterminate"] {
36
+ background: var(--checkbox-checked-bg-color, var(--primary-color));
37
+ border: none;
38
+ }
39
+ }
40
+
41
+ &--soft {
42
+ color: var(--checkbox-soft-color, white);
43
+ background: var(--checkbox-soft-bg-color, var(--secondary-color));
44
+ border: none;
45
+ }
46
+
47
+ //sizes
48
+ &--small-size {
49
+ width: var(--checkbox-size-sm, 16px);
50
+ height: var(--checkbox-size-sm, 16px);
51
+ }
52
+
53
+ &--medium-size {
54
+ width: var(--checkbox-size-md, 20px);
55
+ height: var(--checkbox-size-md, 20px);
56
+ }
57
+
58
+ &--large-size {
59
+ width: var(--checkbox-size-lg, 22px);
60
+ height: var(--checkbox-size-lg, 22px);
61
+ }
62
+
63
+ //Radius
64
+ &--small-radius {
65
+ border-radius: var(--checkbox-border-radius-sm, 2px);
66
+ }
67
+
68
+ &--large-radius {
69
+ border-radius: var(--checkbox-border-radius-lg, 6px);
70
+ }
71
+
72
+ &__indicator {
73
+ display: flex;
74
+ align-items: center;
75
+ justify-content: center;
76
+
77
+ & svg {
78
+ width: 100%;
79
+ height: 100%;
80
+ }
81
+ }
82
+ }
@@ -0,0 +1,2 @@
1
+ export {default as Checkbox, CheckboxVariant, CheckboxSize, CheckboxRadius} from "./Checkbox";
2
+ export type {CheckboxProps, CheckedState} from "./Checkbox";
@@ -0,0 +1,125 @@
1
+ import React, {FC, memo, useEffect, useRef} from "react";
2
+ import classnames from "classnames";
3
+ import {
4
+ Content,
5
+ Description,
6
+ DialogContentProps,
7
+ DialogPortalProps,
8
+ DialogProps as DialogRootProps,
9
+ Overlay,
10
+ Portal,
11
+ Root,
12
+ Title,
13
+ } from "@radix-ui/react-dialog";
14
+ import {VisuallyHidden} from "radix-ui";
15
+
16
+ import {useComponentProps} from "../../providers";
17
+ import {cloneOrCreateElement} from "../../utils";
18
+
19
+ import styles from "./dialog.module.scss";
20
+
21
+ export interface DialogProps extends DialogRootProps, DialogPortalProps, DialogContentProps {
22
+ speed?: number;
23
+ description?: string;
24
+ fullscreen?: boolean;
25
+ className?: string;
26
+ overlayClassName?: string;
27
+ childrenClassName?: string;
28
+ }
29
+
30
+ export const dialogPropsKeys = new Set<keyof DialogProps>([
31
+ // Dialog keys
32
+ "speed",
33
+ "description",
34
+ "fullscreen",
35
+ "className",
36
+ "overlayClassName",
37
+ "childrenClassName",
38
+
39
+ // Extended Dialog keys
40
+ "open",
41
+ "defaultOpen",
42
+ "onOpenChange",
43
+ "modal",
44
+ "container",
45
+ "title",
46
+ ]);
47
+
48
+ const Dialog: FC<DialogProps> = props => {
49
+ const {
50
+ speed = 200,
51
+ open,
52
+ defaultOpen,
53
+ onOpenChange,
54
+ modal,
55
+ children,
56
+ container,
57
+ title,
58
+ description,
59
+ className,
60
+ overlayClassName,
61
+ childrenClassName,
62
+ ...other
63
+ } = {...useComponentProps("dialog"), ...props};
64
+
65
+ const timeoutId = useRef<ReturnType<typeof setTimeout> | undefined>(undefined);
66
+ const intervalId = useRef<ReturnType<typeof setInterval> | undefined>(undefined);
67
+
68
+ useEffect(() => {
69
+ clearInterval(intervalId.current);
70
+ clearTimeout(timeoutId.current);
71
+
72
+ if (open) {
73
+ const scrollbarWidth = window.innerWidth - document.documentElement.clientWidth;
74
+ document.body.style.overflow = "hidden";
75
+ document.body.style.boxSizing = "border-box";
76
+ document.body.style.setProperty("padding-right", `${scrollbarWidth}px`, "important");
77
+ } else {
78
+ intervalId.current = setInterval(() => {
79
+ const scrollbarWidth = window.innerWidth - document.documentElement.clientWidth;
80
+ if (scrollbarWidth) {
81
+ document.body.style.overflow = "";
82
+ document.body.style.paddingRight = "";
83
+ clearInterval(intervalId.current);
84
+ }
85
+ }, 10);
86
+
87
+ timeoutId.current = setTimeout(() => {
88
+ clearInterval(intervalId.current);
89
+ }, speed + 100);
90
+ }
91
+
92
+ return () => {
93
+ document.body.style.overflow = "";
94
+ };
95
+ }, [open, speed]);
96
+
97
+ return (
98
+ <Root open={open} defaultOpen={defaultOpen} onOpenChange={onOpenChange} modal={modal}>
99
+ <Portal container={container}>
100
+ <Overlay
101
+ className={classnames(styles["dialog-overlay"], overlayClassName)}
102
+ style={{animationDuration: `${speed}ms`}}
103
+ />
104
+ <Content
105
+ className={classnames(styles["dialog-content"], className)}
106
+ style={{animationDuration: `${speed}ms`}}
107
+ {...other}
108
+ >
109
+ <VisuallyHidden.Root>
110
+ <Title>{title}</Title>
111
+ <Description>{description}</Description>
112
+ </VisuallyHidden.Root>
113
+
114
+ {cloneOrCreateElement(
115
+ children,
116
+ {className: classnames(styles["dialog-children"], childrenClassName)},
117
+ "div"
118
+ )}
119
+ </Content>
120
+ </Portal>
121
+ </Root>
122
+ );
123
+ };
124
+
125
+ export default memo(Dialog);
@@ -0,0 +1,55 @@
1
+ $root: dialog;
2
+
3
+ .#{$root} {
4
+ &-overlay {
5
+ position: fixed;
6
+ inset: 0;
7
+ z-index: 999;
8
+ background-color: var(--dialog-overlay-bg-color, #111);
9
+ opacity: var(--dialog-animation-overlay-opacity, 0.9);
10
+ animation-timing-function: ease-in-out;
11
+
12
+ &[data-state="open"] {
13
+ animation-name: overlayShow;
14
+ }
15
+
16
+ &[data-state="closed"] {
17
+ animation-name: overlayHide;
18
+ }
19
+ }
20
+
21
+ &-content {
22
+ box-sizing: border-box;
23
+ position: fixed;
24
+ z-index: 9999;
25
+ transition:
26
+ background-color var(--transition-speed-sm),
27
+ color var(--transition-speed-sm);
28
+ animation-timing-function: ease-in-out;
29
+ }
30
+
31
+ &-children {
32
+ display: flex;
33
+ flex-direction: column;
34
+ width: 100%;
35
+ height: 100%;
36
+ }
37
+ }
38
+
39
+ @keyframes overlayShow {
40
+ from {
41
+ opacity: 0;
42
+ }
43
+ to {
44
+ opacity: var(--dialog-animation-overlay-opacity, 0.9);
45
+ }
46
+ }
47
+
48
+ @keyframes overlayHide {
49
+ from {
50
+ opacity: var(--dialog-animation-overlay-opacity, 0.9);
51
+ }
52
+ to {
53
+ opacity: 0;
54
+ }
55
+ }
@@ -0,0 +1,2 @@
1
+ export {default as Dialog, dialogPropsKeys} from "./Dialog";
2
+ export type {DialogProps} from "./Dialog";