norma-library 0.4.9 → 0.5.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 (246) hide show
  1. package/.babelrc.json +1 -1
  2. package/.husky/commit-msg +4 -0
  3. package/.prettierignore +11 -0
  4. package/.prettierrc.json +20 -0
  5. package/CHANGELOG.md +0 -0
  6. package/CONTRIBUTING.md +0 -0
  7. package/README.md +42 -0
  8. package/commitlint.config.js +1 -0
  9. package/dist/Button/index.d.ts +9 -0
  10. package/dist/Button/types.d.ts +18 -0
  11. package/dist/Card/Card.d.ts +3 -0
  12. package/dist/Card/CardHeader.d.ts +3 -0
  13. package/dist/Card/index.d.ts +4 -0
  14. package/dist/Card/styles.d.ts +546 -0
  15. package/dist/Card/types.d.ts +8 -0
  16. package/dist/esm/components/Accordion.d.ts +2 -2
  17. package/dist/esm/components/Accordion.js +8 -8
  18. package/dist/esm/components/Accordion.js.map +1 -1
  19. package/dist/esm/components/Avatar.d.ts +2 -2
  20. package/dist/esm/components/Avatar.js +7 -7
  21. package/dist/esm/components/Avatar.js.map +1 -1
  22. package/dist/esm/components/Badge.d.ts +2 -2
  23. package/dist/esm/components/Badge.js +5 -5
  24. package/dist/esm/components/Badge.js.map +1 -1
  25. package/dist/esm/components/Button.d.ts +2 -2
  26. package/dist/esm/components/Button.js +10 -10
  27. package/dist/esm/components/Button.js.map +1 -1
  28. package/dist/esm/components/Card.d.ts +3 -3
  29. package/dist/esm/components/Card.js +8 -8
  30. package/dist/esm/components/Card.js.map +1 -1
  31. package/dist/esm/components/ChatMessage.d.ts +2 -2
  32. package/dist/esm/components/ChatMessage.js +35 -35
  33. package/dist/esm/components/ChatMessage.js.map +1 -1
  34. package/dist/esm/components/CheckBox.d.ts +2 -2
  35. package/dist/esm/components/CheckBox.js +5 -5
  36. package/dist/esm/components/CheckBox.js.map +1 -1
  37. package/dist/esm/components/DataGrid/base/dropdown.d.ts +2 -2
  38. package/dist/esm/components/DataGrid/base/dropdown.js +32 -32
  39. package/dist/esm/components/DataGrid/base/dropdown.js.map +1 -1
  40. package/dist/esm/components/DataGrid/base/number-filter.d.ts +2 -2
  41. package/dist/esm/components/DataGrid/base/number-filter.js +21 -21
  42. package/dist/esm/components/DataGrid/base/sorting.d.ts +2 -2
  43. package/dist/esm/components/DataGrid/base/sorting.js +1 -1
  44. package/dist/esm/components/DataGrid/base/sorting.js.map +1 -1
  45. package/dist/esm/components/DataGrid/icons.d.ts +1 -1
  46. package/dist/esm/components/DataGrid/icons.js +1 -1
  47. package/dist/esm/components/DataGrid/icons.js.map +1 -1
  48. package/dist/esm/components/DataGrid/index.d.ts +2 -2
  49. package/dist/esm/components/DataGrid/index.js +35 -44
  50. package/dist/esm/components/DataGrid/index.js.map +1 -1
  51. package/dist/esm/components/DataGrid/shared.d.ts +1 -1
  52. package/dist/esm/components/DataGrid/shared.js +19 -32
  53. package/dist/esm/components/DataGrid/shared.js.map +1 -1
  54. package/dist/esm/components/DataGrid/styled.d.ts +2 -2
  55. package/dist/esm/components/DataGrid/styled.js +35 -35
  56. package/dist/esm/components/DataGrid/styled.js.map +1 -1
  57. package/dist/esm/components/DatePicker.d.ts +5 -5
  58. package/dist/esm/components/DatePicker.js +37 -37
  59. package/dist/esm/components/DatePicker.js.map +1 -1
  60. package/dist/esm/components/DropDown.d.ts +2 -2
  61. package/dist/esm/components/DropDown.js +6 -6
  62. package/dist/esm/components/DropDown.js.map +1 -1
  63. package/dist/esm/components/IconButton.d.ts +2 -2
  64. package/dist/esm/components/IconButton.js +7 -7
  65. package/dist/esm/components/IconButton.js.map +1 -1
  66. package/dist/esm/components/Icons.d.ts +2 -2
  67. package/dist/esm/components/Icons.js +10 -10
  68. package/dist/esm/components/Icons.js.map +1 -1
  69. package/dist/esm/components/Modal.d.ts +2 -2
  70. package/dist/esm/components/Modal.js +8 -8
  71. package/dist/esm/components/Modal.js.map +1 -1
  72. package/dist/esm/components/Paper.d.ts +2 -2
  73. package/dist/esm/components/Paper.js +5 -5
  74. package/dist/esm/components/Paper.js.map +1 -1
  75. package/dist/esm/components/ProgressBar.d.ts +2 -2
  76. package/dist/esm/components/ProgressBar.js +11 -11
  77. package/dist/esm/components/ProgressBar.js.map +1 -1
  78. package/dist/esm/components/RadioGroup.d.ts +2 -2
  79. package/dist/esm/components/RadioGroup.js +7 -7
  80. package/dist/esm/components/RadioGroup.js.map +1 -1
  81. package/dist/esm/components/RangerSlider.d.ts +2 -2
  82. package/dist/esm/components/RangerSlider.js +31 -31
  83. package/dist/esm/components/RangerSlider.js.map +1 -1
  84. package/dist/esm/components/Select.d.ts +2 -2
  85. package/dist/esm/components/Select.js +14 -14
  86. package/dist/esm/components/Select.js.map +1 -1
  87. package/dist/esm/components/Svgs.d.ts +1 -1
  88. package/dist/esm/components/Svgs.js +1 -1
  89. package/dist/esm/components/Svgs.js.map +1 -1
  90. package/dist/esm/components/Tabs.d.ts +2 -2
  91. package/dist/esm/components/Tabs.js +25 -26
  92. package/dist/esm/components/Tabs.js.map +1 -1
  93. package/dist/esm/components/Tag.d.ts +2 -2
  94. package/dist/esm/components/Tag.js +8 -8
  95. package/dist/esm/components/Tag.js.map +1 -1
  96. package/dist/esm/components/TextField.d.ts +2 -2
  97. package/dist/esm/components/TextField.js +8 -8
  98. package/dist/esm/components/TextField.js.map +1 -1
  99. package/dist/esm/components/TimeLine.d.ts +2 -2
  100. package/dist/esm/components/TimeLine.js +20 -20
  101. package/dist/esm/components/TimeLine.js.map +1 -1
  102. package/dist/esm/components/TimePicker.d.ts +8 -8
  103. package/dist/esm/components/TimePicker.js +43 -43
  104. package/dist/esm/components/TimePicker.js.map +1 -1
  105. package/dist/esm/components/index.d.ts +23 -23
  106. package/dist/esm/components/index.js +23 -23
  107. package/dist/esm/helpers/alignments.js +7 -7
  108. package/dist/esm/helpers/borders.js +11 -11
  109. package/dist/esm/helpers/colors.js +41 -41
  110. package/dist/esm/helpers/index.d.ts +5 -5
  111. package/dist/esm/helpers/index.js +5 -5
  112. package/dist/esm/helpers/sizes.d.ts +1 -1
  113. package/dist/esm/helpers/sizes.js +39 -39
  114. package/dist/esm/helpers/sizes.js.map +1 -1
  115. package/dist/esm/index.d.ts +17 -17
  116. package/dist/esm/index.js +17 -17
  117. package/dist/esm/interfaces/Accordion.d.ts +3 -3
  118. package/dist/esm/interfaces/Avatar.d.ts +6 -6
  119. package/dist/esm/interfaces/Badge.d.ts +7 -7
  120. package/dist/esm/interfaces/Button.d.ts +5 -5
  121. package/dist/esm/interfaces/Card.d.ts +3 -3
  122. package/dist/esm/interfaces/ChatMessage.d.ts +1 -1
  123. package/dist/esm/interfaces/CheckBox.d.ts +10 -10
  124. package/dist/esm/interfaces/DataGrid.d.ts +4 -4
  125. package/dist/esm/interfaces/DatePicker.d.ts +3 -3
  126. package/dist/esm/interfaces/DropDown.d.ts +4 -4
  127. package/dist/esm/interfaces/IconButton.d.ts +5 -5
  128. package/dist/esm/interfaces/Icons.d.ts +3 -3
  129. package/dist/esm/interfaces/Modal.d.ts +3 -3
  130. package/dist/esm/interfaces/Paper.d.ts +4 -4
  131. package/dist/esm/interfaces/ProgressBar.d.ts +5 -5
  132. package/dist/esm/interfaces/RadioGroup.d.ts +4 -4
  133. package/dist/esm/interfaces/RangerSlider.d.ts +8 -8
  134. package/dist/esm/interfaces/Select.d.ts +3 -3
  135. package/dist/esm/interfaces/Tabs.d.ts +3 -3
  136. package/dist/esm/interfaces/Tag.d.ts +5 -5
  137. package/dist/esm/interfaces/TextField.d.ts +12 -12
  138. package/dist/esm/interfaces/TimeLine.d.ts +3 -3
  139. package/dist/esm/interfaces/TimePicker.d.ts +3 -3
  140. package/dist/esm/interfaces/index.d.ts +23 -23
  141. package/dist/esm/interfaces/index.js +23 -23
  142. package/dist/esm/types/index.d.ts +41 -41
  143. package/dist/esm/types/index.js +2 -2
  144. package/dist/esm/types/index.js.map +1 -1
  145. package/dist/index.d.ts +2 -0
  146. package/dist/index.es.js +6992 -0
  147. package/dist/index.es.js.map +1 -0
  148. package/dist/index.umd.js +266 -0
  149. package/dist/index.umd.js.map +1 -0
  150. package/dist/vite.svg +1 -0
  151. package/docs/index.md +118 -0
  152. package/package.json +64 -8
  153. package/src/components/Accordion.tsx +47 -64
  154. package/src/components/Avatar.tsx +22 -29
  155. package/src/components/Badge.tsx +19 -22
  156. package/src/components/Button.tsx +12 -19
  157. package/src/components/Card.tsx +44 -47
  158. package/src/components/ChatMessage.tsx +87 -89
  159. package/src/components/CheckBox.tsx +8 -19
  160. package/src/components/DataGrid/allData.json +2918 -2918
  161. package/src/components/DataGrid/base/dropdown.tsx +212 -235
  162. package/src/components/DataGrid/base/number-filter.tsx +43 -43
  163. package/src/components/DataGrid/base/sorting.tsx +29 -35
  164. package/src/components/DataGrid/icons.tsx +53 -61
  165. package/src/components/DataGrid/index.tsx +254 -319
  166. package/src/components/DataGrid/shared.ts +154 -179
  167. package/src/components/DataGrid/styled.ts +96 -102
  168. package/src/components/DataGrid/styles/dropdown.module.css +86 -86
  169. package/src/components/DataGrid/styles/number-filter.module.css +16 -16
  170. package/src/components/DataGrid/styles/styles.module.css +107 -107
  171. package/src/components/DatePicker.tsx +73 -84
  172. package/src/components/DropDown.tsx +31 -38
  173. package/src/components/IconButton.tsx +12 -29
  174. package/src/components/Icons.tsx +82 -87
  175. package/src/components/Modal.tsx +114 -123
  176. package/src/components/Paper.tsx +19 -22
  177. package/src/components/ProgressBar.tsx +54 -63
  178. package/src/components/RadioGroup.tsx +47 -55
  179. package/src/components/RangerSlider.tsx +70 -81
  180. package/src/components/Select.tsx +82 -98
  181. package/src/components/Svgs.tsx +498 -522
  182. package/src/components/Tabs.tsx +111 -140
  183. package/src/components/Tag.tsx +37 -45
  184. package/src/components/TextField.tsx +11 -22
  185. package/src/components/TimeLine.tsx +93 -103
  186. package/src/components/TimePicker.tsx +84 -95
  187. package/src/components/index.ts +23 -23
  188. package/src/helpers/alignments.ts +7 -7
  189. package/src/helpers/borders.ts +11 -11
  190. package/src/helpers/colors.ts +42 -42
  191. package/src/helpers/index.ts +5 -5
  192. package/src/helpers/sizes.ts +39 -46
  193. package/src/index.ts +17 -17
  194. package/src/interfaces/Accordion.ts +12 -12
  195. package/src/interfaces/Avatar.tsx +15 -18
  196. package/src/interfaces/Badge.ts +19 -32
  197. package/src/interfaces/Button.ts +5 -10
  198. package/src/interfaces/Card.ts +11 -11
  199. package/src/interfaces/ChatMessage.ts +12 -12
  200. package/src/interfaces/CheckBox.ts +12 -18
  201. package/src/interfaces/DataGrid.ts +46 -51
  202. package/src/interfaces/DatePicker.ts +13 -13
  203. package/src/interfaces/DropDown.ts +14 -14
  204. package/src/interfaces/IconButton.ts +5 -10
  205. package/src/interfaces/Icons.ts +17 -17
  206. package/src/interfaces/Modal.ts +15 -15
  207. package/src/interfaces/Paper.ts +12 -12
  208. package/src/interfaces/ProgressBar.ts +18 -25
  209. package/src/interfaces/RadioGroup.ts +22 -28
  210. package/src/interfaces/RangerSlider.ts +21 -32
  211. package/src/interfaces/Select.ts +17 -17
  212. package/src/interfaces/Tabs.ts +19 -24
  213. package/src/interfaces/Tag.ts +17 -17
  214. package/src/interfaces/TextField.ts +14 -34
  215. package/src/interfaces/TimeLine.ts +11 -16
  216. package/src/interfaces/TimePicker.ts +13 -13
  217. package/src/interfaces/index.ts +23 -23
  218. package/src/sample-data.json +178 -178
  219. package/src/stories/Accordion.stories.tsx +65 -65
  220. package/src/stories/Avatar.stories.tsx +123 -139
  221. package/src/stories/Badge.stories.tsx +39 -47
  222. package/src/stories/Button.stories.tsx +18 -26
  223. package/src/stories/Card.stories.tsx +40 -55
  224. package/src/stories/ChatMessage.stories.tsx +84 -85
  225. package/src/stories/CheckBox.stories.tsx +17 -23
  226. package/src/stories/DataGrid.stories.tsx +28 -28
  227. package/src/stories/DatePicker.stories.tsx +50 -77
  228. package/src/stories/DropDown.stories.tsx +57 -57
  229. package/src/stories/IconButton.stories.tsx +78 -114
  230. package/src/stories/Modal.stories.tsx +190 -190
  231. package/src/stories/Paper.stories.tsx +53 -53
  232. package/src/stories/ProgressBar.stories.tsx +95 -139
  233. package/src/stories/RadioGroup.stories.tsx +21 -28
  234. package/src/stories/RangerSlider.stories.tsx +58 -68
  235. package/src/stories/Select.stories.tsx +100 -128
  236. package/src/stories/Tabs.stories.tsx +62 -62
  237. package/src/stories/Tag.stories.tsx +56 -74
  238. package/src/stories/TextField.stories.tsx +54 -189
  239. package/src/stories/TimeLine.stories.tsx +35 -43
  240. package/src/stories/TimePicker.stories.tsx +87 -113
  241. package/src/types/index.ts +90 -155
  242. package/tsconfig.json +1 -1
  243. package/buildcache/front-end +0 -1
  244. package/norma-library.tar +0 -0
  245. package/postcss.config.js +0 -6
  246. package/tailwind.config.js +0 -58
