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.
Files changed (145) 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/eslint.config.js +39 -0
  9. package/package.json +77 -2
  10. package/src/components/Avatar/Avatar.stories.tsx +118 -0
  11. package/src/components/Avatar/Avatar.tsx +65 -0
  12. package/src/components/Avatar/avatar.module.scss +77 -0
  13. package/src/components/Avatar/index.ts +2 -0
  14. package/src/components/BaseButton/BaseButton.tsx +36 -0
  15. package/src/components/BaseButton/base-button.module.scss +24 -0
  16. package/src/components/BaseButton/index.ts +2 -0
  17. package/src/components/Button/Button.stories.tsx +148 -0
  18. package/src/components/Button/Button.tsx +73 -0
  19. package/src/components/Button/button.module.scss +140 -0
  20. package/src/components/Button/index.ts +2 -0
  21. package/src/components/Checkbox/Checkbox.stories.tsx +180 -0
  22. package/src/components/Checkbox/Checkbox.tsx +71 -0
  23. package/src/components/Checkbox/checkbox.module.scss +82 -0
  24. package/src/components/Checkbox/index.ts +2 -0
  25. package/src/components/Dialog/Dialog.tsx +125 -0
  26. package/src/components/Dialog/dialog.module.scss +55 -0
  27. package/src/components/Dialog/index.ts +2 -0
  28. package/src/components/Drawer/Drawer.stories.tsx +89 -0
  29. package/src/components/Drawer/Drawer.tsx +57 -0
  30. package/src/components/Drawer/drawer.module.scss +170 -0
  31. package/src/components/Drawer/index.ts +2 -0
  32. package/src/components/Footer/Footer.stories.tsx +118 -0
  33. package/src/components/Footer/Footer.tsx +58 -0
  34. package/src/components/Footer/footer.module.scss +44 -0
  35. package/src/components/Footer/index.ts +2 -0
  36. package/src/components/Header/Header.stories.tsx +49 -0
  37. package/src/components/Header/Header.tsx +73 -0
  38. package/src/components/Header/header.module.scss +56 -0
  39. package/src/components/Header/index.ts +2 -0
  40. package/src/components/Highlight/Highlight.stories.tsx +83 -0
  41. package/src/components/Highlight/Highlight.tsx +40 -0
  42. package/src/components/Highlight/highlight.module.scss +47 -0
  43. package/src/components/Highlight/index.ts +2 -0
  44. package/src/components/Icon/Icon.tsx +46 -0
  45. package/src/components/Icon/icon.module.scss +17 -0
  46. package/src/components/Icon/index.ts +2 -0
  47. package/src/components/IconButton/IconButton.stories.tsx +179 -0
  48. package/src/components/IconButton/IconButton.tsx +65 -0
  49. package/src/components/IconButton/icon-button.module.scss +86 -0
  50. package/src/components/IconButton/index.ts +2 -0
  51. package/src/components/Layout/Layout.stories.tsx +88 -0
  52. package/src/components/Layout/Provider.tsx +47 -0
  53. package/src/components/Layout/context.ts +24 -0
  54. package/src/components/Layout/index.ts +2 -0
  55. package/src/components/Layout/layout.module.scss +17 -0
  56. package/src/components/List/List.stories.tsx +81 -0
  57. package/src/components/List/List.tsx +24 -0
  58. package/src/components/List/index.ts +2 -0
  59. package/src/components/List/list.module.scss +8 -0
  60. package/src/components/ListItem/ListItem.tsx +75 -0
  61. package/src/components/ListItem/index.ts +2 -0
  62. package/src/components/ListItem/list-item.module.scss +36 -0
  63. package/src/components/Modal/Modal.stories.tsx +95 -0
  64. package/src/components/Modal/Modal.tsx +94 -0
  65. package/src/components/Modal/index.ts +2 -0
  66. package/src/components/Modal/modal.module.scss +97 -0
  67. package/src/components/Odometer/Odometer.stories.tsx +66 -0
  68. package/src/components/Odometer/Odometer.tsx +45 -0
  69. package/src/components/Odometer/hooks/useOdometer.tsx +24 -0
  70. package/src/components/Odometer/index.ts +3 -0
  71. package/src/components/Odometer/odometer.module.scss +81 -0
  72. package/src/components/Odometer/odometr.d.ts +9 -0
  73. package/src/components/ScrollArea/ScrollArea.stories.tsx +58 -0
  74. package/src/components/ScrollArea/ScrollArea.tsx +63 -0
  75. package/src/components/ScrollArea/index.ts +2 -0
  76. package/src/components/ScrollArea/scroll-area.module.scss +54 -0
  77. package/src/components/SvgSprite/SvgSprite.tsx +21 -0
  78. package/src/components/SvgSprite/index.ts +2 -0
  79. package/src/components/Switch/Switch.stories.tsx +25 -0
  80. package/src/components/Switch/Switch.tsx +23 -0
  81. package/src/components/Switch/index.ts +2 -0
  82. package/src/components/Switch/switch.module.scss +65 -0
  83. package/src/components/Tag/Tag.stories.tsx +157 -0
  84. package/src/components/Tag/Tag.tsx +71 -0
  85. package/src/components/Tag/index.ts +2 -0
  86. package/src/components/Tag/tag.module.scss +118 -0
  87. package/src/components/TextArea/TextArea.stories.tsx +145 -0
  88. package/src/components/TextArea/TextArea.tsx +143 -0
  89. package/src/components/TextArea/index.ts +2 -0
  90. package/src/components/TextArea/text-area.module.scss +88 -0
  91. package/src/components/TextField/TextField.stories.tsx +177 -0
  92. package/src/components/TextField/TextField.tsx +162 -0
  93. package/src/components/TextField/index.ts +2 -0
  94. package/src/components/TextField/text-field.module.scss +129 -0
  95. package/src/components/Toast/Toast.stories.tsx +209 -0
  96. package/src/components/Toast/Toast.tsx +142 -0
  97. package/src/components/Toast/index.ts +2 -0
  98. package/src/components/Toast/toast.module.scss +267 -0
  99. package/src/components/Tooltip/Tooltip.stories.tsx +80 -0
  100. package/src/components/Tooltip/Tooltip.tsx +79 -0
  101. package/src/components/Tooltip/index.ts +2 -0
  102. package/src/components/Tooltip/tooltip.module.scss +93 -0
  103. package/src/components/View/View.stories.tsx +47 -0
  104. package/src/components/View/View.tsx +68 -0
  105. package/src/components/View/index.ts +2 -0
  106. package/src/components/View/view.module.scss +38 -0
  107. package/src/components/ViewDrawer/ViewDrawer.stories.tsx +75 -0
  108. package/src/components/ViewDrawer/ViewDrawer.tsx +24 -0
  109. package/src/components/ViewDrawer/index.ts +2 -0
  110. package/src/components/ViewModal/ViewModal.stories.tsx +68 -0
  111. package/src/components/ViewModal/ViewModal.tsx +24 -0
  112. package/src/components/ViewModal/index.ts +2 -0
  113. package/src/components/index.ts +29 -0
  114. package/src/components/types.ts +65 -0
  115. package/src/config/default.ts +3 -0
  116. package/src/config/index.ts +26 -0
  117. package/src/declaration.d.ts +8 -0
  118. package/src/index.ts +3 -0
  119. package/src/plugin/builder/ConfigBuilder.ts +32 -0
  120. package/src/plugin/builder/StyleBuilder.ts +34 -0
  121. package/src/plugin/builder/virtual.config.ts +7 -0
  122. package/src/plugin/finder/ConfigFinder.ts +26 -0
  123. package/src/plugin/finder/Finder.ts +76 -0
  124. package/src/plugin/finder/StyleFinder.ts +23 -0
  125. package/src/plugin/index.ts +70 -0
  126. package/src/plugin/types.ts +8 -0
  127. package/src/providers/UIProvider.tsx +26 -0
  128. package/src/providers/icons/IconsProvider.tsx +34 -0
  129. package/src/providers/icons/context.ts +22 -0
  130. package/src/providers/icons/index.ts +3 -0
  131. package/src/providers/index.ts +3 -0
  132. package/src/providers/theme/ThemeProvider.tsx +39 -0
  133. package/src/providers/theme/context.ts +30 -0
  134. package/src/providers/theme/index.ts +2 -0
  135. package/src/providers/theme/styles/default.scss +95 -0
  136. package/src/providers/theme/styles/reset.css +111 -0
  137. package/src/styles/mixins.scss +23 -0
  138. package/src/types/theme.ts +4 -0
  139. package/src/utils/index.ts +2 -0
  140. package/src/utils/react.ts +21 -0
  141. package/src/utils/utils.ts +12 -0
  142. package/tsconfig.json +18 -0
  143. package/vite.config.ts +11 -0
  144. package/vitest.workspace.ts +19 -0
  145. package/components/Button/index.ts +0 -0
