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.
- package/.gitignore +30 -0
- package/.prettierrc.json +10 -0
- package/.storybook/main.ts +8 -0
- package/.storybook/preview.ts +50 -0
- package/.versionrc.json +6 -0
- package/README.md +73 -0
- package/dist/components/Accordion/Accordion.d.ts +2 -0
- package/dist/components/Accordion/Accordion.stories.d.ts +14 -0
- package/dist/components/Accordion/Accordion.types.d.ts +18 -0
- package/dist/components/Avatar/Avatar.d.ts +2 -0
- package/dist/components/Avatar/Avatar.stories.d.ts +14 -0
- package/dist/components/Avatar/Avatar.types.d.ts +10 -0
- package/dist/components/Badge/Badge.d.ts +2 -0
- package/dist/components/Badge/Badge.stories.d.ts +33 -0
- package/dist/components/Badge/Badge.types.d.ts +9 -0
- package/dist/components/Box/Box.d.ts +2 -0
- package/dist/components/Box/Box.stories.d.ts +38 -0
- package/dist/components/Box/Box.types.d.ts +49 -0
- package/dist/components/Breadcrumbs/Breadcrumbs.d.ts +3 -0
- package/dist/components/Breadcrumbs/Breadcrumbs.stories.d.ts +13 -0
- package/dist/components/Breadcrumbs/Breadcrumbs.types.d.ts +11 -0
- package/dist/components/Button/Button.d.ts +2 -0
- package/dist/components/Button/Button.stories.d.ts +22 -0
- package/dist/components/Button/Button.types.d.ts +12 -0
- package/dist/components/Card/Card.d.ts +5 -0
- package/dist/components/Card/Card.stories.d.ts +27 -0
- package/dist/components/Card/Card.types.d.ts +15 -0
- package/dist/components/Checkbox/Checkbox.d.ts +2 -0
- package/dist/components/Checkbox/Checkbox.stories.d.ts +17 -0
- package/dist/components/Checkbox/Checkbox.types.d.ts +6 -0
- package/dist/components/Dropdown/Dropdown.d.ts +2 -0
- package/dist/components/Dropdown/Dropdown.stories.d.ts +12 -0
- package/dist/components/Dropdown/Dropdown.types.d.ts +24 -0
- package/dist/components/Header/Header.d.ts +2 -0
- package/dist/components/Header/Header.stories.d.ts +18 -0
- package/dist/components/Header/Header.types.d.ts +14 -0
- package/dist/components/Input/Input.d.ts +2 -0
- package/dist/components/Input/Input.stories.d.ts +29 -0
- package/dist/components/Input/Input.types.d.ts +8 -0
- package/dist/components/Loader/Loader.d.ts +2 -0
- package/dist/components/Loader/Loader.stories.d.ts +25 -0
- package/dist/components/Loader/Loader.types.d.ts +8 -0
- package/dist/components/Modal/Modal.d.ts +2 -0
- package/dist/components/Modal/Modal.stories.d.ts +22 -0
- package/dist/components/Modal/Modal.types.d.ts +12 -0
- package/dist/components/NavBar/NavBar.d.ts +6 -0
- package/dist/components/NavBar/NavBar.stories.d.ts +8 -0
- package/dist/components/NavBar/NavBar.types.d.ts +34 -0
- package/dist/components/Notification/Notification.d.ts +2 -0
- package/dist/components/Notification/Notification.stories.d.ts +26 -0
- package/dist/components/Notification/Notification.types.d.ts +8 -0
- package/dist/components/Pagination/Pagination.d.ts +2 -0
- package/dist/components/Pagination/Pagination.stories.d.ts +21 -0
- package/dist/components/Pagination/Pagination.types.d.ts +34 -0
- package/dist/components/ProgressBar/ProgressBar.d.ts +2 -0
- package/dist/components/ProgressBar/ProgressBar.stories.d.ts +32 -0
- package/dist/components/ProgressBar/ProgressBar.types.d.ts +12 -0
- package/dist/components/RadioButton/RadioButton.d.ts +2 -0
- package/dist/components/RadioButton/RadioButton.stories.d.ts +30 -0
- package/dist/components/RadioButton/RadioButton.types.d.ts +8 -0
- package/dist/components/Select/Select.d.ts +2 -0
- package/dist/components/Select/Select.stories.d.ts +29 -0
- package/dist/components/Select/Select.types.d.ts +15 -0
- package/dist/components/Skeleton/Skeleton.d.ts +2 -0
- package/dist/components/Skeleton/Skeleton.stories.d.ts +15 -0
- package/dist/components/Skeleton/Skeleton.types.d.ts +8 -0
- package/dist/components/Stepper/Step.d.ts +2 -0
- package/dist/components/Stepper/Step.types.d.ts +17 -0
- package/dist/components/Stepper/Stepper.d.ts +2 -0
- package/dist/components/Stepper/Stepper.stories.d.ts +15 -0
- package/dist/components/Stepper/Stepper.types.d.ts +13 -0
- package/dist/components/Stepper/stepper.utils.d.ts +3 -0
- package/dist/components/Switch/Switch.d.ts +2 -0
- package/dist/components/Switch/Switch.stories.d.ts +16 -0
- package/dist/components/Switch/Switch.types.d.ts +5 -0
- package/dist/components/Table/Table.d.ts +8 -0
- package/dist/components/Table/Table.stories.d.ts +27 -0
- package/dist/components/Table/Table.types.d.ts +17 -0
- package/dist/components/Tabs/Tabs.d.ts +2 -0
- package/dist/components/Tabs/Tabs.stories.d.ts +14 -0
- package/dist/components/Tabs/Tabs.types.d.ts +16 -0
- package/dist/components/Text/Text.d.ts +2 -0
- package/dist/components/Text/Text.stories.d.ts +35 -0
- package/dist/components/Text/Text.types.d.ts +21 -0
- package/dist/components/Textarea/Textarea.d.ts +2 -0
- package/dist/components/Textarea/Textarea.stories.d.ts +29 -0
- package/dist/components/Textarea/Textarea.types.d.ts +9 -0
- package/dist/components/Tooltip/Tooltip.d.ts +2 -0
- package/dist/components/Tooltip/Tooltip.stories.d.ts +10 -0
- package/dist/components/Tooltip/Tooltip.types.d.ts +12 -0
- package/dist/ds.css +1 -0
- package/dist/ds.js +1930 -0
- package/dist/ds.umd.cjs +1 -0
- package/dist/index.d.ts +63 -0
- package/dist/layouts/AppLayout/AppLayout.d.ts +8 -0
- package/dist/layouts/AppLayout/AppLayout.stories.d.ts +19 -0
- package/dist/layouts/AppLayout/AppLayout.types.d.ts +50 -0
- package/dist/layouts/AuthLayout/AuthLayout.d.ts +2 -0
- package/dist/layouts/AuthLayout/AuthLayout.stories.d.ts +12 -0
- package/dist/layouts/AuthLayout/AuthLayout.types.d.ts +7 -0
- package/dist/layouts/DashboardLayout/DashboardLayout.d.ts +2 -0
- package/dist/layouts/DashboardLayout/DashboardLayout.stories.d.ts +17 -0
- package/dist/layouts/DashboardLayout/DashboardLayout.types.d.ts +15 -0
- package/dist/layouts/SettingsLayout/SettingsLayout.d.ts +2 -0
- package/dist/layouts/SettingsLayout/SettingsLayout.stories.d.ts +17 -0
- package/dist/layouts/SettingsLayout/SettingsLayout.types.d.ts +14 -0
- package/eslint.config.js +45 -0
- package/package.json +100 -0
- package/src/components/Accordion/Accordion.module.css +158 -0
- package/src/components/Accordion/Accordion.stories.tsx +133 -0
- package/src/components/Accordion/Accordion.tsx +68 -0
- package/src/components/Accordion/Accordion.types.ts +21 -0
- package/src/components/Avatar/Avatar.module.css +58 -0
- package/src/components/Avatar/Avatar.stories.tsx +41 -0
- package/src/components/Avatar/Avatar.tsx +64 -0
- package/src/components/Avatar/Avatar.types.ts +12 -0
- package/src/components/Badge/Badge.module.css +98 -0
- package/src/components/Badge/Badge.stories.tsx +108 -0
- package/src/components/Badge/Badge.tsx +22 -0
- package/src/components/Badge/Badge.types.ts +11 -0
- package/src/components/Box/Box.module.css +638 -0
- package/src/components/Box/Box.stories.tsx +109 -0
- package/src/components/Box/Box.tsx +95 -0
- package/src/components/Box/Box.types.ts +65 -0
- package/src/components/Breadcrumbs/Breadcrumbs.module.css +41 -0
- package/src/components/Breadcrumbs/Breadcrumbs.stories.tsx +40 -0
- package/src/components/Breadcrumbs/Breadcrumbs.tsx +54 -0
- package/src/components/Breadcrumbs/Breadcrumbs.types.ts +13 -0
- package/src/components/Button/Button.module.css +247 -0
- package/src/components/Button/Button.stories.tsx +93 -0
- package/src/components/Button/Button.tsx +31 -0
- package/src/components/Button/Button.types.ts +14 -0
- package/src/components/Card/Card.module.css +112 -0
- package/src/components/Card/Card.stories.tsx +86 -0
- package/src/components/Card/Card.tsx +70 -0
- package/src/components/Card/Card.types.ts +20 -0
- package/src/components/Checkbox/Checkbox.module.css +88 -0
- package/src/components/Checkbox/Checkbox.stories.tsx +65 -0
- package/src/components/Checkbox/Checkbox.tsx +57 -0
- package/src/components/Checkbox/Checkbox.types.ts +7 -0
- package/src/components/Dropdown/Dropdown.module.css +140 -0
- package/src/components/Dropdown/Dropdown.stories.tsx +86 -0
- package/src/components/Dropdown/Dropdown.tsx +251 -0
- package/src/components/Dropdown/Dropdown.types.ts +27 -0
- package/src/components/Header/Header.module.css +38 -0
- package/src/components/Header/Header.stories.tsx +53 -0
- package/src/components/Header/Header.tsx +49 -0
- package/src/components/Header/Header.types.ts +15 -0
- package/src/components/Input/Input.module.css +87 -0
- package/src/components/Input/Input.stories.tsx +101 -0
- package/src/components/Input/Input.tsx +41 -0
- package/src/components/Input/Input.types.ts +10 -0
- package/src/components/Loader/Loader.module.css +49 -0
- package/src/components/Loader/Loader.stories.tsx +75 -0
- package/src/components/Loader/Loader.tsx +15 -0
- package/src/components/Loader/Loader.types.ts +9 -0
- package/src/components/Modal/Modal.module.css +88 -0
- package/src/components/Modal/Modal.stories.tsx +94 -0
- package/src/components/Modal/Modal.tsx +115 -0
- package/src/components/Modal/Modal.types.ts +13 -0
- package/src/components/NavBar/NavBar.module.css +77 -0
- package/src/components/NavBar/NavBar.stories.tsx +55 -0
- package/src/components/NavBar/NavBar.tsx +50 -0
- package/src/components/NavBar/NavBar.types.ts +36 -0
- package/src/components/Notification/Notification.module.css +72 -0
- package/src/components/Notification/Notification.stories.tsx +81 -0
- package/src/components/Notification/Notification.tsx +34 -0
- package/src/components/Notification/Notification.types.ts +10 -0
- package/src/components/Pagination/Pagination.module.css +31 -0
- package/src/components/Pagination/Pagination.stories.tsx +128 -0
- package/src/components/Pagination/Pagination.tsx +245 -0
- package/src/components/Pagination/Pagination.types.ts +37 -0
- package/src/components/ProgressBar/ProgressBar.module.css +67 -0
- package/src/components/ProgressBar/ProgressBar.stories.tsx +91 -0
- package/src/components/ProgressBar/ProgressBar.tsx +49 -0
- package/src/components/ProgressBar/ProgressBar.types.ts +13 -0
- package/src/components/RadioButton/RadioButton.module.css +162 -0
- package/src/components/RadioButton/RadioButton.stories.tsx +114 -0
- package/src/components/RadioButton/RadioButton.tsx +43 -0
- package/src/components/RadioButton/RadioButton.types.ts +10 -0
- package/src/components/Select/Select.module.css +88 -0
- package/src/components/Select/Select.stories.tsx +99 -0
- package/src/components/Select/Select.tsx +51 -0
- package/src/components/Select/Select.types.ts +18 -0
- package/src/components/Skeleton/Skeleton.module.css +71 -0
- package/src/components/Skeleton/Skeleton.stories.tsx +54 -0
- package/src/components/Skeleton/Skeleton.tsx +32 -0
- package/src/components/Skeleton/Skeleton.types.ts +10 -0
- package/src/components/Stepper/Step.module.css +162 -0
- package/src/components/Stepper/Step.tsx +62 -0
- package/src/components/Stepper/Step.types.ts +19 -0
- package/src/components/Stepper/Stepper.module.css +39 -0
- package/src/components/Stepper/Stepper.stories.tsx +88 -0
- package/src/components/Stepper/Stepper.tsx +47 -0
- package/src/components/Stepper/Stepper.types.ts +16 -0
- package/src/components/Stepper/stepper.utils.ts +41 -0
- package/src/components/Switch/Switch.module.css +74 -0
- package/src/components/Switch/Switch.stories.tsx +56 -0
- package/src/components/Switch/Switch.tsx +36 -0
- package/src/components/Switch/Switch.types.ts +6 -0
- package/src/components/Table/Table.module.css +78 -0
- package/src/components/Table/Table.stories.tsx +124 -0
- package/src/components/Table/Table.tsx +75 -0
- package/src/components/Table/Table.types.ts +29 -0
- package/src/components/Tabs/Tabs.module.css +74 -0
- package/src/components/Tabs/Tabs.stories.tsx +48 -0
- package/src/components/Tabs/Tabs.tsx +113 -0
- package/src/components/Tabs/Tabs.types.ts +18 -0
- package/src/components/Text/Text.module.css +126 -0
- package/src/components/Text/Text.stories.tsx +128 -0
- package/src/components/Text/Text.tsx +50 -0
- package/src/components/Text/Text.types.ts +43 -0
- package/src/components/Textarea/Textarea.module.css +82 -0
- package/src/components/Textarea/Textarea.stories.tsx +99 -0
- package/src/components/Textarea/Textarea.tsx +43 -0
- package/src/components/Textarea/Textarea.types.ts +11 -0
- package/src/components/Tooltip/Tooltip.module.css +125 -0
- package/src/components/Tooltip/Tooltip.stories.tsx +68 -0
- package/src/components/Tooltip/Tooltip.tsx +87 -0
- package/src/components/Tooltip/Tooltip.types.ts +14 -0
- package/src/index.ts +132 -0
- package/src/layouts/AppLayout/AppLayout.module.css +17 -0
- package/src/layouts/AppLayout/AppLayout.stories.tsx +124 -0
- package/src/layouts/AppLayout/AppLayout.tsx +46 -0
- package/src/layouts/AppLayout/AppLayout.types.ts +50 -0
- package/src/layouts/AuthLayout/AuthLayout.module.css +49 -0
- package/src/layouts/AuthLayout/AuthLayout.stories.tsx +109 -0
- package/src/layouts/AuthLayout/AuthLayout.tsx +27 -0
- package/src/layouts/AuthLayout/AuthLayout.types.tsx +8 -0
- package/src/layouts/DashboardLayout/DashboardLayout.module.css +37 -0
- package/src/layouts/DashboardLayout/DashboardLayout.stories.tsx +144 -0
- package/src/layouts/DashboardLayout/DashboardLayout.tsx +41 -0
- package/src/layouts/DashboardLayout/DashboardLayout.types.tsx +14 -0
- package/src/layouts/SettingsLayout/SettingsLayout.module.css +39 -0
- package/src/layouts/SettingsLayout/SettingsLayout.stories.tsx +103 -0
- package/src/layouts/SettingsLayout/SettingsLayout.tsx +37 -0
- package/src/layouts/SettingsLayout/SettingsLayout.types.tsx +13 -0
- package/src/styles/ds.css +12 -0
- package/src/styles/semantic.css +56 -0
- package/src/styles/themes/dark.css +58 -0
- package/src/styles/themes/light.css +58 -0
- package/src/styles/themes/retro.css +58 -0
- package/src/styles/tokens.css +138 -0
- package/tsconfig.app.json +28 -0
- package/tsconfig.json +7 -0
- package/tsconfig.node.json +26 -0
- package/vite.config.ts +33 -0
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
import type { Meta, StoryObj } from '@storybook/react-vite';
|
|
2
|
+
|
|
3
|
+
import { Select } from './Select.tsx';
|
|
4
|
+
import { Box } from '../Box/Box.tsx';
|
|
5
|
+
|
|
6
|
+
const meta = {
|
|
7
|
+
title: 'Components/Select',
|
|
8
|
+
component: Select,
|
|
9
|
+
tags: ['autodocs'],
|
|
10
|
+
parameters: {
|
|
11
|
+
layout: 'centered',
|
|
12
|
+
},
|
|
13
|
+
argTypes: {
|
|
14
|
+
size: {
|
|
15
|
+
control: 'select',
|
|
16
|
+
options: ['sm', 'md', 'lg'],
|
|
17
|
+
},
|
|
18
|
+
error: {
|
|
19
|
+
control: 'boolean',
|
|
20
|
+
},
|
|
21
|
+
disabled: {
|
|
22
|
+
control: 'boolean',
|
|
23
|
+
},
|
|
24
|
+
},
|
|
25
|
+
} satisfies Meta<typeof Select>;
|
|
26
|
+
|
|
27
|
+
export default meta;
|
|
28
|
+
type Story = StoryObj<typeof meta>;
|
|
29
|
+
|
|
30
|
+
const options = [
|
|
31
|
+
{ value: 'option1', label: 'Option 1' },
|
|
32
|
+
{ value: 'option2', label: 'Option 2' },
|
|
33
|
+
{ value: 'option3', label: 'Option 3', disabled: true },
|
|
34
|
+
{ value: 'option4', label: 'Option 4' },
|
|
35
|
+
];
|
|
36
|
+
|
|
37
|
+
export const Default: Story = {
|
|
38
|
+
args: {
|
|
39
|
+
label: 'Select option',
|
|
40
|
+
options,
|
|
41
|
+
helperText: 'Please select an option from the list.',
|
|
42
|
+
},
|
|
43
|
+
};
|
|
44
|
+
|
|
45
|
+
export const WithError: Story = {
|
|
46
|
+
args: {
|
|
47
|
+
label: 'Select option',
|
|
48
|
+
options,
|
|
49
|
+
error: true,
|
|
50
|
+
helperText: 'This field is required.',
|
|
51
|
+
},
|
|
52
|
+
};
|
|
53
|
+
|
|
54
|
+
export const Disabled: Story = {
|
|
55
|
+
args: {
|
|
56
|
+
label: 'Select option',
|
|
57
|
+
options,
|
|
58
|
+
disabled: true,
|
|
59
|
+
},
|
|
60
|
+
};
|
|
61
|
+
|
|
62
|
+
export const Small: Story = {
|
|
63
|
+
args: {
|
|
64
|
+
size: 'sm',
|
|
65
|
+
label: 'Small Select',
|
|
66
|
+
options,
|
|
67
|
+
},
|
|
68
|
+
};
|
|
69
|
+
|
|
70
|
+
export const Large: Story = {
|
|
71
|
+
args: {
|
|
72
|
+
size: 'lg',
|
|
73
|
+
label: 'Large Select',
|
|
74
|
+
options,
|
|
75
|
+
},
|
|
76
|
+
};
|
|
77
|
+
|
|
78
|
+
export const Gallery: Story = {
|
|
79
|
+
render: () => (
|
|
80
|
+
<Box display="flex" flexDirection="column" gap={8} width="400px">
|
|
81
|
+
{(['sm', 'md', 'lg'] as const).map((size) => (
|
|
82
|
+
<Box key={size} display="flex" flexDirection="column" gap={4}>
|
|
83
|
+
<Box as="h3" m={0} style={{ textTransform: 'capitalize' }}>
|
|
84
|
+
Size: {size}
|
|
85
|
+
</Box>
|
|
86
|
+
<Select size={size} label="Default" options={options} />
|
|
87
|
+
<Select
|
|
88
|
+
size={size}
|
|
89
|
+
label="With Error"
|
|
90
|
+
options={options}
|
|
91
|
+
error
|
|
92
|
+
helperText="This field is required"
|
|
93
|
+
/>
|
|
94
|
+
<Select size={size} label="Disabled" options={options} disabled />
|
|
95
|
+
</Box>
|
|
96
|
+
))}
|
|
97
|
+
</Box>
|
|
98
|
+
),
|
|
99
|
+
};
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import clsx from 'clsx';
|
|
2
|
+
import { useId } from 'react';
|
|
3
|
+
|
|
4
|
+
import styles from './Select.module.css';
|
|
5
|
+
import type { SelectProps } from './Select.types.ts';
|
|
6
|
+
|
|
7
|
+
export const Select = ({
|
|
8
|
+
size = 'md',
|
|
9
|
+
error,
|
|
10
|
+
label,
|
|
11
|
+
helperText,
|
|
12
|
+
className,
|
|
13
|
+
id,
|
|
14
|
+
options,
|
|
15
|
+
children,
|
|
16
|
+
...props
|
|
17
|
+
}: SelectProps) => {
|
|
18
|
+
const baseId = useId();
|
|
19
|
+
const componentId = id ?? `ds-select-${baseId}`;
|
|
20
|
+
const helperId = helperText ? `${componentId}-help` : undefined;
|
|
21
|
+
|
|
22
|
+
return (
|
|
23
|
+
<div className={clsx(styles.wrapper, className)}>
|
|
24
|
+
{label && (
|
|
25
|
+
<label htmlFor={componentId} className={styles.label}>
|
|
26
|
+
{label}
|
|
27
|
+
</label>
|
|
28
|
+
)}
|
|
29
|
+
<select
|
|
30
|
+
id={componentId}
|
|
31
|
+
className={clsx(styles.selectRoot, styles[size], error && styles.error)}
|
|
32
|
+
aria-describedby={helperId}
|
|
33
|
+
aria-invalid={error || undefined}
|
|
34
|
+
{...props}
|
|
35
|
+
>
|
|
36
|
+
{options
|
|
37
|
+
? options.map((option) => (
|
|
38
|
+
<option key={option.value} value={option.value} disabled={option.disabled}>
|
|
39
|
+
{option.label}
|
|
40
|
+
</option>
|
|
41
|
+
))
|
|
42
|
+
: children}
|
|
43
|
+
</select>
|
|
44
|
+
{helperText && (
|
|
45
|
+
<span id={helperId} className={clsx(styles.helperText, error && styles.errorText)}>
|
|
46
|
+
{helperText}
|
|
47
|
+
</span>
|
|
48
|
+
)}
|
|
49
|
+
</div>
|
|
50
|
+
);
|
|
51
|
+
};
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import type { SelectHTMLAttributes, ReactNode } from 'react';
|
|
2
|
+
|
|
3
|
+
export type SelectSize = 'sm' | 'md' | 'lg';
|
|
4
|
+
|
|
5
|
+
export interface SelectOption {
|
|
6
|
+
value: string | number;
|
|
7
|
+
label: string;
|
|
8
|
+
disabled?: boolean;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
export interface SelectProps extends Omit<SelectHTMLAttributes<HTMLSelectElement>, 'size'> {
|
|
12
|
+
size?: SelectSize;
|
|
13
|
+
error?: boolean;
|
|
14
|
+
label?: string;
|
|
15
|
+
helperText?: string;
|
|
16
|
+
options?: SelectOption[];
|
|
17
|
+
children?: ReactNode;
|
|
18
|
+
}
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
.root {
|
|
2
|
+
background-color: var(--ds-skeleton);
|
|
3
|
+
display: block;
|
|
4
|
+
}
|
|
5
|
+
|
|
6
|
+
.text {
|
|
7
|
+
height: 1em;
|
|
8
|
+
margin-top: 0.1em;
|
|
9
|
+
margin-bottom: 0.1em;
|
|
10
|
+
transform: scale(1, 0.6);
|
|
11
|
+
transform-origin: 0 0;
|
|
12
|
+
border-radius: var(--ds-radius-sm);
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
.rectangular {
|
|
16
|
+
height: 1.25rem;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
.rounded {
|
|
20
|
+
border-radius: var(--ds-radius-md);
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
.circular {
|
|
24
|
+
border-radius: var(--ds-radius-full);
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
/* Animations */
|
|
28
|
+
.pulse {
|
|
29
|
+
animation: pulse 1.5s ease-in-out infinite;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
@keyframes pulse {
|
|
33
|
+
0% {
|
|
34
|
+
opacity: 1;
|
|
35
|
+
}
|
|
36
|
+
50% {
|
|
37
|
+
opacity: 0.4;
|
|
38
|
+
}
|
|
39
|
+
100% {
|
|
40
|
+
opacity: 1;
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
.wave {
|
|
45
|
+
position: relative;
|
|
46
|
+
overflow: hidden;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
.wave::after {
|
|
50
|
+
content: '';
|
|
51
|
+
position: absolute;
|
|
52
|
+
top: 0;
|
|
53
|
+
left: 0;
|
|
54
|
+
right: 0;
|
|
55
|
+
bottom: 0;
|
|
56
|
+
background: linear-gradient(90deg, transparent, var(--ds-skeleton-highlight), transparent);
|
|
57
|
+
animation: wave 1.6s linear infinite;
|
|
58
|
+
transform: translateX(-100%);
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
@keyframes wave {
|
|
62
|
+
0% {
|
|
63
|
+
transform: translateX(-100%);
|
|
64
|
+
}
|
|
65
|
+
50% {
|
|
66
|
+
transform: translateX(100%);
|
|
67
|
+
}
|
|
68
|
+
100% {
|
|
69
|
+
transform: translateX(100%);
|
|
70
|
+
}
|
|
71
|
+
}
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import type { Meta, StoryObj } from '@storybook/react-vite';
|
|
2
|
+
|
|
3
|
+
import { Skeleton } from './Skeleton.tsx';
|
|
4
|
+
import { Box } from '../Box/Box.tsx';
|
|
5
|
+
|
|
6
|
+
const meta = {
|
|
7
|
+
title: 'Components/Skeleton',
|
|
8
|
+
component: Skeleton,
|
|
9
|
+
tags: ['autodocs'],
|
|
10
|
+
parameters: {
|
|
11
|
+
layout: 'centered',
|
|
12
|
+
},
|
|
13
|
+
} satisfies Meta<typeof Skeleton>;
|
|
14
|
+
|
|
15
|
+
export default meta;
|
|
16
|
+
type Story = StoryObj<typeof meta>;
|
|
17
|
+
|
|
18
|
+
export const Rectangular: Story = {
|
|
19
|
+
args: {
|
|
20
|
+
variant: 'rectangular',
|
|
21
|
+
width: 300,
|
|
22
|
+
height: 150,
|
|
23
|
+
},
|
|
24
|
+
};
|
|
25
|
+
|
|
26
|
+
export const Circular: Story = {
|
|
27
|
+
args: {
|
|
28
|
+
variant: 'circular',
|
|
29
|
+
width: 60,
|
|
30
|
+
height: 60,
|
|
31
|
+
},
|
|
32
|
+
};
|
|
33
|
+
|
|
34
|
+
export const Text: Story = {
|
|
35
|
+
render: () => (
|
|
36
|
+
<Box width="300px">
|
|
37
|
+
<Skeleton variant="text" width="100%" />
|
|
38
|
+
<Skeleton variant="text" width="80%" />
|
|
39
|
+
<Skeleton variant="text" width="60%" />
|
|
40
|
+
</Box>
|
|
41
|
+
),
|
|
42
|
+
};
|
|
43
|
+
|
|
44
|
+
export const Combined: Story = {
|
|
45
|
+
render: () => (
|
|
46
|
+
<Box display="flex" gap={4} width="300px">
|
|
47
|
+
<Skeleton variant="circular" width={40} height={40} />
|
|
48
|
+
<Box flex={1}>
|
|
49
|
+
<Skeleton variant="text" width="100%" />
|
|
50
|
+
<Skeleton variant="text" width="70%" />
|
|
51
|
+
</Box>
|
|
52
|
+
</Box>
|
|
53
|
+
),
|
|
54
|
+
};
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import clsx from 'clsx';
|
|
2
|
+
|
|
3
|
+
import styles from './Skeleton.module.css';
|
|
4
|
+
import type { SkeletonProps } from './Skeleton.types.ts';
|
|
5
|
+
import { Box } from '../Box/Box.tsx';
|
|
6
|
+
|
|
7
|
+
export const Skeleton = ({
|
|
8
|
+
variant = 'rectangular',
|
|
9
|
+
width,
|
|
10
|
+
height,
|
|
11
|
+
animation = 'pulse',
|
|
12
|
+
className,
|
|
13
|
+
style,
|
|
14
|
+
'aria-hidden': ariaHidden,
|
|
15
|
+
...props
|
|
16
|
+
}: SkeletonProps) => {
|
|
17
|
+
return (
|
|
18
|
+
<Box
|
|
19
|
+
className={clsx(
|
|
20
|
+
styles.root,
|
|
21
|
+
styles[variant],
|
|
22
|
+
animation !== 'none' && styles[animation],
|
|
23
|
+
className
|
|
24
|
+
)}
|
|
25
|
+
width={width}
|
|
26
|
+
height={height}
|
|
27
|
+
style={style}
|
|
28
|
+
aria-hidden={ariaHidden ?? true}
|
|
29
|
+
{...props}
|
|
30
|
+
/>
|
|
31
|
+
);
|
|
32
|
+
};
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { HTMLAttributes } from 'react';
|
|
2
|
+
|
|
3
|
+
export type SkeletonVariant = 'text' | 'circular' | 'rectangular' | 'rounded';
|
|
4
|
+
|
|
5
|
+
export interface SkeletonProps extends HTMLAttributes<HTMLDivElement> {
|
|
6
|
+
variant?: SkeletonVariant;
|
|
7
|
+
width?: string | number;
|
|
8
|
+
height?: string | number;
|
|
9
|
+
animation?: 'pulse' | 'wave' | 'none';
|
|
10
|
+
}
|
|
@@ -0,0 +1,162 @@
|
|
|
1
|
+
.step {
|
|
2
|
+
display: flex;
|
|
3
|
+
align-items: center;
|
|
4
|
+
position: relative;
|
|
5
|
+
min-width: 0;
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
[data-orientation='horizontal'] .step {
|
|
9
|
+
flex: 1;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
[data-orientation='vertical'] .step {
|
|
13
|
+
flex-direction: column;
|
|
14
|
+
align-items: flex-start;
|
|
15
|
+
width: 100%;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
.stepRow {
|
|
19
|
+
display: inline-flex;
|
|
20
|
+
align-items: center;
|
|
21
|
+
gap: var(--stepper-gap);
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
[data-orientation='horizontal'] .stepRow {
|
|
25
|
+
min-width: 0;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
.interactive {
|
|
29
|
+
all: unset;
|
|
30
|
+
cursor: pointer;
|
|
31
|
+
display: inline-flex;
|
|
32
|
+
align-items: center;
|
|
33
|
+
gap: var(--stepper-gap);
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
.interactive:focus-visible {
|
|
37
|
+
outline: none;
|
|
38
|
+
box-shadow:
|
|
39
|
+
0 0 0 2px var(--ds-ring-offset),
|
|
40
|
+
0 0 0 4px var(--ds-ring);
|
|
41
|
+
border-radius: var(--ds-radius-md);
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
.interactive:disabled {
|
|
45
|
+
cursor: not-allowed;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
.marker {
|
|
49
|
+
width: var(--stepper-marker-size);
|
|
50
|
+
height: var(--stepper-marker-size);
|
|
51
|
+
border-radius: var(--ds-radius-full);
|
|
52
|
+
display: inline-flex;
|
|
53
|
+
align-items: center;
|
|
54
|
+
justify-content: center;
|
|
55
|
+
font-size: var(--stepper-font-size);
|
|
56
|
+
font-weight: var(--ds-font-weight-medium);
|
|
57
|
+
border: 1px solid var(--ds-border-1);
|
|
58
|
+
background-color: var(--ds-surface-0);
|
|
59
|
+
color: var(--ds-text-2);
|
|
60
|
+
flex-shrink: 0;
|
|
61
|
+
transition:
|
|
62
|
+
background-color var(--ds-transition-fast),
|
|
63
|
+
color var(--ds-transition-fast),
|
|
64
|
+
border-color var(--ds-transition-fast);
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
.text {
|
|
68
|
+
display: inline-flex;
|
|
69
|
+
flex-direction: column;
|
|
70
|
+
gap: var(--ds-space-1);
|
|
71
|
+
min-width: 0;
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
.label {
|
|
75
|
+
font-size: var(--stepper-font-size);
|
|
76
|
+
font-weight: var(--ds-font-weight-medium);
|
|
77
|
+
color: var(--ds-text-1);
|
|
78
|
+
white-space: nowrap;
|
|
79
|
+
overflow: hidden;
|
|
80
|
+
text-overflow: ellipsis;
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
.description {
|
|
84
|
+
font-size: var(--stepper-description-size);
|
|
85
|
+
color: var(--ds-text-2);
|
|
86
|
+
line-height: var(--ds-line-height-tight);
|
|
87
|
+
white-space: nowrap;
|
|
88
|
+
overflow: hidden;
|
|
89
|
+
text-overflow: ellipsis;
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
.connector {
|
|
93
|
+
background-color: var(--ds-border-1);
|
|
94
|
+
border-radius: var(--ds-radius-full);
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
[data-orientation='horizontal'] .connector {
|
|
98
|
+
height: 2px;
|
|
99
|
+
flex: 1;
|
|
100
|
+
margin-left: var(--ds-space-3);
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
[data-orientation='vertical'] .connector {
|
|
104
|
+
width: 2px;
|
|
105
|
+
height: var(--ds-space-8);
|
|
106
|
+
margin-left: calc(var(--stepper-marker-size) / 2 - 1px);
|
|
107
|
+
margin-top: var(--ds-space-2);
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
.completed .marker {
|
|
111
|
+
background-color: var(--ds-success);
|
|
112
|
+
border-color: var(--ds-success);
|
|
113
|
+
color: var(--ds-text-on-brand);
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
.completed .label {
|
|
117
|
+
color: var(--ds-text-1);
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
.connector-completed {
|
|
121
|
+
background-color: var(--ds-success);
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
.current .marker {
|
|
125
|
+
background-color: var(--ds-info-subtle);
|
|
126
|
+
border-color: var(--ds-info);
|
|
127
|
+
color: var(--ds-info);
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
.current .label {
|
|
131
|
+
color: var(--ds-text-1);
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
.connector-current {
|
|
135
|
+
background-color: var(--ds-info);
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
.error .marker {
|
|
139
|
+
background-color: var(--ds-danger);
|
|
140
|
+
border-color: var(--ds-danger);
|
|
141
|
+
color: var(--ds-text-on-brand);
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
.error .label {
|
|
145
|
+
color: var(--ds-danger);
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
.connector-error {
|
|
149
|
+
background-color: var(--ds-danger);
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
.upcoming .label {
|
|
153
|
+
color: var(--ds-text-2);
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
.disabled {
|
|
157
|
+
opacity: 0.5;
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
.disabled .interactive {
|
|
161
|
+
cursor: not-allowed;
|
|
162
|
+
}
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import clsx from 'clsx';
|
|
2
|
+
import type { ElementType, KeyboardEvent } from 'react';
|
|
3
|
+
|
|
4
|
+
import styles from './Step.module.css';
|
|
5
|
+
import type { StepProps } from './Step.types.ts';
|
|
6
|
+
|
|
7
|
+
export const Step = ({
|
|
8
|
+
step,
|
|
9
|
+
index,
|
|
10
|
+
status,
|
|
11
|
+
isInteractive,
|
|
12
|
+
onStepClick,
|
|
13
|
+
isLast,
|
|
14
|
+
id,
|
|
15
|
+
}: StepProps) => {
|
|
16
|
+
const isDisabled = Boolean(step.disabled);
|
|
17
|
+
const StepContent: ElementType = isInteractive ? 'button' : 'div';
|
|
18
|
+
const markerContent = status === 'error' ? '!' : String(index + 1);
|
|
19
|
+
|
|
20
|
+
const handleClick = () => {
|
|
21
|
+
if (isInteractive && !isDisabled) {
|
|
22
|
+
onStepClick?.(step, index);
|
|
23
|
+
}
|
|
24
|
+
};
|
|
25
|
+
|
|
26
|
+
const handleKeyDown = (event: KeyboardEvent) => {
|
|
27
|
+
if (isInteractive && !isDisabled && (event.key === 'Enter' || event.key === ' ')) {
|
|
28
|
+
event.preventDefault();
|
|
29
|
+
onStepClick?.(step, index);
|
|
30
|
+
}
|
|
31
|
+
};
|
|
32
|
+
|
|
33
|
+
return (
|
|
34
|
+
<li className={clsx(styles.step, styles[status], isDisabled && styles.disabled)}>
|
|
35
|
+
<StepContent
|
|
36
|
+
id={id}
|
|
37
|
+
type={isInteractive ? 'button' : undefined}
|
|
38
|
+
className={clsx(styles.stepRow, isInteractive && styles.interactive)}
|
|
39
|
+
onClick={handleClick}
|
|
40
|
+
onKeyDown={handleKeyDown}
|
|
41
|
+
aria-current={status === 'current' ? 'step' : undefined}
|
|
42
|
+
aria-disabled={isDisabled ? true : undefined}
|
|
43
|
+
disabled={isInteractive && isDisabled ? true : undefined}
|
|
44
|
+
tabIndex={isInteractive && !isDisabled ? 0 : undefined}
|
|
45
|
+
>
|
|
46
|
+
<span className={styles.marker} aria-hidden="true">
|
|
47
|
+
{markerContent}
|
|
48
|
+
</span>
|
|
49
|
+
<span className={styles.text}>
|
|
50
|
+
<span className={styles.label}>{step.label}</span>
|
|
51
|
+
{step.description && <span className={styles.description}>{step.description}</span>}
|
|
52
|
+
</span>
|
|
53
|
+
</StepContent>
|
|
54
|
+
{!isLast && (
|
|
55
|
+
<span
|
|
56
|
+
className={clsx(styles.connector, styles[`connector-${status}`])}
|
|
57
|
+
aria-hidden="true"
|
|
58
|
+
/>
|
|
59
|
+
)}
|
|
60
|
+
</li>
|
|
61
|
+
);
|
|
62
|
+
};
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
export type StepperStatus = 'completed' | 'current' | 'upcoming' | 'error';
|
|
2
|
+
|
|
3
|
+
export interface StepOptions {
|
|
4
|
+
id: string;
|
|
5
|
+
label: string;
|
|
6
|
+
description?: string;
|
|
7
|
+
status?: StepperStatus;
|
|
8
|
+
disabled?: boolean;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
export interface StepProps {
|
|
12
|
+
step: StepOptions;
|
|
13
|
+
index: number;
|
|
14
|
+
status: StepperStatus;
|
|
15
|
+
isInteractive: boolean;
|
|
16
|
+
onStepClick?: (step: StepOptions, index: number) => void;
|
|
17
|
+
isLast: boolean;
|
|
18
|
+
id?: string;
|
|
19
|
+
}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
.root {
|
|
2
|
+
--stepper-marker-size: var(--ds-space-8);
|
|
3
|
+
--stepper-font-size: var(--ds-font-size-sm);
|
|
4
|
+
--stepper-description-size: var(--ds-font-size-xs);
|
|
5
|
+
--stepper-gap: var(--ds-space-3);
|
|
6
|
+
|
|
7
|
+
display: flex;
|
|
8
|
+
list-style: none;
|
|
9
|
+
padding: 0;
|
|
10
|
+
margin: 0;
|
|
11
|
+
font-family: var(--ds-font-family-base);
|
|
12
|
+
color: var(--ds-text-1);
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
.sm {
|
|
16
|
+
--stepper-marker-size: var(--ds-space-6);
|
|
17
|
+
--stepper-font-size: var(--ds-font-size-xs);
|
|
18
|
+
--stepper-description-size: var(--ds-font-size-xs);
|
|
19
|
+
--stepper-gap: var(--ds-space-2);
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
.lg {
|
|
23
|
+
--stepper-marker-size: var(--ds-space-10);
|
|
24
|
+
--stepper-font-size: var(--ds-font-size-base);
|
|
25
|
+
--stepper-description-size: var(--ds-font-size-sm);
|
|
26
|
+
--stepper-gap: var(--ds-space-4);
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
.horizontal {
|
|
30
|
+
flex-direction: row;
|
|
31
|
+
align-items: center;
|
|
32
|
+
gap: var(--ds-space-3);
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
.vertical {
|
|
36
|
+
flex-direction: column;
|
|
37
|
+
align-items: flex-start;
|
|
38
|
+
gap: var(--ds-space-4);
|
|
39
|
+
}
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
import type { Meta, StoryObj } from '@storybook/react-vite';
|
|
2
|
+
|
|
3
|
+
import type { StepOptions } from './Step.types.ts';
|
|
4
|
+
import { Stepper } from './Stepper.tsx';
|
|
5
|
+
import { Box } from '../Box/Box.tsx';
|
|
6
|
+
|
|
7
|
+
const meta = {
|
|
8
|
+
title: 'Components/Stepper',
|
|
9
|
+
component: Stepper,
|
|
10
|
+
tags: ['autodocs'],
|
|
11
|
+
parameters: {
|
|
12
|
+
layout: 'centered',
|
|
13
|
+
},
|
|
14
|
+
} satisfies Meta<typeof Stepper>;
|
|
15
|
+
|
|
16
|
+
export default meta;
|
|
17
|
+
type Story = StoryObj<typeof meta>;
|
|
18
|
+
|
|
19
|
+
const steps: StepOptions[] = [
|
|
20
|
+
{
|
|
21
|
+
id: 'account',
|
|
22
|
+
label: 'Account',
|
|
23
|
+
description: 'Create login details',
|
|
24
|
+
},
|
|
25
|
+
{
|
|
26
|
+
id: 'profile',
|
|
27
|
+
label: 'Profile',
|
|
28
|
+
description: 'Add personal information',
|
|
29
|
+
},
|
|
30
|
+
{
|
|
31
|
+
id: 'billing',
|
|
32
|
+
label: 'Billing',
|
|
33
|
+
description: 'Choose a plan',
|
|
34
|
+
},
|
|
35
|
+
{
|
|
36
|
+
id: 'review',
|
|
37
|
+
label: 'Review',
|
|
38
|
+
description: 'Confirm and submit',
|
|
39
|
+
},
|
|
40
|
+
];
|
|
41
|
+
|
|
42
|
+
export const Default: Story = {
|
|
43
|
+
args: {
|
|
44
|
+
steps,
|
|
45
|
+
currentStep: 1,
|
|
46
|
+
},
|
|
47
|
+
};
|
|
48
|
+
|
|
49
|
+
export const Vertical: Story = {
|
|
50
|
+
args: {
|
|
51
|
+
steps,
|
|
52
|
+
currentStep: 2,
|
|
53
|
+
orientation: 'vertical',
|
|
54
|
+
},
|
|
55
|
+
render: (args) => (
|
|
56
|
+
<Box width="360px">
|
|
57
|
+
<Stepper {...args} />
|
|
58
|
+
</Box>
|
|
59
|
+
),
|
|
60
|
+
};
|
|
61
|
+
|
|
62
|
+
export const WithStatuses: Story = {
|
|
63
|
+
args: {
|
|
64
|
+
steps: [
|
|
65
|
+
{ id: 'done', label: 'Done', description: 'Completed step', status: 'completed' },
|
|
66
|
+
{ id: 'current', label: 'Current', description: 'In progress', status: 'current' },
|
|
67
|
+
{ id: 'error', label: 'Error', description: 'Needs attention', status: 'error' },
|
|
68
|
+
{ id: 'upcoming', label: 'Upcoming', description: 'Not started', status: 'upcoming' },
|
|
69
|
+
],
|
|
70
|
+
},
|
|
71
|
+
};
|
|
72
|
+
|
|
73
|
+
export const Clickable: Story = {
|
|
74
|
+
args: {
|
|
75
|
+
steps,
|
|
76
|
+
currentStep: 0,
|
|
77
|
+
},
|
|
78
|
+
render: (args) => (
|
|
79
|
+
<Box width="520px">
|
|
80
|
+
<Stepper
|
|
81
|
+
{...args}
|
|
82
|
+
onStepClick={(step) => {
|
|
83
|
+
console.log('Clicked step:', step.id);
|
|
84
|
+
}}
|
|
85
|
+
/>
|
|
86
|
+
</Box>
|
|
87
|
+
),
|
|
88
|
+
};
|