tharaday 0.1.1

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 (247) hide show
  1. package/.gitignore +30 -0
  2. package/.prettierrc.json +10 -0
  3. package/.storybook/main.ts +8 -0
  4. package/.storybook/preview.ts +50 -0
  5. package/.versionrc.json +6 -0
  6. package/README.md +73 -0
  7. package/dist/components/Accordion/Accordion.d.ts +2 -0
  8. package/dist/components/Accordion/Accordion.stories.d.ts +14 -0
  9. package/dist/components/Accordion/Accordion.types.d.ts +18 -0
  10. package/dist/components/Avatar/Avatar.d.ts +2 -0
  11. package/dist/components/Avatar/Avatar.stories.d.ts +14 -0
  12. package/dist/components/Avatar/Avatar.types.d.ts +10 -0
  13. package/dist/components/Badge/Badge.d.ts +2 -0
  14. package/dist/components/Badge/Badge.stories.d.ts +33 -0
  15. package/dist/components/Badge/Badge.types.d.ts +9 -0
  16. package/dist/components/Box/Box.d.ts +2 -0
  17. package/dist/components/Box/Box.stories.d.ts +38 -0
  18. package/dist/components/Box/Box.types.d.ts +49 -0
  19. package/dist/components/Breadcrumbs/Breadcrumbs.d.ts +3 -0
  20. package/dist/components/Breadcrumbs/Breadcrumbs.stories.d.ts +13 -0
  21. package/dist/components/Breadcrumbs/Breadcrumbs.types.d.ts +11 -0
  22. package/dist/components/Button/Button.d.ts +2 -0
  23. package/dist/components/Button/Button.stories.d.ts +22 -0
  24. package/dist/components/Button/Button.types.d.ts +12 -0
  25. package/dist/components/Card/Card.d.ts +5 -0
  26. package/dist/components/Card/Card.stories.d.ts +27 -0
  27. package/dist/components/Card/Card.types.d.ts +15 -0
  28. package/dist/components/Checkbox/Checkbox.d.ts +2 -0
  29. package/dist/components/Checkbox/Checkbox.stories.d.ts +17 -0
  30. package/dist/components/Checkbox/Checkbox.types.d.ts +6 -0
  31. package/dist/components/Dropdown/Dropdown.d.ts +2 -0
  32. package/dist/components/Dropdown/Dropdown.stories.d.ts +12 -0
  33. package/dist/components/Dropdown/Dropdown.types.d.ts +24 -0
  34. package/dist/components/Header/Header.d.ts +2 -0
  35. package/dist/components/Header/Header.stories.d.ts +18 -0
  36. package/dist/components/Header/Header.types.d.ts +14 -0
  37. package/dist/components/Input/Input.d.ts +2 -0
  38. package/dist/components/Input/Input.stories.d.ts +29 -0
  39. package/dist/components/Input/Input.types.d.ts +8 -0
  40. package/dist/components/Loader/Loader.d.ts +2 -0
  41. package/dist/components/Loader/Loader.stories.d.ts +25 -0
  42. package/dist/components/Loader/Loader.types.d.ts +8 -0
  43. package/dist/components/Modal/Modal.d.ts +2 -0
  44. package/dist/components/Modal/Modal.stories.d.ts +22 -0
  45. package/dist/components/Modal/Modal.types.d.ts +12 -0
  46. package/dist/components/NavBar/NavBar.d.ts +6 -0
  47. package/dist/components/NavBar/NavBar.stories.d.ts +8 -0
  48. package/dist/components/NavBar/NavBar.types.d.ts +34 -0
  49. package/dist/components/Notification/Notification.d.ts +2 -0
  50. package/dist/components/Notification/Notification.stories.d.ts +26 -0
  51. package/dist/components/Notification/Notification.types.d.ts +8 -0
  52. package/dist/components/Pagination/Pagination.d.ts +2 -0
  53. package/dist/components/Pagination/Pagination.stories.d.ts +21 -0
  54. package/dist/components/Pagination/Pagination.types.d.ts +34 -0
  55. package/dist/components/ProgressBar/ProgressBar.d.ts +2 -0
  56. package/dist/components/ProgressBar/ProgressBar.stories.d.ts +32 -0
  57. package/dist/components/ProgressBar/ProgressBar.types.d.ts +12 -0
  58. package/dist/components/RadioButton/RadioButton.d.ts +2 -0
  59. package/dist/components/RadioButton/RadioButton.stories.d.ts +30 -0
  60. package/dist/components/RadioButton/RadioButton.types.d.ts +8 -0
  61. package/dist/components/Select/Select.d.ts +2 -0
  62. package/dist/components/Select/Select.stories.d.ts +29 -0
  63. package/dist/components/Select/Select.types.d.ts +15 -0
  64. package/dist/components/Skeleton/Skeleton.d.ts +2 -0
  65. package/dist/components/Skeleton/Skeleton.stories.d.ts +15 -0
  66. package/dist/components/Skeleton/Skeleton.types.d.ts +8 -0
  67. package/dist/components/Stepper/Step.d.ts +2 -0
  68. package/dist/components/Stepper/Step.types.d.ts +17 -0
  69. package/dist/components/Stepper/Stepper.d.ts +2 -0
  70. package/dist/components/Stepper/Stepper.stories.d.ts +15 -0
  71. package/dist/components/Stepper/Stepper.types.d.ts +13 -0
  72. package/dist/components/Stepper/stepper.utils.d.ts +3 -0
  73. package/dist/components/Switch/Switch.d.ts +2 -0
  74. package/dist/components/Switch/Switch.stories.d.ts +16 -0
  75. package/dist/components/Switch/Switch.types.d.ts +5 -0
  76. package/dist/components/Table/Table.d.ts +8 -0
  77. package/dist/components/Table/Table.stories.d.ts +27 -0
  78. package/dist/components/Table/Table.types.d.ts +17 -0
  79. package/dist/components/Tabs/Tabs.d.ts +2 -0
  80. package/dist/components/Tabs/Tabs.stories.d.ts +14 -0
  81. package/dist/components/Tabs/Tabs.types.d.ts +16 -0
  82. package/dist/components/Text/Text.d.ts +2 -0
  83. package/dist/components/Text/Text.stories.d.ts +35 -0
  84. package/dist/components/Text/Text.types.d.ts +21 -0
  85. package/dist/components/Textarea/Textarea.d.ts +2 -0
  86. package/dist/components/Textarea/Textarea.stories.d.ts +29 -0
  87. package/dist/components/Textarea/Textarea.types.d.ts +9 -0
  88. package/dist/components/Tooltip/Tooltip.d.ts +2 -0
  89. package/dist/components/Tooltip/Tooltip.stories.d.ts +10 -0
  90. package/dist/components/Tooltip/Tooltip.types.d.ts +12 -0
  91. package/dist/ds.css +1 -0
  92. package/dist/ds.js +1930 -0
  93. package/dist/ds.umd.cjs +1 -0
  94. package/dist/index.d.ts +63 -0
  95. package/dist/layouts/AppLayout/AppLayout.d.ts +8 -0
  96. package/dist/layouts/AppLayout/AppLayout.stories.d.ts +19 -0
  97. package/dist/layouts/AppLayout/AppLayout.types.d.ts +50 -0
  98. package/dist/layouts/AuthLayout/AuthLayout.d.ts +2 -0
  99. package/dist/layouts/AuthLayout/AuthLayout.stories.d.ts +12 -0
  100. package/dist/layouts/AuthLayout/AuthLayout.types.d.ts +7 -0
  101. package/dist/layouts/DashboardLayout/DashboardLayout.d.ts +2 -0
  102. package/dist/layouts/DashboardLayout/DashboardLayout.stories.d.ts +17 -0
  103. package/dist/layouts/DashboardLayout/DashboardLayout.types.d.ts +15 -0
  104. package/dist/layouts/SettingsLayout/SettingsLayout.d.ts +2 -0
  105. package/dist/layouts/SettingsLayout/SettingsLayout.stories.d.ts +17 -0
  106. package/dist/layouts/SettingsLayout/SettingsLayout.types.d.ts +14 -0
  107. package/eslint.config.js +45 -0
  108. package/package.json +100 -0
  109. package/src/components/Accordion/Accordion.module.css +158 -0
  110. package/src/components/Accordion/Accordion.stories.tsx +133 -0
  111. package/src/components/Accordion/Accordion.tsx +68 -0
  112. package/src/components/Accordion/Accordion.types.ts +21 -0
  113. package/src/components/Avatar/Avatar.module.css +58 -0
  114. package/src/components/Avatar/Avatar.stories.tsx +41 -0
  115. package/src/components/Avatar/Avatar.tsx +64 -0
  116. package/src/components/Avatar/Avatar.types.ts +12 -0
  117. package/src/components/Badge/Badge.module.css +98 -0
  118. package/src/components/Badge/Badge.stories.tsx +108 -0
  119. package/src/components/Badge/Badge.tsx +22 -0
  120. package/src/components/Badge/Badge.types.ts +11 -0
  121. package/src/components/Box/Box.module.css +638 -0
  122. package/src/components/Box/Box.stories.tsx +109 -0
  123. package/src/components/Box/Box.tsx +95 -0
  124. package/src/components/Box/Box.types.ts +65 -0
  125. package/src/components/Breadcrumbs/Breadcrumbs.module.css +41 -0
  126. package/src/components/Breadcrumbs/Breadcrumbs.stories.tsx +40 -0
  127. package/src/components/Breadcrumbs/Breadcrumbs.tsx +54 -0
  128. package/src/components/Breadcrumbs/Breadcrumbs.types.ts +13 -0
  129. package/src/components/Button/Button.module.css +247 -0
  130. package/src/components/Button/Button.stories.tsx +93 -0
  131. package/src/components/Button/Button.tsx +31 -0
  132. package/src/components/Button/Button.types.ts +14 -0
  133. package/src/components/Card/Card.module.css +112 -0
  134. package/src/components/Card/Card.stories.tsx +86 -0
  135. package/src/components/Card/Card.tsx +70 -0
  136. package/src/components/Card/Card.types.ts +20 -0
  137. package/src/components/Checkbox/Checkbox.module.css +88 -0
  138. package/src/components/Checkbox/Checkbox.stories.tsx +65 -0
  139. package/src/components/Checkbox/Checkbox.tsx +57 -0
  140. package/src/components/Checkbox/Checkbox.types.ts +7 -0
  141. package/src/components/Dropdown/Dropdown.module.css +140 -0
  142. package/src/components/Dropdown/Dropdown.stories.tsx +86 -0
  143. package/src/components/Dropdown/Dropdown.tsx +251 -0
  144. package/src/components/Dropdown/Dropdown.types.ts +27 -0
  145. package/src/components/Header/Header.module.css +38 -0
  146. package/src/components/Header/Header.stories.tsx +53 -0
  147. package/src/components/Header/Header.tsx +49 -0
  148. package/src/components/Header/Header.types.ts +15 -0
  149. package/src/components/Input/Input.module.css +87 -0
  150. package/src/components/Input/Input.stories.tsx +101 -0
  151. package/src/components/Input/Input.tsx +41 -0
  152. package/src/components/Input/Input.types.ts +10 -0
  153. package/src/components/Loader/Loader.module.css +49 -0
  154. package/src/components/Loader/Loader.stories.tsx +75 -0
  155. package/src/components/Loader/Loader.tsx +15 -0
  156. package/src/components/Loader/Loader.types.ts +9 -0
  157. package/src/components/Modal/Modal.module.css +88 -0
  158. package/src/components/Modal/Modal.stories.tsx +94 -0
  159. package/src/components/Modal/Modal.tsx +115 -0
  160. package/src/components/Modal/Modal.types.ts +13 -0
  161. package/src/components/NavBar/NavBar.module.css +77 -0
  162. package/src/components/NavBar/NavBar.stories.tsx +55 -0
  163. package/src/components/NavBar/NavBar.tsx +50 -0
  164. package/src/components/NavBar/NavBar.types.ts +36 -0
  165. package/src/components/Notification/Notification.module.css +72 -0
  166. package/src/components/Notification/Notification.stories.tsx +81 -0
  167. package/src/components/Notification/Notification.tsx +34 -0
  168. package/src/components/Notification/Notification.types.ts +10 -0
  169. package/src/components/Pagination/Pagination.module.css +31 -0
  170. package/src/components/Pagination/Pagination.stories.tsx +128 -0
  171. package/src/components/Pagination/Pagination.tsx +245 -0
  172. package/src/components/Pagination/Pagination.types.ts +37 -0
  173. package/src/components/ProgressBar/ProgressBar.module.css +67 -0
  174. package/src/components/ProgressBar/ProgressBar.stories.tsx +91 -0
  175. package/src/components/ProgressBar/ProgressBar.tsx +49 -0
  176. package/src/components/ProgressBar/ProgressBar.types.ts +13 -0
  177. package/src/components/RadioButton/RadioButton.module.css +162 -0
  178. package/src/components/RadioButton/RadioButton.stories.tsx +114 -0
  179. package/src/components/RadioButton/RadioButton.tsx +43 -0
  180. package/src/components/RadioButton/RadioButton.types.ts +10 -0
  181. package/src/components/Select/Select.module.css +88 -0
  182. package/src/components/Select/Select.stories.tsx +99 -0
  183. package/src/components/Select/Select.tsx +51 -0
  184. package/src/components/Select/Select.types.ts +18 -0
  185. package/src/components/Skeleton/Skeleton.module.css +71 -0
  186. package/src/components/Skeleton/Skeleton.stories.tsx +54 -0
  187. package/src/components/Skeleton/Skeleton.tsx +32 -0
  188. package/src/components/Skeleton/Skeleton.types.ts +10 -0
  189. package/src/components/Stepper/Step.module.css +162 -0
  190. package/src/components/Stepper/Step.tsx +62 -0
  191. package/src/components/Stepper/Step.types.ts +19 -0
  192. package/src/components/Stepper/Stepper.module.css +39 -0
  193. package/src/components/Stepper/Stepper.stories.tsx +88 -0
  194. package/src/components/Stepper/Stepper.tsx +47 -0
  195. package/src/components/Stepper/Stepper.types.ts +16 -0
  196. package/src/components/Stepper/stepper.utils.ts +41 -0
  197. package/src/components/Switch/Switch.module.css +74 -0
  198. package/src/components/Switch/Switch.stories.tsx +56 -0
  199. package/src/components/Switch/Switch.tsx +36 -0
  200. package/src/components/Switch/Switch.types.ts +6 -0
  201. package/src/components/Table/Table.module.css +78 -0
  202. package/src/components/Table/Table.stories.tsx +124 -0
  203. package/src/components/Table/Table.tsx +75 -0
  204. package/src/components/Table/Table.types.ts +29 -0
  205. package/src/components/Tabs/Tabs.module.css +74 -0
  206. package/src/components/Tabs/Tabs.stories.tsx +48 -0
  207. package/src/components/Tabs/Tabs.tsx +113 -0
  208. package/src/components/Tabs/Tabs.types.ts +18 -0
  209. package/src/components/Text/Text.module.css +126 -0
  210. package/src/components/Text/Text.stories.tsx +128 -0
  211. package/src/components/Text/Text.tsx +50 -0
  212. package/src/components/Text/Text.types.ts +43 -0
  213. package/src/components/Textarea/Textarea.module.css +82 -0
  214. package/src/components/Textarea/Textarea.stories.tsx +99 -0
  215. package/src/components/Textarea/Textarea.tsx +43 -0
  216. package/src/components/Textarea/Textarea.types.ts +11 -0
  217. package/src/components/Tooltip/Tooltip.module.css +125 -0
  218. package/src/components/Tooltip/Tooltip.stories.tsx +68 -0
  219. package/src/components/Tooltip/Tooltip.tsx +87 -0
  220. package/src/components/Tooltip/Tooltip.types.ts +14 -0
  221. package/src/index.ts +132 -0
  222. package/src/layouts/AppLayout/AppLayout.module.css +17 -0
  223. package/src/layouts/AppLayout/AppLayout.stories.tsx +124 -0
  224. package/src/layouts/AppLayout/AppLayout.tsx +46 -0
  225. package/src/layouts/AppLayout/AppLayout.types.ts +50 -0
  226. package/src/layouts/AuthLayout/AuthLayout.module.css +49 -0
  227. package/src/layouts/AuthLayout/AuthLayout.stories.tsx +109 -0
  228. package/src/layouts/AuthLayout/AuthLayout.tsx +27 -0
  229. package/src/layouts/AuthLayout/AuthLayout.types.tsx +8 -0
  230. package/src/layouts/DashboardLayout/DashboardLayout.module.css +37 -0
  231. package/src/layouts/DashboardLayout/DashboardLayout.stories.tsx +144 -0
  232. package/src/layouts/DashboardLayout/DashboardLayout.tsx +41 -0
  233. package/src/layouts/DashboardLayout/DashboardLayout.types.tsx +14 -0
  234. package/src/layouts/SettingsLayout/SettingsLayout.module.css +39 -0
  235. package/src/layouts/SettingsLayout/SettingsLayout.stories.tsx +103 -0
  236. package/src/layouts/SettingsLayout/SettingsLayout.tsx +37 -0
  237. package/src/layouts/SettingsLayout/SettingsLayout.types.tsx +13 -0
  238. package/src/styles/ds.css +12 -0
  239. package/src/styles/semantic.css +56 -0
  240. package/src/styles/themes/dark.css +58 -0
  241. package/src/styles/themes/light.css +58 -0
  242. package/src/styles/themes/retro.css +58 -0
  243. package/src/styles/tokens.css +138 -0
  244. package/tsconfig.app.json +28 -0
  245. package/tsconfig.json +7 -0
  246. package/tsconfig.node.json +26 -0
  247. package/vite.config.ts +33 -0