@@ -1,65 +1,65 @@
1
- import React from "react";
2
-
3
- import type { Meta, StoryObj } from "@storybook/react";
4
- import { Accordion } from "../components";
5
- import { DataAccordion } from "../types";
6
- import { Typography } from "@mui/material";
7
-
8
- const data: DataAccordion[] = [
9
- {
10
- label: "Accordion 1",
11
- id: "panel-1",
12
- children: (
13
- <Typography>
14
- Lorem ipsum dolor sit amet, consectetur adipiscing elit. Suspendisse
15
- malesuada lacus ex, sit amet blandit leo lobortis eget.
16
- </Typography>
17
- ),
18
- },
19
- {
20
- label: "Accordion 2",
21
- id: "panel-2",
22
- children: (
23
- <Typography>
24
- Lorem ipsum dolor sit amet, consectetur adipiscing elit. Suspendisse
25
- malesuada lacus ex, sit amet blandit leo lobortis eget.
26
- </Typography>
27
- ),
28
- },
29
- ];
30
-
31
- const meta = {
32
- title: "Display/Accordion",
33
- component: Accordion,
34
- parameters: {
35
- layout: "centered",
36
- },
37
- tags: ["autodocs"],
38
- argTypes: {
39
- data: data,
40
- },
41
- } satisfies Meta<typeof Accordion>;
42
-
43
- export default meta;
44
-
45
- type Story = StoryObj<typeof meta>;
46
-
47
- export const AccordionBasic = () => {
48
- return (
49
- <div style={{ width: "480px", marginBottom: 30 }}>
50
- <Accordion data={data} />
51
- </div>
52
- );
53
- };
54
-
55
- AccordionBasic.storyName = "Accordion Basic";
56
-
57
- export const AccordionExpanded = () => {
58
- return (
59
- <div style={{ width: "480px", marginBottom: 30 }}>
60
- <Accordion data={data} defaultExpanded="panel-1" />
61
- </div>
62
- );
63
- };
64
-
65
- AccordionExpanded.storyName = "Accordion Expanded";
1
+ import React from 'react';
2
+
3
+ import type { Meta, StoryObj } from '@storybook/react';
4
+ import { Accordion } from '../components';
5
+ import { DataAccordion } from '../types';
6
+ import { Typography } from '@mui/material';
7
+
8
+ const data: DataAccordion[] = [
9
+ {
10
+ label: 'Accordion 1',
11
+ id: 'panel-1',
12
+ children: (
13
+ <Typography>
14
+ Lorem ipsum dolor sit amet, consectetur adipiscing elit. Suspendisse malesuada lacus ex, sit amet blandit leo
15
+ lobortis eget.
16
+ </Typography>
17
+ ),
18
+ },
19
+ {
20
+ label: 'Accordion 2',
21
+ id: 'panel-2',
22
+ children: (
23
+ <Typography>
24
+ Lorem ipsum dolor sit amet, consectetur adipiscing elit. Suspendisse malesuada lacus ex, sit amet blandit leo
25
+ lobortis eget.
26
+ </Typography>
27
+ ),
28
+ },
29
+ ];
30
+
31
+ const meta = {
32
+ title: 'Display/Accordion',
33
+ component: Accordion,
34
+ parameters: {
35
+ layout: 'centered',
36
+ },
37
+ tags: ['autodocs'],
38
+ argTypes: {
39
+ data: data,
40
+ },
41
+ } satisfies Meta<typeof Accordion>;
42
+
43
+ export default meta;
44
+
45
+ type Story = StoryObj<typeof meta>;
46
+
47
+ export const AccordionBasic = () => {
48
+ return (
49
+ <div style={{ width: '480px', marginBottom: 30 }}>
50
+ <Accordion data={data} />
51
+ </div>
52
+ );
53
+ };
54
+
55
+ AccordionBasic.storyName = 'Accordion Basic';
56
+
57
+ export const AccordionExpanded = () => {
58
+ return (
59
+ <div style={{ width: '480px', marginBottom: 30 }}>
60
+ <Accordion data={data} defaultExpanded="panel-1" />
61
+ </div>
62
+ );
63
+ };
64
+
65
+ AccordionExpanded.storyName = 'Accordion Expanded';
@@ -1,139 +1,123 @@
1
- import React from "react";
2
-
3
- import type { Meta } from "@storybook/react";
4
- import { Avatar, Icons } from "../components";
5
- import { AvatarGroup, Stack } from "@mui/material";
6
- import { green, pink } from "@mui/material/colors";
7
-
8
- const meta = {
9
- title: "Display/Avatar",
10
- component: Avatar,
11
- parameters: {
12
- layout: "centered",
13
- },
14
- tags: ["autodocs"],
15
- argTypes: {},
16
- } satisfies Meta<typeof Avatar>;
17
-
18
- export default meta;
19
-
20
- function stringToColor(string: string) {
21
- let hash = 0;
22
- let i;
23
-
24
- /* eslint-disable no-bitwise */
25
- for (i = 0; i < string.length; i += 1) {
26
- hash = string.charCodeAt(i) + ((hash << 5) - hash);
27
- }
28
-
29
- let color = "#";
30
-
31
- for (i = 0; i < 3; i += 1) {
32
- const value = (hash >> (i * 8)) & 0xff;
33
- color += `00${value.toString(16)}`.slice(-2);
34
- }
35
- /* eslint-enable no-bitwise */
36
-
37
- return color;
38
- }
39
-
40
- function stringAvatar(name: string) {
41
- return {
42
- sx: {
43
- bgcolor: stringToColor(name),
44
- },
45
- children: `${name.split(" ")[0][0]}${name.split(" ")[1][0]}`,
46
- };
47
- }
48
-
49
- export const AvatarBasic = () => {
50
- return (
51
- <>
52
- <Avatar src="https://mui.com/static/images/avatar/2.jpg" />
53
- </>
54
- );
55
- };
56
-
57
- export const AvatarVariants = () => {
58
- return (
59
- <Stack direction="row" spacing={2}>
60
- <Avatar
61
- src="https://mui.com/static/images/avatar/1.jpg"
62
- variant="square"
63
- />
64
- <Avatar
65
- src="https://mui.com/static/images/avatar/2.jpg"
66
- variant="rounded"
67
- />
68
- <Avatar src="https://mui.com/static/images/avatar/3.jpg" />
69
- </Stack>
70
- );
71
- };
72
-
73
- export const AvatarLetters = () => {
74
- return (
75
- <>
76
- <Stack direction="row" spacing={2}>
77
- <Avatar {...stringAvatar("Kent Dodds")} />
78
- <Avatar {...stringAvatar("Jed Watson")} />
79
- <Avatar {...stringAvatar("Tim Neutkens")} />
80
- </Stack>
81
- </>
82
- );
83
- };
84
-
85
- export const AvatarSizes = () => {
86
- return (
87
- <>
88
- <Stack direction="row" spacing={2}>
89
- <Avatar
90
- src="https://mui.com/static/images/avatar/1.jpg"
91
- variant="square"
92
- sx={{ width: 24, height: 24 }}
93
- />
94
- <Avatar
95
- src="https://mui.com/static/images/avatar/2.jpg"
96
- variant="rounded"
97
- />
98
- <Avatar
99
- src="https://mui.com/static/images/avatar/3.jpg"
100
- sx={{ width: 56, height: 56 }}
101
- />
102
- </Stack>
103
- </>
104
- );
105
- };
106
-
107
- export const AvatarWidthIcons = () => {
108
- return (
109
- <>
110
- <Stack direction="row" spacing={2}>
111
- <Avatar>
112
- <Icons icon="user" color="white" />
113
- </Avatar>
114
- <Avatar sx={{ bgcolor: pink[500] }}>
115
- <Icons icon="starOutlined" color="white" />
116
- </Avatar>
117
- <Avatar sx={{ bgcolor: green[500] }}>
118
- <Icons icon="chartBar" color="white" />
119
- </Avatar>
120
- </Stack>
121
- </>
122
- );
123
- };
124
-
125
- export const AvatarGrouped = () => {
126
- return (
127
- <>
128
- <Stack direction="row" spacing={2}>
129
- <AvatarGroup max={4}>
130
- <Avatar src="https://mui.com/static/images/avatar/1.jpg" />
131
- <Avatar src="https://mui.com/static/images/avatar/2.jpg" />
132
- <Avatar src="https://mui.com/static/images/avatar/3.jpg" />
133
- <Avatar src="https://mui.com/static/images/avatar/4.jpg" />
134
- <Avatar src="https://mui.com/static/images/avatar/5.jpg" />
135
- </AvatarGroup>
136
- </Stack>
137
- </>
138
- );
139
- };
1
+ import React from 'react';
2
+
3
+ import type { Meta } from '@storybook/react';
4
+ import { Avatar, Icons } from '../components';
5
+ import { AvatarGroup, Stack } from '@mui/material';
6
+ import { green, pink } from '@mui/material/colors';
7
+
8
+ const meta = {
9
+ title: 'Display/Avatar',
10
+ component: Avatar,
11
+ parameters: {
12
+ layout: 'centered',
13
+ },
14
+ tags: ['autodocs'],
15
+ argTypes: {},
16
+ } satisfies Meta<typeof Avatar>;
17
+
18
+ export default meta;
19
+
20
+ function stringToColor(string: string) {
21
+ let hash = 0;
22
+ let i;
23
+
24
+ /* eslint-disable no-bitwise */
25
+ for (i = 0; i < string.length; i += 1) {
26
+ hash = string.charCodeAt(i) + ((hash << 5) - hash);
27
+ }
28
+
29
+ let color = '#';
30
+
31
+ for (i = 0; i < 3; i += 1) {
32
+ const value = (hash >> (i * 8)) & 0xff;
33
+ color += `00${value.toString(16)}`.slice(-2);
34
+ }
35
+ /* eslint-enable no-bitwise */
36
+
37
+ return color;
38
+ }
39
+
40
+ function stringAvatar(name: string) {
41
+ return {
42
+ sx: {
43
+ bgcolor: stringToColor(name),
44
+ },
45
+ children: `${name.split(' ')[0][0]}${name.split(' ')[1][0]}`,
46
+ };
47
+ }
48
+
49
+ export const AvatarBasic = () => {
50
+ return (
51
+ <>
52
+ <Avatar src="https://mui.com/static/images/avatar/2.jpg" />
53
+ </>
54
+ );
55
+ };
56
+
57
+ export const AvatarVariants = () => {
58
+ return (
59
+ <Stack direction="row" spacing={2}>
60
+ <Avatar src="https://mui.com/static/images/avatar/1.jpg" variant="square" />
61
+ <Avatar src="https://mui.com/static/images/avatar/2.jpg" variant="rounded" />
62
+ <Avatar src="https://mui.com/static/images/avatar/3.jpg" />
63
+ </Stack>
64
+ );
65
+ };
66
+
67
+ export const AvatarLetters = () => {
68
+ return (
69
+ <>
70
+ <Stack direction="row" spacing={2}>
71
+ <Avatar {...stringAvatar('Kent Dodds')} />
72
+ <Avatar {...stringAvatar('Jed Watson')} />
73
+ <Avatar {...stringAvatar('Tim Neutkens')} />
74
+ </Stack>
75
+ </>
76
+ );
77
+ };
78
+
79
+ export const AvatarSizes = () => {
80
+ return (
81
+ <>
82
+ <Stack direction="row" spacing={2}>
83
+ <Avatar src="https://mui.com/static/images/avatar/1.jpg" variant="square" sx={{ width: 24, height: 24 }} />
84
+ <Avatar src="https://mui.com/static/images/avatar/2.jpg" variant="rounded" />
85
+ <Avatar src="https://mui.com/static/images/avatar/3.jpg" sx={{ width: 56, height: 56 }} />
86
+ </Stack>
87
+ </>
88
+ );
89
+ };
90
+
91
+ export const AvatarWidthIcons = () => {
92
+ return (
93
+ <>
94
+ <Stack direction="row" spacing={2}>
95
+ <Avatar>
96
+ <Icons icon="user" color="white" />
97
+ </Avatar>
98
+ <Avatar sx={{ bgcolor: pink[500] }}>
99
+ <Icons icon="starOutlined" color="white" />
100
+ </Avatar>
101
+ <Avatar sx={{ bgcolor: green[500] }}>
102
+ <Icons icon="chartBar" color="white" />
103
+ </Avatar>
104
+ </Stack>
105
+ </>
106
+ );
107
+ };
108
+
109
+ export const AvatarGrouped = () => {
110
+ return (
111
+ <>
112
+ <Stack direction="row" spacing={2}>
113
+ <AvatarGroup max={4}>
114
+ <Avatar src="https://mui.com/static/images/avatar/1.jpg" />
115
+ <Avatar src="https://mui.com/static/images/avatar/2.jpg" />
116
+ <Avatar src="https://mui.com/static/images/avatar/3.jpg" />
117
+ <Avatar src="https://mui.com/static/images/avatar/4.jpg" />
118
+ <Avatar src="https://mui.com/static/images/avatar/5.jpg" />
119
+ </AvatarGroup>
120
+ </Stack>
121
+ </>
122
+ );
123
+ };
@@ -1,47 +1,39 @@
1
- import React from "react";
2
-
3
- import type { Meta } from "@storybook/react";
4
- import { Avatar, Badge, Icons } from "../components";
5
- import { AvatarGroup, Stack } from "@mui/material";
6
-
7
- const meta = {
8
- title: "Display/Badge",
9
- component: Badge,
10
- parameters: {
11
- layout: "centered",
12
- },
13
- tags: ["autodocs"],
14
- argTypes: {},
15
- } satisfies Meta<typeof Badge>;
16
-
17
- export default meta;
18
-
19
- export const BadgeBasic = () => {
20
- return (
21
- <>
22
- <Badge badgeContent={4} color="primary">
23
- <Icons icon="user" />
24
- </Badge>
25
- </>
26
- );
27
- };
28
-
29
- export const BadgeColors = () => {
30
- return (
31
- <Stack direction="row" spacing={2}>
32
- {[
33
- "primary",
34
- "secondary",
35
- "default",
36
- "error",
37
- "info",
38
- "success",
39
- "warning",
40
- ].map((color, key) => (
41
- <Badge badgeContent={4} color={color} key={key}>
42
- <Icons icon="user" />
43
- </Badge>
44
- ))}
45
- </Stack>
46
- );
47
- };
1
+ import React from 'react';
2
+
3
+ import type { Meta } from '@storybook/react';
4
+ import { Avatar, Badge, Icons } from '../components';
5
+ import { AvatarGroup, Stack } from '@mui/material';
6
+
7
+ const meta = {
8
+ title: 'Display/Badge',
9
+ component: Badge,
10
+ parameters: {
11
+ layout: 'centered',
12
+ },
13
+ tags: ['autodocs'],
14
+ argTypes: {},
15
+ } satisfies Meta<typeof Badge>;
16
+
17
+ export default meta;
18
+
19
+ export const BadgeBasic = () => {
20
+ return (
21
+ <>
22
+ <Badge badgeContent={4} color="primary">
23
+ <Icons icon="user" />
24
+ </Badge>
25
+ </>
26
+ );
27
+ };
28
+
29
+ export const BadgeColors = () => {
30
+ return (
31
+ <Stack direction="row" spacing={2}>
32
+ {['primary', 'secondary', 'default', 'error', 'info', 'success', 'warning'].map((color, key) => (
33
+ <Badge badgeContent={4} color={color} key={key}>
34
+ <Icons icon="user" />
35
+ </Badge>
36
+ ))}
37
+ </Stack>
38
+ );
39
+ };
@@ -1,27 +1,19 @@
1
- import React from "react";
2
- import { Button } from "../components/Button";
3
- import type { Meta, StoryObj } from "@storybook/react";
4
- import { ButtonVariant, SizeVariant, ColorVariant } from "../types";
1
+ import React from 'react';
2
+ import { Button } from '../components/Button';
3
+ import type { Meta, StoryObj } from '@storybook/react';
4
+ import { ButtonVariant, SizeVariant, ColorVariant } from '../types';
5
5
 