@@ -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";
@@ -0,0 +1,88 @@
1
+ import {useState} from "react";
2
+ import {Meta} from "@storybook/react";
3
+
4
+ import {hideInTable} from "../../utils";
5
+
6
+ import {Header, Footer, Button, ScrollArea, IconButton, IconButtonVariant, IconButtonSize} from "../index";
7
+
8
+ import {LayoutProvider, useLayout} from "./index";
9
+
10
+ const meta: Meta<typeof LayoutProvider> = {
11
+ title: "Components/Layout",
12
+ component: LayoutProvider,
13
+ tags: ["autodocs"],
14
+ argTypes: {
15
+ children: hideInTable,
16
+ },
17
+ };
18
+
19
+ export default meta;
20
+
21
+ export const Layout = () => {
22
+ return (
23
+ <LayoutProvider>
24
+ <App />
25
+ </LayoutProvider>
26
+ );
27
+ };
28
+
29
+ const App = () => {
30
+ const [arr, setArr] = useState(Array.from(Array(5)));
31
+ const {expand, collapse} = useLayout();
32
+
33
+ return (
34
+ <div
35
+ style={{
36
+ background: "var(--bg-secondary-color)",
37
+ flex: 1,
38
+ display: "flex",
39
+ flexDirection: "column",
40
+ borderRadius: "10px",
41
+ overflow: "hidden",
42
+ }}
43
+ >
44
+ <Header title={"Layout"} />
45
+ <div style={{display: "flex", justifyContent: "space-evenly", alignItems: "center", padding: "5px 10px"}}>
46
+ <IconButton
47
+ size={IconButtonSize.Medium}
48
+ variant={IconButtonVariant.Contained}
49
+ onClick={() => setArr([...arr, "item"])}
50
+ >
51
+
52
+ </IconButton>
53
+ <Button onClick={() => expand()}>Expand</Button>
54
+ <Button onClick={() => collapse()}>Collapse</Button>
55
+
56
+ <IconButton
57
+ size={IconButtonSize.Medium}
58
+ variant={IconButtonVariant.Contained}
59
+ onClick={() => setArr(arr.slice(0, -1))}
60
+ >
61
+
62
+ </IconButton>
63
+ </div>
64
+ <div style={{display: "flex", justifyContent: "space-evenly", padding: "5px 10px"}}>
65
+ <Button onClick={() => expand({height: 700})}>700px height</Button>
66
+ <Button onClick={() => expand({height: 700, width: 500})}>700x500px</Button>
67
+ <Button onClick={() => expand({width: 500})}>500px width</Button>
68
+ </div>
69
+ <ScrollArea
70
+ xOffset={10}
71
+ type="always"
72
+ style={{flex: 1, display: "flex", flexDirection: "column", overflow: "hidden"}}
73
+ >
74
+ <div style={{flex: 1}}>
75
+ {arr.map((_, index) => (
76
+ <div
77
+ key={index}
78
+ style={{padding: "10px 20px", textAlign: "center", color: "var(--text-secondary-color)"}}
79
+ >
80
+ Item {++index}
81
+ </div>
82
+ ))}
83
+ </div>
84
+ </ScrollArea>
85
+ <Footer left="❤️" right="⭐" shadow style={{paddingTop: "10px"}} />
86
+ </div>
87
+ );
88
+ };
@@ -0,0 +1,47 @@
1
+ import React, {ComponentProps, FC, PropsWithChildren, useCallback, useState} from "react";
2
+
3
+ import {expandType, LayoutContext} from "./context";
4
+
5
+ import classnames from "classnames";
6
+
7
+ import styles from "./layout.module.scss";
8
+
9
+ const Provider: FC<PropsWithChildren<ComponentProps<"div">>> = ({children, className, style, ...props}) => {
10
+ const [isExpanded, setExpanded] = useState(false);
11
+ const [height, setHeight] = useState<number | string | undefined>(undefined);
12
+ const [width, setWidth] = useState<number | string | undefined>(undefined);
13
+
14
+ const expand = useCallback((value?: expandType) => {
15
+ setHeight(value?.height);
16
+ setWidth(value?.width);
17
+ setExpanded(true);
18
+ }, []);
19
+
20
+ const collapse = useCallback(() => {
21
+ setHeight(undefined);
22
+ setWidth(undefined);
23
+ setExpanded(false);
24
+ }, []);
25
+
26
+ return (
27
+ <LayoutContext.Provider value={{isExpanded, expand, collapse}}>
28
+ <div
29
+ style={{minHeight: height, minWidth: width, ...style}}
30
+ className={classnames(
31
+ styles["layout"],
32
+ {
33
+ [styles["layout--expanded"]]: isExpanded,
34
+ },
35
+ className
36
+ )}
37
+ {...props}
38
+ >
39
+ {children}
40
+ </div>
41
+ </LayoutContext.Provider>
42
+ );
43
+ };
44
+
45
+ Provider.displayName = "ViewportProvider";
46
+
47
+ export default Provider;
@@ -0,0 +1,24 @@
1
+ import {createContext, useContext} from "react";
2
+
3
+ export type expandType = {
4
+ height?: number | string;
5
+ width?: number | string;
6
+ };
7
+
8
+ export interface LayoutContract {
9
+ isExpanded?: boolean;
10
+
11
+ expand(value?: expandType): void;
12
+
13
+ collapse(): void;
14
+ }
15
+
16
+ export const LayoutContext = createContext<LayoutContract>({
17
+ isExpanded: false,
18
+ expand() {},
19
+ collapse() {},
20
+ });
21
+
22
+ LayoutContext.displayName = "LayoutContext";
23
+
24
+ export const useLayout = () => useContext(LayoutContext);
@@ -0,0 +1,2 @@
1
+ export {default as LayoutProvider} from "./Provider";
2
+ export {useLayout} from "./context";
@@ -0,0 +1,17 @@
1
+ .layout {
2
+ display: flex;
3
+ flex-direction: column;
4
+ overflow: hidden;
5
+ min-width: var(--min-width);
6
+ max-width: var(--max-width);
7
+ min-height: var(--min-height);
8
+ max-height: var(--max-height);
9
+ transition:
10
+ min-height var(--transition-speed-md) ease-in-out,
11
+ min-width var(--transition-speed-md) ease-in-out;
12
+
13
+ &--expanded {
14
+ min-height: var(--max-height);
15
+ min-width: var(--max-width);
16
+ }
17
+ }
@@ -0,0 +1,81 @@
1
+ import {Meta, StoryObj} from "@storybook/react";
2
+
3
+ import {hideInTable} from "../../utils";
4
+
5
+ import {ListItem, Button, ButtonSize, ButtonVariant, Avatar, AvatarSize} from "../index";
6
+
7
+ import ListComponent from "./List";
8
+
9
+ const mockListItems = [
10
+ {
11
+ id: 1,
12
+ avatar: "https://images.unsplash.com/photo-1492633423870-43d1cd2775eb?&w=128&h=128&dpr=2&q=80",
13
+ name: "John Doe",
14
+ role: "React Developer",
15
+ action: "Add",
16
+ },
17
+ {
18
+ id: 2,
19
+ avatar: "https://images.unsplash.com/photo-1492633423870-43d1cd2775eb?&w=128&h=128&dpr=2&q=80",
20
+ name: "Emily Smith",
21
+ role: "UI/UX Designer",
22
+ action: "Invite",
23
+ },
24
+ {
25
+ id: 3,
26
+ avatar: "https://images.unsplash.com/photo-1492633423870-43d1cd2775eb?&w=128&h=128&dpr=2&q=80",
27
+ name: "Michael Johnson",
28
+ role: "Project Manager",
29
+ action: "Add",
30
+ },
31
+ {
32
+ id: 4,
33
+ avatar: "https://images.unsplash.com/photo-1492633423870-43d1cd2775eb?&w=128&h=128&dpr=2&q=80",
34
+ name: "Sarah Brown",
35
+ role: "QA Engineer",
36
+ action: "Invite",
37
+ },
38
+ {
39
+ id: 5,
40
+ avatar: "https://images.unsplash.com/photo-1492633423870-43d1cd2775eb?&w=128&h=128&dpr=2&q=80",
41
+ name: "David Wilson",
42
+ role: "DevOps Engineer",
43
+ action: "Invite",
44
+ },
45
+ ];
46
+
47
+ const meta: Meta<typeof ListComponent> = {
48
+ title: "Components/List",
49
+ component: ListComponent,
50
+ tags: ["autodocs"],
51
+ argTypes: {
52
+ children: hideInTable,
53
+ className: hideInTable,
54
+ style: hideInTable,
55
+ },
56
+ };
57
+
58
+ export default meta;
59
+
60
+ type Story = StoryObj<typeof ListComponent>;
61
+
62
+ export const List: Story = {
63
+ args: {
64
+ children: mockListItems.map(({id, avatar, name, role, action}) => (
65
+ <ListItem
66
+ key={id}
67
+ left={<Avatar src={avatar} size={AvatarSize.Small} />}
68
+ primary={<span style={{fontWeight: 500}}>{name}</span>}
69
+ secondary={<span style={{fontSize: "14px"}}>{role}</span>}
70
+ right={
71
+ <Button variant={ButtonVariant.Contained} size={ButtonSize.Small}>
72
+ {action}
73
+ </Button>
74
+ }
75
+ />
76
+ )),
77
+ style: {
78
+ minWidth: "300px",
79
+ },
80
+ },
81
+ };
@@ -0,0 +1,24 @@
1
+ import React, {ComponentProps, forwardRef, memo, ReactElement} from "react";
2
+ import classnames from "classnames";
3
+
4
+ import {useComponentProps} from "../../providers";
5
+
6
+ import {ListItemProps} from "../ListItem";
7
+
8
+ import styles from "./list.module.scss";
9
+
10
+ export interface ListProps extends Omit<ComponentProps<"ul">, "children"> {
11
+ children: ReactElement<ListItemProps> | ReactElement<ListItemProps>[];
12
+ }
13
+
14
+ const List = forwardRef<HTMLUListElement, ListProps>((props, ref) => {
15
+ const {children, className, ...other} = {...useComponentProps("list"), ...props};
16
+
17
+ return (
18
+ <ul {...other} ref={ref} className={classnames(styles["list"], className)}>
19
+ {children}
20
+ </ul>
21
+ );
22
+ });
23
+
24
+ export default memo(List);
@@ -0,0 +1,2 @@
1
+ export {default as List} from "./List";
2
+ export type {ListProps} from "./List";
@@ -0,0 +1,8 @@
1
+ .list {
2
+ display: flex;
3
+ flex-direction: column;
4
+ gap: 10px;
5
+ padding: 0;
6
+ margin: 0;
7
+ list-style: none;
8
+ }