@@ -0,0 +1,41 @@
1
+ import clsx from 'clsx';
2
+ import { useId } from 'react';
3
+
4
+ import styles from './Input.module.css';
5
+ import type { InputProps } from './Input.types.ts';
6
+
7
+ export const Input = ({
8
+ size = 'md',
9
+ error,
10
+ label,
11
+ helperText,
12
+ className,
13
+ id,
14
+ ...props
15
+ }: InputProps) => {
16
+ const baseId = useId();
17
+ const componentId = id ?? `ds-input-${baseId}`;
18
+ const helperId = helperText ? `${componentId}-help` : undefined;
19
+
20
+ return (
21
+ <div className={clsx(styles.wrapper, className)}>
22
+ {label && (
23
+ <label htmlFor={componentId} className={styles.label}>
24
+ {label}
25
+ </label>
26
+ )}
27
+ <input
28
+ id={componentId}
29
+ className={clsx(styles.inputRoot, styles[size], error && styles.error)}
30
+ aria-describedby={helperId}
31
+ aria-invalid={error || undefined}
32
+ {...props}
33
+ />
34
+ {helperText && (
35
+ <span id={helperId} className={clsx(styles.helperText, error && styles.errorText)}>
36
+ {helperText}
37
+ </span>
38
+ )}
39
+ </div>
40
+ );
41
+ };
@@ -0,0 +1,10 @@
1
+ import type { InputHTMLAttributes } from 'react';
2
+
3
+ export type InputSize = 'sm' | 'md' | 'lg';
4
+
5
+ export interface InputProps extends Omit<InputHTMLAttributes<HTMLInputElement>, 'size'> {
6
+ size?: InputSize;
7
+ error?: boolean;
8
+ label?: string;
9
+ helperText?: string;
10
+ }
@@ -0,0 +1,49 @@
1
+ .loader {
2
+ display: inline-block;
3
+ border-radius: var(--ds-radius-full);
4
+ border: 0.125rem solid var(--ds-surface-1);
5
+ border-top-color: var(--ds-info);
6
+ animation: spin 0.8s linear infinite;
7
+ }
8
+
9
+ /* Intents */
10
+ .neutral {
11
+ border-top-color: var(--ds-neutral);
12
+ }
13
+ .info {
14
+ border-top-color: var(--ds-info);
15
+ }
16
+ .success {
17
+ border-top-color: var(--ds-success);
18
+ }
19
+ .warning {
20
+ border-top-color: var(--ds-warning);
21
+ }
22
+ .danger {
23
+ border-top-color: var(--ds-danger);
24
+ }
25
+
26
+ /* Sizes */
27
+ .sm {
28
+ width: var(--ds-space-4);
29
+ height: var(--ds-space-4);
30
+ border-width: 0.125rem;
31
+ }
32
+
33
+ .md {
34
+ width: var(--ds-space-8);
35
+ height: var(--ds-space-8);
36
+ border-width: 0.1875rem;
37
+ }
38
+
39
+ .lg {
40
+ width: var(--ds-space-12);
41
+ height: var(--ds-space-12);
42
+ border-width: 0.25rem;
43
+ }
44
+
45
+ @keyframes spin {
46
+ to {
47
+ transform: rotate(360deg);
48
+ }
49
+ }
@@ -0,0 +1,75 @@
1
+ import type { Meta, StoryObj } from '@storybook/react-vite';
2
+
3
+ import { Loader } from './Loader.tsx';
4
+ import { Box } from '../Box/Box.tsx';
5
+
6
+ const meta = {
7
+ title: 'Components/Loader',
8
+ component: Loader,
9
+ tags: ['autodocs'],
10
+ parameters: {
11
+ layout: 'centered',
12
+ },
13
+ argTypes: {
14
+ size: {
15
+ control: 'select',
16
+ options: ['sm', 'md', 'lg'],
17
+ },
18
+ intent: {
19
+ control: 'select',
20
+ options: ['neutral', 'info', 'success', 'warning', 'danger'],
21
+ },
22
+ },
23
+ } satisfies Meta<typeof Loader>;
24
+
25
+ export default meta;
26
+ type Story = StoryObj<typeof meta>;
27
+
28
+ export const Default: Story = {
29
+ args: {
30
+ size: 'md',
31
+ intent: 'info',
32
+ },
33
+ };
34
+
35
+ export const Intents: Story = {
36
+ render: () => (
37
+ <Box display="flex" gap={6} alignItems="center">
38
+ <Loader intent="neutral" />
39
+ <Loader intent="info" />
40
+ <Loader intent="success" />
41
+ <Loader intent="warning" />
42
+ <Loader intent="danger" />
43
+ </Box>
44
+ ),
45
+ };
46
+
47
+ export const Sizes: Story = {
48
+ render: () => (
49
+ <Box display="flex" gap={6} alignItems="center">
50
+ <Loader size="sm" />
51
+ <Loader size="md" />
52
+ <Loader size="lg" />
53
+ </Box>
54
+ ),
55
+ };
56
+
57
+ export const All: Story = {
58
+ name: 'Gallery',
59
+ render: () => (
60
+ <Box display="flex" flexDirection="column" gap={8}>
61
+ {(['sm', 'md', 'lg'] as const).map((size) => (
62
+ <Box key={size} display="flex" flexDirection="column" gap={4}>
63
+ <Box as="h3" m={0} style={{ textTransform: 'capitalize' }}>
64
+ Size: {size}
65
+ </Box>
66
+ <Box display="flex" gap={6} alignItems="center">
67
+ {(['neutral', 'info', 'success', 'warning', 'danger'] as const).map((intent) => (
68
+ <Loader key={intent} size={size} intent={intent} />
69
+ ))}
70
+ </Box>
71
+ </Box>
72
+ ))}
73
+ </Box>
74
+ ),
75
+ };
@@ -0,0 +1,15 @@
1
+ import clsx from 'clsx';
2
+
3
+ import styles from './Loader.module.css';
4
+ import type { LoaderProps } from './Loader.types.ts';
5
+
6
+ export const Loader = ({ id, size = 'md', intent = 'neutral', className }: LoaderProps) => {
7
+ return (
8
+ <div
9
+ id={id}
10
+ className={clsx(styles.loader, styles[size], styles[intent], className)}
11
+ role="status"
12
+ aria-label="Loading"
13
+ />
14
+ );
15
+ };
@@ -0,0 +1,9 @@
1
+ export type LoaderSize = 'sm' | 'md' | 'lg';
2
+ export type LoaderIntent = 'neutral' | 'info' | 'success' | 'warning' | 'danger';
3
+
4
+ export interface LoaderProps {
5
+ id?: string;
6
+ size?: LoaderSize;
7
+ intent?: LoaderIntent;
8
+ className?: string;
9
+ }
@@ -0,0 +1,88 @@
1
+ .overlay {
2
+ position: fixed;
3
+ top: 0;
4
+ left: 0;
5
+ right: 0;
6
+ bottom: 0;
7
+ background-color: rgba(0, 0, 0, 0.5);
8
+ display: flex;
9
+ align-items: center;
10
+ justify-content: center;
11
+ z-index: 1000;
12
+ padding: var(--ds-space-4);
13
+ }
14
+
15
+ .modal {
16
+ background-color: var(--ds-surface-0);
17
+ border-radius: var(--ds-radius-lg);
18
+ box-shadow: var(--ds-shadow-md);
19
+ display: flex;
20
+ flex-direction: column;
21
+ max-height: 100%;
22
+ width: 100%;
23
+ overflow: hidden;
24
+ font-family: var(--ds-font-family-base);
25
+ }
26
+
27
+ .header {
28
+ padding: var(--ds-space-4);
29
+ display: flex;
30
+ align-items: center;
31
+ justify-content: space-between;
32
+ border-bottom: 1px solid var(--ds-border-2);
33
+ }
34
+
35
+ .title {
36
+ margin: 0;
37
+ font-size: var(--ds-font-size-lg);
38
+ font-weight: var(--ds-font-weight-bold);
39
+ color: var(--ds-text-1);
40
+ }
41
+
42
+ .closeButton {
43
+ margin: 0;
44
+ padding: 0 !important;
45
+ width: var(--ds-space-8) !important;
46
+ height: var(--ds-space-8) !important;
47
+ min-width: unset !important;
48
+ }
49
+
50
+ .content {
51
+ padding: var(--ds-space-6);
52
+ overflow-y: auto;
53
+ flex: 1;
54
+ }
55
+
56
+ .footer {
57
+ padding: var(--ds-space-4);
58
+ display: flex;
59
+ align-items: center;
60
+ justify-content: flex-end;
61
+ gap: var(--ds-space-3);
62
+ border-top: 1px solid var(--ds-border-2);
63
+ background-color: var(--ds-surface-1);
64
+ }
65
+
66
+ /* Sizes */
67
+ .sm {
68
+ max-width: 25rem;
69
+ }
70
+ .md {
71
+ max-width: 37.5rem;
72
+ }
73
+ .lg {
74
+ max-width: 50rem;
75
+ }
76
+ .xl {
77
+ max-width: 62.5rem;
78
+ }
79
+ .full {
80
+ max-width: 100%;
81
+ height: 100%;
82
+ border-radius: 0;
83
+ }
84
+
85
+ .loading {
86
+ opacity: 0.7;
87
+ pointer-events: none;
88
+ }
@@ -0,0 +1,94 @@
1
+ import type { Meta, StoryObj } from '@storybook/react-vite';
2
+ import { useState } from 'react';
3
+ import { fn } from 'storybook/test';
4
+
5
+ import { Modal } from './Modal.tsx';
6
+ import { Box } from '../Box/Box.tsx';
7
+ import { Button } from '../Button/Button.tsx';
8
+ import { Text } from '../Text/Text.tsx';
9
+
10
+ const meta = {
11
+ title: 'Components/Modal',
12
+ component: Modal,
13
+ tags: ['autodocs'],
14
+ parameters: {
15
+ layout: 'centered',
16
+ },
17
+ argTypes: {
18
+ size: {
19
+ control: 'select',
20
+ options: ['sm', 'md', 'lg', 'xl', 'full'],
21
+ },
22
+ },
23
+ args: {
24
+ onClose: fn(),
25
+ },
26
+ } satisfies Meta<typeof Modal>;
27
+
28
+ export default meta;
29
+ type Story = StoryObj<typeof meta>;
30
+
31
+ export const Default: Story = {
32
+ args: {
33
+ isOpen: false,
34
+ },
35
+ render: function Render(args) {
36
+ const [isOpen, setIsOpen] = useState(false);
37
+
38
+ return (
39
+ <>
40
+ <Button onClick={() => setIsOpen(true)}>Open Modal</Button>
41
+ <Modal
42
+ {...args}
43
+ isOpen={isOpen}
44
+ onClose={() => {
45
+ setIsOpen(false);
46
+ args.onClose();
47
+ }}
48
+ title="Modal Title"
49
+ footer={
50
+ <Box display="flex" gap={2} justifyContent="flex-end" fullWidth>
51
+ <Button variant="outline" onClick={() => setIsOpen(false)}>
52
+ Cancel
53
+ </Button>
54
+ <Button variant="solid" intent="info" onClick={() => setIsOpen(false)}>
55
+ Save Changes
56
+ </Button>
57
+ </Box>
58
+ }
59
+ >
60
+ <Text>This is the modal content. You can put any React components here.</Text>
61
+ </Modal>
62
+ </>
63
+ );
64
+ },
65
+ };
66
+
67
+ export const Large: Story = {
68
+ args: {
69
+ isOpen: false,
70
+ size: 'lg',
71
+ title: 'Large Modal',
72
+ },
73
+ render: function Render(args) {
74
+ const [isOpen, setIsOpen] = useState(false);
75
+
76
+ return (
77
+ <>
78
+ <Button onClick={() => setIsOpen(true)}>Open Large Modal</Button>
79
+ <Modal
80
+ {...args}
81
+ isOpen={isOpen}
82
+ onClose={() => {
83
+ setIsOpen(false);
84
+ args.onClose();
85
+ }}
86
+ >
87
+ <Box height="1000px" padding={4} backgroundColor="info-subtle" borderRadius="md">
88
+ <Text>This is a large modal with scrolling content.</Text>
89
+ </Box>
90
+ </Modal>
91
+ </>
92
+ );
93
+ },
94
+ };
@@ -0,0 +1,115 @@
1
+ import clsx from 'clsx';
2
+ import { useEffect, useRef, useId } from 'react';
3
+ import { createPortal } from 'react-dom';
4
+
5
+ import styles from './Modal.module.css';
6
+ import type { ModalProps } from './Modal.types.ts';
7
+ import { Button } from '../Button/Button.tsx';
8
+
9
+ export const Modal = ({
10
+ isOpen,
11
+ onClose,
12
+ title,
13
+ children,
14
+ footer,
15
+ size = 'md',
16
+ isLoading = false,
17
+ className,
18
+ id,
19
+ }: ModalProps) => {
20
+ const modalRef = useRef<HTMLDivElement>(null);
21
+ const previousFocus = useRef<HTMLElement | null>(null);
22
+ const baseId = useId();
23
+ const componentId = id ?? `ds-modal-${baseId}`;
24
+ const titleId = `${componentId}-title`;
25
+
26
+ useEffect(() => {
27
+ const handleKeyDown = (event: KeyboardEvent) => {
28
+ if (event.key === 'Escape' && !isLoading) {
29
+ onClose();
30
+ return;
31
+ }
32
+
33
+ if (event.key === 'Tab' && modalRef.current) {
34
+ const focusableElements = modalRef.current.querySelectorAll<HTMLElement>(
35
+ 'button, [href], input, select, textarea, [tabindex]:not([tabindex="-1"])'
36
+ );
37
+ const firstElement = focusableElements[0];
38
+ const lastElement = focusableElements[focusableElements.length - 1];
39
+
40
+ if (event.shiftKey) {
41
+ if (document.activeElement === firstElement) {
42
+ lastElement.focus();
43
+ event.preventDefault();
44
+ }
45
+ } else {
46
+ if (document.activeElement === lastElement) {
47
+ firstElement.focus();
48
+ event.preventDefault();
49
+ }
50
+ }
51
+ }
52
+ };
53
+
54
+ if (isOpen) {
55
+ previousFocus.current = document.activeElement as HTMLElement;
56
+ document.body.style.overflow = 'hidden';
57
+ window.addEventListener('keydown', handleKeyDown);
58
+
59
+ // Focus the first element or the close button after a small delay to ensure it's rendered
60
+ setTimeout(() => {
61
+ const focusableElements = modalRef.current?.querySelectorAll<HTMLElement>(
62
+ 'button, [href], input, select, textarea, [tabindex]:not([tabindex="-1"])'
63
+ );
64
+ if (focusableElements && focusableElements.length > 0) {
65
+ focusableElements[0].focus();
66
+ }
67
+ }, 0);
68
+ }
69
+
70
+ return () => {
71
+ document.body.style.overflow = 'unset';
72
+ window.removeEventListener('keydown', handleKeyDown);
73
+ previousFocus.current?.focus();
74
+ };
75
+ }, [isOpen, onClose, isLoading]);
76
+
77
+ if (!isOpen) {
78
+ return null;
79
+ }
80
+
81
+ return createPortal(
82
+ <div className={styles.overlay} onClick={() => !isLoading && onClose()}>
83
+ <div
84
+ id={componentId}
85
+ className={clsx(styles.modal, styles[size], isLoading && styles.loading, className)}
86
+ onClick={(e) => e.stopPropagation()}
87
+ role="dialog"
88
+ aria-modal="true"
89
+ aria-labelledby={title ? titleId : undefined}
90
+ ref={modalRef}
91
+ >
92
+ <div className={styles.header}>
93
+ {title && (
94
+ <h2 id={titleId} className={styles.title}>
95
+ {title}
96
+ </h2>
97
+ )}
98
+ <Button
99
+ variant="subtle"
100
+ size="sm"
101
+ onClick={onClose}
102
+ className={styles.closeButton}
103
+ aria-label="Close modal"
104
+ disabled={isLoading}
105
+ >
106
+
107
+ </Button>
108
+ </div>
109
+ <div className={styles.content}>{children}</div>
110
+ {footer && <div className={styles.footer}>{footer}</div>}
111
+ </div>
112
+ </div>,
113
+ document.body
114
+ );
115
+ };
@@ -0,0 +1,13 @@
1
+ import type { ReactNode } from 'react';
2
+
3
+ export interface ModalProps {
4
+ id?: string;
5
+ isOpen: boolean;
6
+ onClose: () => void;
7
+ title?: string;
8
+ children?: ReactNode;
9
+ footer?: ReactNode;
10
+ size?: 'sm' | 'md' | 'lg' | 'xl' | 'full';
11
+ isLoading?: boolean;
12
+ className?: string;
13
+ }
@@ -0,0 +1,77 @@
1
+ .root {
2
+ background-color: var(--ds-surface-0);
3
+ border-bottom: 1px solid var(--ds-border-1);
4
+ width: 100%;
5
+ }
6
+
7
+ .container {
8
+ max-width: 75rem;
9
+ margin: 0 auto;
10
+ padding: 0 var(--ds-space-4);
11
+ display: flex;
12
+ align-items: stretch;
13
+ height: 4rem;
14
+ }
15
+
16
+ .leftSection {
17
+ display: flex;
18
+ align-items: center;
19
+ margin-right: var(--ds-space-8);
20
+ }
21
+
22
+ .nav {
23
+ display: flex;
24
+ align-items: stretch;
25
+ flex: 1;
26
+ }
27
+
28
+ .navList {
29
+ display: flex;
30
+ list-style: none;
31
+ margin: 0;
32
+ padding: 0;
33
+ gap: var(--ds-space-4);
34
+ }
35
+
36
+ .navItem {
37
+ display: flex;
38
+ align-items: center;
39
+ }
40
+
41
+ .navLink {
42
+ display: flex;
43
+ align-items: center;
44
+ height: 100%;
45
+ padding: 0 var(--ds-space-2);
46
+ color: var(--ds-text-2);
47
+ text-decoration: none;
48
+ font-size: var(--ds-font-size-sm);
49
+ font-weight: var(--ds-font-weight-medium);
50
+ border-bottom: 0.125rem solid transparent;
51
+ background: none;
52
+ border-top: none;
53
+ border-left: none;
54
+ border-right: none;
55
+ cursor: pointer;
56
+ transition: all 0.2s ease;
57
+ }
58
+
59
+ .navLink:hover:not(.disabled) {
60
+ color: var(--ds-text-1);
61
+ }
62
+
63
+ .active {
64
+ color: var(--ds-info-1);
65
+ border-bottom-color: var(--ds-info-1);
66
+ }
67
+
68
+ .disabled {
69
+ opacity: 0.5;
70
+ cursor: not-allowed;
71
+ }
72
+
73
+ .rightSection {
74
+ display: flex;
75
+ align-items: center;
76
+ gap: var(--ds-space-4);
77
+ }
@@ -0,0 +1,55 @@
1
+ import type { Meta, StoryObj } from '@storybook/react';
2
+
3
+ import { NavBar } from './NavBar.tsx';
4
+ import { Button } from '../Button/Button.tsx';
5
+
6
+ const meta: Meta<typeof NavBar> = {
7
+ title: 'Components/NavBar',
8
+ component: NavBar,
9
+ parameters: {
10
+ layout: 'fullscreen',
11
+ },
12
+ tags: ['autodocs'],
13
+ };
14
+
15
+ export default meta;
16
+ type Story = StoryObj<typeof NavBar>;
17
+
18
+ const defaultItems = [
19
+ { id: 'home', label: 'Home' },
20
+ { id: 'products', label: 'Products' },
21
+ { id: 'services', label: 'Services' },
22
+ { id: 'about', label: 'About' },
23
+ { id: 'contact', label: 'Contact', disabled: true },
24
+ ];
25
+
26
+ export const Default: Story = {
27
+ args: {
28
+ items: defaultItems,
29
+ activeId: 'home',
30
+ logo: (
31
+ <div style={{ fontWeight: 'bold', fontSize: '1.2rem', color: 'var(--ds-info-1)' }}>Logo</div>
32
+ ),
33
+ },
34
+ };
35
+
36
+ export const WithActions: Story = {
37
+ args: {
38
+ ...Default.args,
39
+ actions: (
40
+ <>
41
+ <Button size="sm" variant="outline">
42
+ Log in
43
+ </Button>
44
+ <Button size="sm">Get Started</Button>
45
+ </>
46
+ ),
47
+ },
48
+ };
49
+
50
+ export const Simple: Story = {
51
+ args: {
52
+ items: defaultItems,
53
+ activeId: 'services',
54
+ },
55
+ };
@@ -0,0 +1,50 @@
1
+ import clsx from 'clsx';
2
+
3
+ import styles from './NavBar.module.css';
4
+ import type { NavBarProps } from './NavBar.types.ts';
5
+
6
+ /**
7
+ * NavBar is a navigation component typically used for application-wide navigation.
8
+ * It differs from Header as it focuses on navigational links rather than just branding and user actions.
9
+ */
10
+ export const NavBar = ({
11
+ id,
12
+ items,
13
+ activeId,
14
+ logo,
15
+ actions,
16
+ onItemClick,
17
+ className,
18
+ }: NavBarProps) => {
19
+ return (
20
+ <nav id={id} className={clsx(styles.root, className)}>
21
+ <div className={styles.container}>
22
+ {logo && <div className={styles.leftSection}>{logo}</div>}
23
+
24
+ <div className={styles.nav}>
25
+ <ul className={styles.navList}>
26
+ {items.map((item) => (
27
+ <li key={item.id} className={styles.navItem}>
28
+ <button
29
+ type="button"
30
+ className={clsx(
31
+ styles.navLink,
32
+ activeId === item.id && styles.active,
33
+ item.disabled && styles.disabled
34
+ )}
35
+ onClick={() => !item.disabled && onItemClick?.(item.id)}
36
+ disabled={item.disabled}
37
+ aria-current={activeId === item.id ? 'page' : undefined}
38
+ >
39
+ {item.label}
40
+ </button>
41
+ </li>
42
+ ))}
43
+ </ul>
44
+ </div>
45
+
46
+ {actions && <div className={styles.rightSection}>{actions}</div>}
47
+ </div>
48
+ </nav>
49
+ );
50
+ };