6
- const sizes: SizeVariant[] = ["small", "medium", "large"];
7
- const variants: ButtonVariant[] = ["text", "outlined", "contained"];
8
- const colors: ColorVariant[] = [
9
- "inherit",
10
- "primary",
11
- "secondary",
12
- "success",
13
- "error",
14
- "info",
15
- "warning",
16
- ];
6
+ const sizes: SizeVariant[] = ['small', 'medium', 'large'];
7
+ const variants: ButtonVariant[] = ['text', 'outlined', 'contained'];
8
+ const colors: ColorVariant[] = ['inherit', 'primary', 'secondary', 'success', 'error', 'info', 'warning'];
17
9
 
18
10
  const meta = {
19
- title: "Layout/Button",
11
+ title: 'Layout/Button',
20
12
  component: Button,
21
13
  parameters: {
22
- layout: "centered",
14
+ layout: 'centered',
23
15
  },
24
- tags: ["autodocs"],
16
+ tags: ['autodocs'],
25
17
  argTypes: {},
26
18
  } satisfies Meta<typeof Button>;
27
19
 
@@ -35,10 +27,10 @@ const defaultArgs = {
35
27
 
36
28
  export const Playground: Story = {
37
29
  args: {
38
- label: "My Button",
39
- size: "medium",
40
- color: "primary",
41
- variant: "contained",
30
+ label: 'My Button',
31
+ size: 'medium',
32
+ color: 'primary',
33
+ variant: 'contained',
42
34
  },
43
35
  };
44
36
 
@@ -50,7 +42,7 @@ export const ButtonSizes = () => (
50
42
  label={`Size ${size}`}
51
43
  size={size}
52
44
  variant="contained"
53
- style={{ marginRight: "5px" }}
45
+ style={{ marginRight: '5px' }}
54
46
  {...defaultArgs}
55
47
  />
56
48
  ))}
