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,67 @@
|
|
|
1
|
+
.wrapper {
|
|
2
|
+
width: 100%;
|
|
3
|
+
display: flex;
|
|
4
|
+
flex-direction: column;
|
|
5
|
+
gap: var(--ds-space-1);
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
.labelWrapper {
|
|
9
|
+
display: flex;
|
|
10
|
+
justify-content: space-between;
|
|
11
|
+
align-items: center;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
.label {
|
|
15
|
+
font-family: var(--ds-font-family-base);
|
|
16
|
+
font-size: var(--ds-font-size-sm);
|
|
17
|
+
font-weight: var(--ds-font-weight-medium);
|
|
18
|
+
color: var(--ds-text-1);
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
.percentage {
|
|
22
|
+
font-family: var(--ds-font-family-base);
|
|
23
|
+
font-size: var(--ds-font-size-xs);
|
|
24
|
+
color: var(--ds-text-2);
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
.progressRoot {
|
|
28
|
+
width: 100%;
|
|
29
|
+
background-color: var(--ds-surface-1);
|
|
30
|
+
border-radius: var(--ds-radius-full);
|
|
31
|
+
overflow: hidden;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
.indicator {
|
|
35
|
+
height: 100%;
|
|
36
|
+
transition: width var(--ds-transition-base);
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
/* Sizes */
|
|
40
|
+
.sm .progressRoot {
|
|
41
|
+
height: var(--ds-space-1);
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
.md .progressRoot {
|
|
45
|
+
height: var(--ds-space-2);
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
.lg .progressRoot {
|
|
49
|
+
height: var(--ds-space-3);
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
/* Intents */
|
|
53
|
+
.info .indicator {
|
|
54
|
+
background-color: var(--ds-info);
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
.success .indicator {
|
|
58
|
+
background-color: var(--ds-success);
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
.warning .indicator {
|
|
62
|
+
background-color: var(--ds-warning);
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
.danger .indicator {
|
|
66
|
+
background-color: var(--ds-danger);
|
|
67
|
+
}
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
import type { Meta, StoryObj } from '@storybook/react-vite';
|
|
2
|
+
|
|
3
|
+
import { ProgressBar } from './ProgressBar.tsx';
|
|
4
|
+
import { Box } from '../Box/Box.tsx';
|
|
5
|
+
|
|
6
|
+
const meta = {
|
|
7
|
+
title: 'Components/ProgressBar',
|
|
8
|
+
component: ProgressBar,
|
|
9
|
+
tags: ['autodocs'],
|
|
10
|
+
parameters: {
|
|
11
|
+
layout: 'centered',
|
|
12
|
+
},
|
|
13
|
+
argTypes: {
|
|
14
|
+
value: {
|
|
15
|
+
control: { type: 'range', min: 0, max: 100 },
|
|
16
|
+
},
|
|
17
|
+
size: {
|
|
18
|
+
control: 'select',
|
|
19
|
+
options: ['sm', 'md', 'lg'],
|
|
20
|
+
},
|
|
21
|
+
intent: {
|
|
22
|
+
control: 'select',
|
|
23
|
+
options: ['info', 'success', 'warning', 'danger'],
|
|
24
|
+
},
|
|
25
|
+
},
|
|
26
|
+
} satisfies Meta<typeof ProgressBar>;
|
|
27
|
+
|
|
28
|
+
export default meta;
|
|
29
|
+
type Story = StoryObj<typeof meta>;
|
|
30
|
+
|
|
31
|
+
export const Default: Story = {
|
|
32
|
+
args: {
|
|
33
|
+
value: 40,
|
|
34
|
+
showLabel: true,
|
|
35
|
+
label: 'Loading files...',
|
|
36
|
+
},
|
|
37
|
+
};
|
|
38
|
+
|
|
39
|
+
export const Intents: Story = {
|
|
40
|
+
args: {
|
|
41
|
+
value: 50,
|
|
42
|
+
},
|
|
43
|
+
render: (args) => (
|
|
44
|
+
<Box display="flex" flexDirection="column" gap={4} width="300px">
|
|
45
|
+
<ProgressBar {...args} intent="info" label="Info" value={25} showLabel />
|
|
46
|
+
<ProgressBar {...args} intent="success" label="Success" value={50} showLabel />
|
|
47
|
+
<ProgressBar {...args} intent="warning" label="Warning" value={75} showLabel />
|
|
48
|
+
<ProgressBar {...args} intent="danger" label="Danger" value={100} showLabel />
|
|
49
|
+
</Box>
|
|
50
|
+
),
|
|
51
|
+
};
|
|
52
|
+
|
|
53
|
+
export const Sizes: Story = {
|
|
54
|
+
args: {
|
|
55
|
+
value: 50,
|
|
56
|
+
},
|
|
57
|
+
render: (args) => (
|
|
58
|
+
<Box display="flex" flexDirection="column" gap={4} width="300px">
|
|
59
|
+
<ProgressBar {...args} size="sm" label="Small" value={40} />
|
|
60
|
+
<ProgressBar {...args} size="md" label="Medium" value={60} />
|
|
61
|
+
<ProgressBar {...args} size="lg" label="Large" value={80} />
|
|
62
|
+
</Box>
|
|
63
|
+
),
|
|
64
|
+
};
|
|
65
|
+
|
|
66
|
+
export const All: Story = {
|
|
67
|
+
args: {
|
|
68
|
+
value: 60,
|
|
69
|
+
},
|
|
70
|
+
render: (args) => (
|
|
71
|
+
<Box display="flex" flexDirection="column" gap={8} width="400px">
|
|
72
|
+
{(['sm', 'md', 'lg'] as const).map((size) => (
|
|
73
|
+
<Box key={size} display="flex" flexDirection="column" gap={4}>
|
|
74
|
+
<Box as="h3" m={0} style={{ textTransform: 'capitalize' }}>
|
|
75
|
+
Size: {size}
|
|
76
|
+
</Box>
|
|
77
|
+
{(['info', 'success', 'warning', 'danger'] as const).map((intent) => (
|
|
78
|
+
<ProgressBar
|
|
79
|
+
key={intent}
|
|
80
|
+
{...args}
|
|
81
|
+
size={size}
|
|
82
|
+
intent={intent}
|
|
83
|
+
label={intent}
|
|
84
|
+
showLabel
|
|
85
|
+
/>
|
|
86
|
+
))}
|
|
87
|
+
</Box>
|
|
88
|
+
))}
|
|
89
|
+
</Box>
|
|
90
|
+
),
|
|
91
|
+
};
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import clsx from 'clsx';
|
|
2
|
+
import { useId } from 'react';
|
|
3
|
+
|
|
4
|
+
import styles from './ProgressBar.module.css';
|
|
5
|
+
import type { ProgressBarProps } from './ProgressBar.types.ts';
|
|
6
|
+
|
|
7
|
+
export const ProgressBar = ({
|
|
8
|
+
value,
|
|
9
|
+
max = 100,
|
|
10
|
+
size = 'md',
|
|
11
|
+
intent = 'info',
|
|
12
|
+
showLabel = false,
|
|
13
|
+
label,
|
|
14
|
+
className,
|
|
15
|
+
id,
|
|
16
|
+
}: ProgressBarProps) => {
|
|
17
|
+
const baseId = useId();
|
|
18
|
+
const componentId = id ?? `ds-progressbar-${baseId}`;
|
|
19
|
+
const safeMax = max > 0 ? max : 0;
|
|
20
|
+
const clampedValue = Math.min(Math.max(0, value), safeMax);
|
|
21
|
+
const percentage = safeMax > 0 ? Math.min(Math.max(0, (clampedValue / safeMax) * 100), 100) : 0;
|
|
22
|
+
const labelId = label ? `${componentId}-label` : undefined;
|
|
23
|
+
|
|
24
|
+
return (
|
|
25
|
+
<div id={componentId} className={clsx(styles.wrapper, styles[size], styles[intent], className)}>
|
|
26
|
+
{(label || showLabel) && (
|
|
27
|
+
<div className={styles.labelWrapper}>
|
|
28
|
+
{label && (
|
|
29
|
+
<span id={labelId} className={styles.label}>
|
|
30
|
+
{label}
|
|
31
|
+
</span>
|
|
32
|
+
)}
|
|
33
|
+
{showLabel && <span className={styles.percentage}>{Math.round(percentage)}%</span>}
|
|
34
|
+
</div>
|
|
35
|
+
)}
|
|
36
|
+
<div
|
|
37
|
+
className={styles.progressRoot}
|
|
38
|
+
role="progressbar"
|
|
39
|
+
aria-valuenow={clampedValue}
|
|
40
|
+
aria-valuemin={0}
|
|
41
|
+
aria-valuemax={max}
|
|
42
|
+
aria-labelledby={labelId}
|
|
43
|
+
aria-label={label ? undefined : 'Progress'}
|
|
44
|
+
>
|
|
45
|
+
<div className={styles.indicator} style={{ width: `${percentage}%` }} />
|
|
46
|
+
</div>
|
|
47
|
+
</div>
|
|
48
|
+
);
|
|
49
|
+
};
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
export type ProgressBarSize = 'sm' | 'md' | 'lg';
|
|
2
|
+
export type ProgressBarIntent = 'info' | 'success' | 'warning' | 'danger';
|
|
3
|
+
|
|
4
|
+
export interface ProgressBarProps {
|
|
5
|
+
id?: string;
|
|
6
|
+
value: number;
|
|
7
|
+
max?: number;
|
|
8
|
+
size?: ProgressBarSize;
|
|
9
|
+
intent?: ProgressBarIntent;
|
|
10
|
+
showLabel?: boolean;
|
|
11
|
+
label?: string;
|
|
12
|
+
className?: string;
|
|
13
|
+
}
|
|
@@ -0,0 +1,162 @@
|
|
|
1
|
+
.wrapper {
|
|
2
|
+
display: flex;
|
|
3
|
+
flex-direction: column;
|
|
4
|
+
gap: var(--ds-space-1);
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
.label {
|
|
8
|
+
display: inline-flex;
|
|
9
|
+
align-items: flex-start;
|
|
10
|
+
gap: var(--ds-space-2);
|
|
11
|
+
cursor: pointer;
|
|
12
|
+
user-select: none;
|
|
13
|
+
font-family: var(--ds-font-family-base);
|
|
14
|
+
color: var(--ds-text-1);
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
.label.sm {
|
|
18
|
+
font-size: var(--ds-font-size-xs);
|
|
19
|
+
}
|
|
20
|
+
.label.md {
|
|
21
|
+
font-size: var(--ds-font-size-sm);
|
|
22
|
+
}
|
|
23
|
+
.label.lg {
|
|
24
|
+
font-size: var(--ds-font-size-base);
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
.inputWrapper {
|
|
28
|
+
position: relative;
|
|
29
|
+
display: flex;
|
|
30
|
+
align-items: center;
|
|
31
|
+
justify-content: center;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
.radioRoot {
|
|
35
|
+
position: absolute;
|
|
36
|
+
opacity: 0;
|
|
37
|
+
width: 100%;
|
|
38
|
+
height: 100%;
|
|
39
|
+
cursor: pointer;
|
|
40
|
+
margin: 0;
|
|
41
|
+
z-index: 1;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
.checkmark {
|
|
45
|
+
display: flex;
|
|
46
|
+
align-items: center;
|
|
47
|
+
justify-content: center;
|
|
48
|
+
border: 1px solid var(--ds-border-1);
|
|
49
|
+
border-radius: var(--ds-radius-full);
|
|
50
|
+
background-color: var(--ds-surface-0);
|
|
51
|
+
transition: all var(--ds-transition-fast);
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
/* Sizes */
|
|
55
|
+
.sm .checkmark {
|
|
56
|
+
width: var(--ds-space-4);
|
|
57
|
+
height: var(--ds-space-4);
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
.md .checkmark {
|
|
61
|
+
width: calc(var(--ds-space-5, 1.25rem));
|
|
62
|
+
height: calc(var(--ds-space-5, 1.25rem));
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
.lg .checkmark {
|
|
66
|
+
width: var(--ds-space-6);
|
|
67
|
+
height: var(--ds-space-6);
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
/* Inner circle for checked state */
|
|
71
|
+
.checkmark::after {
|
|
72
|
+
content: '';
|
|
73
|
+
display: block;
|
|
74
|
+
border-radius: var(--ds-radius-full);
|
|
75
|
+
background-color: var(--ds-surface-0);
|
|
76
|
+
transform: scale(0);
|
|
77
|
+
transition: transform var(--ds-transition-fast);
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
.sm .checkmark::after {
|
|
81
|
+
width: var(--ds-space-2);
|
|
82
|
+
height: var(--ds-space-2);
|
|
83
|
+
}
|
|
84
|
+
.md .checkmark::after {
|
|
85
|
+
width: var(--ds-space-2);
|
|
86
|
+
height: var(--ds-space-2);
|
|
87
|
+
}
|
|
88
|
+
.lg .checkmark::after {
|
|
89
|
+
width: var(--ds-space-3);
|
|
90
|
+
height: var(--ds-space-3);
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
/* Checked State */
|
|
94
|
+
.radioRoot:checked ~ .checkmark {
|
|
95
|
+
background-color: var(--ds-info);
|
|
96
|
+
border-color: var(--ds-info);
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
.radioRoot:checked ~ .checkmark::after {
|
|
100
|
+
transform: scale(1);
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
/* Focus State */
|
|
104
|
+
.radioRoot:focus-visible ~ .checkmark {
|
|
105
|
+
box-shadow:
|
|
106
|
+
0 0 0 2px var(--ds-ring-offset),
|
|
107
|
+
0 0 0 4px var(--ds-ring);
|
|
108
|
+
border-color: var(--ds-ring);
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
/* Hover State */
|
|
112
|
+
.label:hover .radioRoot:not(:disabled):not(:checked) ~ .checkmark {
|
|
113
|
+
border-color: var(--ds-info);
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
/* Disabled State */
|
|
117
|
+
.radioRoot:disabled {
|
|
118
|
+
cursor: not-allowed;
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
.radioRoot:disabled ~ .checkmark {
|
|
122
|
+
background-color: var(--ds-surface-1);
|
|
123
|
+
border-color: var(--ds-border-2);
|
|
124
|
+
opacity: 0.7;
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
.radioRoot:disabled ~ .labelText {
|
|
128
|
+
color: var(--ds-text-2);
|
|
129
|
+
cursor: not-allowed;
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
/* Error State */
|
|
133
|
+
.radioRoot.error ~ .checkmark {
|
|
134
|
+
border-color: var(--ds-danger);
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
.radioRoot.error:checked ~ .checkmark {
|
|
138
|
+
background-color: var(--ds-danger);
|
|
139
|
+
border-color: var(--ds-danger);
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
.helperText {
|
|
143
|
+
font-family: var(--ds-font-family-base);
|
|
144
|
+
font-size: var(--ds-font-size-xs);
|
|
145
|
+
color: var(--ds-text-2);
|
|
146
|
+
padding-left: calc(var(--ds-space-5, 1.25rem) + var(--ds-space-2));
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
.sm ~ .helperText {
|
|
150
|
+
padding-left: calc(var(--ds-space-4) + var(--ds-space-2));
|
|
151
|
+
}
|
|
152
|
+
.lg ~ .helperText {
|
|
153
|
+
padding-left: calc(var(--ds-space-6) + var(--ds-space-2));
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
.helperText.errorText {
|
|
157
|
+
color: var(--ds-danger);
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
.labelText {
|
|
161
|
+
line-height: var(--ds-line-height-base);
|
|
162
|
+
}
|
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
import type { Meta, StoryObj } from '@storybook/react-vite';
|
|
2
|
+
|
|
3
|
+
import { RadioButton } from './RadioButton.tsx';
|
|
4
|
+
import { Box } from '../Box/Box.tsx';
|
|
5
|
+
|
|
6
|
+
const meta = {
|
|
7
|
+
title: 'Components/RadioButton',
|
|
8
|
+
component: RadioButton,
|
|
9
|
+
tags: ['autodocs'],
|
|
10
|
+
parameters: {
|
|
11
|
+
layout: 'centered',
|
|
12
|
+
},
|
|
13
|
+
argTypes: {
|
|
14
|
+
size: {
|
|
15
|
+
control: 'select',
|
|
16
|
+
options: ['sm', 'md', 'lg'],
|
|
17
|
+
},
|
|
18
|
+
disabled: {
|
|
19
|
+
control: 'boolean',
|
|
20
|
+
},
|
|
21
|
+
error: {
|
|
22
|
+
control: 'boolean',
|
|
23
|
+
},
|
|
24
|
+
},
|
|
25
|
+
} satisfies Meta<typeof RadioButton>;
|
|
26
|
+
|
|
27
|
+
export default meta;
|
|
28
|
+
type Story = StoryObj<typeof meta>;
|
|
29
|
+
|
|
30
|
+
export const Default: Story = {
|
|
31
|
+
args: {
|
|
32
|
+
label: 'Radio Option',
|
|
33
|
+
name: 'default',
|
|
34
|
+
},
|
|
35
|
+
};
|
|
36
|
+
|
|
37
|
+
export const Group: Story = {
|
|
38
|
+
render: () => (
|
|
39
|
+
<Box display="flex" flexDirection="column" gap={3}>
|
|
40
|
+
<RadioButton name="group" label="Option 1" defaultChecked />
|
|
41
|
+
<RadioButton name="group" label="Option 2" />
|
|
42
|
+
<RadioButton name="group" label="Option 3" />
|
|
43
|
+
</Box>
|
|
44
|
+
),
|
|
45
|
+
};
|
|
46
|
+
|
|
47
|
+
export const Sizes: Story = {
|
|
48
|
+
render: () => (
|
|
49
|
+
<Box display="flex" flexDirection="column" gap={4}>
|
|
50
|
+
<RadioButton size="sm" name="sizes" label="Small Radio" />
|
|
51
|
+
<RadioButton size="md" name="sizes" label="Medium Radio" defaultChecked />
|
|
52
|
+
<RadioButton size="lg" name="sizes" label="Large Radio" />
|
|
53
|
+
</Box>
|
|
54
|
+
),
|
|
55
|
+
};
|
|
56
|
+
|
|
57
|
+
export const WithHelperText: Story = {
|
|
58
|
+
args: {
|
|
59
|
+
label: 'Radio with helper',
|
|
60
|
+
helperText: 'This is some useful information.',
|
|
61
|
+
name: 'helper',
|
|
62
|
+
},
|
|
63
|
+
};
|
|
64
|
+
|
|
65
|
+
export const Error: Story = {
|
|
66
|
+
args: {
|
|
67
|
+
label: 'Radio with error',
|
|
68
|
+
error: true,
|
|
69
|
+
helperText: 'Something went wrong.',
|
|
70
|
+
name: 'error',
|
|
71
|
+
defaultChecked: true,
|
|
72
|
+
},
|
|
73
|
+
};
|
|
74
|
+
|
|
75
|
+
export const Disabled: Story = {
|
|
76
|
+
render: () => (
|
|
77
|
+
<Box display="flex" flexDirection="column" gap={3}>
|
|
78
|
+
<RadioButton name="disabled" label="Disabled unchecked" disabled />
|
|
79
|
+
<RadioButton name="disabled" label="Disabled checked" disabled defaultChecked />
|
|
80
|
+
</Box>
|
|
81
|
+
),
|
|
82
|
+
};
|
|
83
|
+
|
|
84
|
+
export const Gallery: Story = {
|
|
85
|
+
render: () => (
|
|
86
|
+
<Box display="flex" flexDirection="column" gap={8}>
|
|
87
|
+
{(['sm', 'md', 'lg'] as const).map((size) => (
|
|
88
|
+
<Box key={size} display="flex" flexDirection="column" gap={4}>
|
|
89
|
+
<Box as="h3" m={0} style={{ textTransform: 'capitalize' }}>
|
|
90
|
+
Size: {size}
|
|
91
|
+
</Box>
|
|
92
|
+
<Box display="flex" gap={4}>
|
|
93
|
+
<RadioButton size={size} name={`radio-${size}`} label="Default" />
|
|
94
|
+
<RadioButton size={size} name={`radio-${size}`} label="Checked" defaultChecked />
|
|
95
|
+
<RadioButton
|
|
96
|
+
size={size}
|
|
97
|
+
name={`radio-helper-${size}`}
|
|
98
|
+
label="With helper"
|
|
99
|
+
helperText="Help text"
|
|
100
|
+
/>
|
|
101
|
+
<RadioButton
|
|
102
|
+
size={size}
|
|
103
|
+
name={`radio-error-${size}`}
|
|
104
|
+
label="Error"
|
|
105
|
+
error
|
|
106
|
+
helperText="Error text"
|
|
107
|
+
/>
|
|
108
|
+
<RadioButton size={size} name={`radio-disabled-${size}`} label="Disabled" disabled />
|
|
109
|
+
</Box>
|
|
110
|
+
</Box>
|
|
111
|
+
))}
|
|
112
|
+
</Box>
|
|
113
|
+
),
|
|
114
|
+
};
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import clsx from 'clsx';
|
|
2
|
+
import { useId } from 'react';
|
|
3
|
+
|
|
4
|
+
import styles from './RadioButton.module.css';
|
|
5
|
+
import type { RadioButtonProps } from './RadioButton.types.ts';
|
|
6
|
+
|
|
7
|
+
export const RadioButton = ({
|
|
8
|
+
size = 'md',
|
|
9
|
+
label,
|
|
10
|
+
helperText,
|
|
11
|
+
error,
|
|
12
|
+
className,
|
|
13
|
+
id,
|
|
14
|
+
...props
|
|
15
|
+
}: RadioButtonProps) => {
|
|
16
|
+
const baseId = useId();
|
|
17
|
+
const componentId = id ?? `ds-radio-${baseId}`;
|
|
18
|
+
const helperId = helperText ? `${componentId}-help` : undefined;
|
|
19
|
+
|
|
20
|
+
return (
|
|
21
|
+
<div className={clsx(styles.wrapper, className)}>
|
|
22
|
+
<label htmlFor={componentId} className={clsx(styles.label, styles[size])}>
|
|
23
|
+
<div className={styles.inputWrapper}>
|
|
24
|
+
<input
|
|
25
|
+
type="radio"
|
|
26
|
+
id={componentId}
|
|
27
|
+
className={clsx(styles.radioRoot, styles[size], error && styles.error)}
|
|
28
|
+
aria-describedby={helperId}
|
|
29
|
+
aria-invalid={error || undefined}
|
|
30
|
+
{...props}
|
|
31
|
+
/>
|
|
32
|
+
<span className={styles.checkmark} />
|
|
33
|
+
</div>
|
|
34
|
+
{label && <span className={styles.labelText}>{label}</span>}
|
|
35
|
+
</label>
|
|
36
|
+
{helperText && (
|
|
37
|
+
<span id={helperId} className={clsx(styles.helperText, error && styles.errorText)}>
|
|
38
|
+
{helperText}
|
|
39
|
+
</span>
|
|
40
|
+
)}
|
|
41
|
+
</div>
|
|
42
|
+
);
|
|
43
|
+
};
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { InputHTMLAttributes } from 'react';
|
|
2
|
+
|
|
3
|
+
export type RadioButtonSize = 'sm' | 'md' | 'lg';
|
|
4
|
+
|
|
5
|
+
export interface RadioButtonProps extends Omit<InputHTMLAttributes<HTMLInputElement>, 'size'> {
|
|
6
|
+
size?: RadioButtonSize;
|
|
7
|
+
label?: string;
|
|
8
|
+
helperText?: string;
|
|
9
|
+
error?: boolean;
|
|
10
|
+
}
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
.wrapper {
|
|
2
|
+
display: flex;
|
|
3
|
+
flex-direction: column;
|
|
4
|
+
gap: var(--ds-space-1);
|
|
5
|
+
width: 100%;
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
.label {
|
|
9
|
+
font-family: var(--ds-font-family-base);
|
|
10
|
+
font-size: var(--ds-font-size-sm);
|
|
11
|
+
font-weight: var(--ds-font-weight-medium);
|
|
12
|
+
color: var(--ds-text-1);
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
.selectRoot {
|
|
16
|
+
box-sizing: border-box;
|
|
17
|
+
width: 100%;
|
|
18
|
+
font-family: var(--ds-font-family-base);
|
|
19
|
+
border: 1px solid var(--ds-border-1);
|
|
20
|
+
border-radius: var(--ds-radius-md);
|
|
21
|
+
background-color: var(--ds-surface-0);
|
|
22
|
+
color: var(--ds-text-1);
|
|
23
|
+
transition:
|
|
24
|
+
border-color var(--ds-transition-fast),
|
|
25
|
+
box-shadow var(--ds-transition-fast);
|
|
26
|
+
cursor: pointer;
|
|
27
|
+
appearance: none;
|
|
28
|
+
background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 24 24' stroke='currentColor'%3E%3Cpath stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='M19 9l-7 7-7-7'%3E%3C/path%3E%3C/svg%3E");
|
|
29
|
+
background-repeat: no-repeat;
|
|
30
|
+
background-position: right var(--ds-space-3) center;
|
|
31
|
+
background-size: 1.25rem;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
.selectRoot:focus {
|
|
35
|
+
outline: none;
|
|
36
|
+
border-color: var(--ds-ring);
|
|
37
|
+
box-shadow:
|
|
38
|
+
0 0 0 2px var(--ds-ring-offset),
|
|
39
|
+
0 0 0 4px var(--ds-ring);
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
.selectRoot:disabled {
|
|
43
|
+
background-color: var(--ds-surface-1);
|
|
44
|
+
cursor: not-allowed;
|
|
45
|
+
opacity: 0.7;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
/* Sizes */
|
|
49
|
+
.sm {
|
|
50
|
+
height: var(--ds-space-8);
|
|
51
|
+
padding: 0 var(--ds-space-8) 0 var(--ds-space-3);
|
|
52
|
+
font-size: var(--ds-font-size-xs);
|
|
53
|
+
background-position: right var(--ds-space-2) center;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
.md {
|
|
57
|
+
height: calc(var(--ds-space-4) * 2.5);
|
|
58
|
+
padding: 0 var(--ds-space-10) 0 var(--ds-space-4);
|
|
59
|
+
font-size: var(--ds-font-size-sm);
|
|
60
|
+
background-position: right var(--ds-space-3) center;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
.lg {
|
|
64
|
+
height: var(--ds-space-12);
|
|
65
|
+
padding: 0 var(--ds-space-12) 0 var(--ds-space-5);
|
|
66
|
+
font-size: var(--ds-font-size-base);
|
|
67
|
+
background-position: right var(--ds-space-4) center;
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
/* Error state */
|
|
71
|
+
.error {
|
|
72
|
+
border-color: var(--ds-danger);
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
.error:focus {
|
|
76
|
+
border-color: var(--ds-danger);
|
|
77
|
+
box-shadow: 0 0 0 0.125rem var(--ds-danger-subtle);
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
.helperText {
|
|
81
|
+
font-family: var(--ds-font-family-base);
|
|
82
|
+
font-size: var(--ds-font-size-xs);
|
|
83
|
+
color: var(--ds-text-2);
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
.helperText.errorText {
|
|
87
|
+
color: var(--ds-danger);
|
|
88
|
+
}
|