@@ -64,7 +56,7 @@ export const ButtonVariants = () => (
64
56
  key={key}
65
57
  variant={variant}
66
58
  label={`Variant ${variant}`}
67
- style={{ marginRight: "5px" }}
59
+ style={{ marginRight: '5px' }}
68
60
  {...defaultArgs}
69
61
  />
70
62
  ))}
@@ -79,7 +71,7 @@ export const ButtonColorsDefault = () => (
79
71
  variant="outlined"
80
72
  label={`Color ${color}`}
81
73
  color={color}
82
- style={{ margin: "2px" }}
74
+ style={{ margin: '2px' }}
83
75
  {...defaultArgs}
84
76
  />
85
77
  ))}
@@ -90,7 +82,7 @@ export const ButtonColorsDefault = () => (
90
82
  label={`Color ${color}`}
91
83
  color={color}
92
84
  variant="contained"
93
- style={{ margin: "2px" }}
85
+ style={{ margin: '2px' }}
94
86
  {...defaultArgs}
95
87
  />
96
88
  ))}
@@ -1,55 +1,40 @@
1
- import React from "react";
2
- import { Card } from "../components/Card";
3
- import type { Meta, StoryObj } from "@storybook/react";
4
- import { ColorVariant } from "../types";
5
-
6
- const colors: ColorVariant[] = [
7
- "inherit",
8
- "primary",
9
- "secondary",
10
- "success",
11
- "error",
12
- "info",
13
- "warning",
14
- ];
15
-
16
- const meta = {
17
- title: "Layout/Card",
18
- component: Card,
19
- parameters: {
20
- layout: "centered",
21
- },
22
- tags: ["autodocs"],
23
- argTypes: {},
24
- } satisfies Meta<typeof Card>;
25
-
26
- export default meta;
27
-
28
- type Story = StoryObj<typeof meta>;
29
-
30
- const defaultArgs = {};
31
-
32
- export const BasicCard = () => (
33
- <Card sx={{ minWidth: 275 }}>Content children card</Card>
34
- );
35
-
36
- export const BasicBordered = () => (
37
- <Card sx={{ minWidth: 275 }} border={true} color="primary">
38
- Card with border
39
- </Card>
40
- );
41
-
42
- export const BasicBorderedColors = () => (
43
- <>
44
- {colors.map((color, key) => (
45
- <Card
46
- sx={{ minWidth: 275, marginBottom: 2 }}
47
- border={true}
48
- color={color}
49
- key={key}
50
- >
51
- Card with border {color}
52
- </Card>
53
- ))}
54
- </>
55
- );
1
+ import React from 'react';
2
+ import { Card } from '../components/Card';
3
+ import type { Meta, StoryObj } from '@storybook/react';
4
+ import { ColorVariant } from '../types';
5
+
6
+ const colors: ColorVariant[] = ['inherit', 'primary', 'secondary', 'success', 'error', 'info', 'warning'];
7
+
8
+ const meta = {
9
+ title: 'Layout/Card',
10
+ component: Card,
11
+ parameters: {
12
+ layout: 'centered',
13
+ },
14
+ tags: ['autodocs'],
15
+ argTypes: {},
16
+ } satisfies Meta<typeof Card>;
17
+
18
+ export default meta;
19
+
20
+ type Story = StoryObj<typeof meta>;
21
+
22
+ const defaultArgs = {};
23
+
24
+ export const BasicCard = () => <Card sx={{ minWidth: 275 }}>Content children card</Card>;
25
+
26
+ export const BasicBordered = () => (
27
+ <Card sx={{ minWidth: 275 }} border={true} color="primary">
28
+ Card with border
29
+ </Card>
30
+ );
31
+
32
+ export const BasicBorderedColors = () => (
33
+ <>
34
+ {colors.map((color, key) => (
35
+ <Card sx={{ minWidth: 275, marginBottom: 2 }} border={true} color={color} key={key}>
36
+ Card with border {color}
37
+ </Card>
38
+ ))}
39
+ </>
40
+ );