@boostdev/design-system-components 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/AGENTS.md +72 -0
- package/README.md +396 -0
- package/dist/index.cjs +2273 -0
- package/dist/index.css +2543 -0
- package/dist/index.d.cts +453 -0
- package/dist/index.d.ts +453 -0
- package/dist/index.js +2221 -0
- package/package.json +143 -0
- package/src/components/interaction/Button/Button.module.css +136 -0
- package/src/components/interaction/Button/Button.spec.tsx +50 -0
- package/src/components/interaction/Button/Button.stories.tsx +43 -0
- package/src/components/interaction/Button/Button.tsx +68 -0
- package/src/components/interaction/Button/index.ts +1 -0
- package/src/components/interaction/Command/Command.module.css +128 -0
- package/src/components/interaction/Command/Command.spec.tsx +60 -0
- package/src/components/interaction/Command/Command.stories.tsx +35 -0
- package/src/components/interaction/Command/Command.tsx +161 -0
- package/src/components/interaction/Command/index.ts +2 -0
- package/src/components/interaction/Dialog/Dialog.module.css +39 -0
- package/src/components/interaction/Dialog/Dialog.spec.tsx +43 -0
- package/src/components/interaction/Dialog/Dialog.stories.tsx +36 -0
- package/src/components/interaction/Dialog/Dialog.tsx +42 -0
- package/src/components/interaction/Dialog/index.ts +1 -0
- package/src/components/interaction/Drawer/Drawer.module.css +98 -0
- package/src/components/interaction/Drawer/Drawer.spec.tsx +43 -0
- package/src/components/interaction/Drawer/Drawer.stories.tsx +46 -0
- package/src/components/interaction/Drawer/Drawer.tsx +71 -0
- package/src/components/interaction/Drawer/index.ts +1 -0
- package/src/components/interaction/DropdownMenu/DropdownMenu.module.css +68 -0
- package/src/components/interaction/DropdownMenu/DropdownMenu.spec.tsx +74 -0
- package/src/components/interaction/DropdownMenu/DropdownMenu.stories.tsx +68 -0
- package/src/components/interaction/DropdownMenu/DropdownMenu.tsx +137 -0
- package/src/components/interaction/DropdownMenu/index.ts +1 -0
- package/src/components/interaction/Popover/Popover.module.css +39 -0
- package/src/components/interaction/Popover/Popover.spec.tsx +72 -0
- package/src/components/interaction/Popover/Popover.stories.tsx +47 -0
- package/src/components/interaction/Popover/Popover.tsx +78 -0
- package/src/components/interaction/Popover/index.ts +1 -0
- package/src/components/interaction/Rating/Rating.module.css +16 -0
- package/src/components/interaction/Rating/Rating.spec.tsx +30 -0
- package/src/components/interaction/Rating/Rating.stories.tsx +29 -0
- package/src/components/interaction/Rating/Rating.tsx +30 -0
- package/src/components/interaction/Rating/index.ts +1 -0
- package/src/components/interaction/Toast/Toast.module.css +48 -0
- package/src/components/interaction/Toast/Toast.spec.tsx +41 -0
- package/src/components/interaction/Toast/Toast.stories.tsx +57 -0
- package/src/components/interaction/Toast/Toast.tsx +64 -0
- package/src/components/interaction/Toast/index.ts +1 -0
- package/src/components/interaction/form/Checkbox/Checkbox.module.css +61 -0
- package/src/components/interaction/form/Checkbox/Checkbox.spec.tsx +39 -0
- package/src/components/interaction/form/Checkbox/Checkbox.stories.tsx +17 -0
- package/src/components/interaction/form/Checkbox/Checkbox.tsx +39 -0
- package/src/components/interaction/form/Checkbox/index.ts +1 -0
- package/src/components/interaction/form/Combobox/Combobox.module.css +104 -0
- package/src/components/interaction/form/Combobox/Combobox.spec.tsx +81 -0
- package/src/components/interaction/form/Combobox/Combobox.stories.tsx +25 -0
- package/src/components/interaction/form/Combobox/Combobox.tsx +182 -0
- package/src/components/interaction/form/Combobox/index.ts +1 -0
- package/src/components/interaction/form/FileInput/FileInput.module.css +79 -0
- package/src/components/interaction/form/FileInput/FileInput.spec.tsx +53 -0
- package/src/components/interaction/form/FileInput/FileInput.stories.tsx +17 -0
- package/src/components/interaction/form/FileInput/FileInput.tsx +99 -0
- package/src/components/interaction/form/FileInput/index.ts +1 -0
- package/src/components/interaction/form/FormInput/FormInput.module.css +37 -0
- package/src/components/interaction/form/FormInput/FormInput.spec.tsx +43 -0
- package/src/components/interaction/form/FormInput/FormInput.stories.tsx +17 -0
- package/src/components/interaction/form/FormInput/FormInput.tsx +47 -0
- package/src/components/interaction/form/FormInput/index.ts +1 -0
- package/src/components/interaction/form/NumberInput/NumberInput.module.css +78 -0
- package/src/components/interaction/form/NumberInput/NumberInput.spec.tsx +49 -0
- package/src/components/interaction/form/NumberInput/NumberInput.stories.tsx +17 -0
- package/src/components/interaction/form/NumberInput/NumberInput.tsx +106 -0
- package/src/components/interaction/form/NumberInput/index.ts +1 -0
- package/src/components/interaction/form/Radio/Radio.module.css +62 -0
- package/src/components/interaction/form/Radio/Radio.spec.tsx +38 -0
- package/src/components/interaction/form/Radio/Radio.stories.tsx +26 -0
- package/src/components/interaction/form/Radio/Radio.tsx +39 -0
- package/src/components/interaction/form/Radio/index.ts +1 -0
- package/src/components/interaction/form/Select/Select.module.css +64 -0
- package/src/components/interaction/form/Select/Select.spec.tsx +61 -0
- package/src/components/interaction/form/Select/Select.stories.tsx +24 -0
- package/src/components/interaction/form/Select/Select.tsx +72 -0
- package/src/components/interaction/form/Select/index.ts +1 -0
- package/src/components/interaction/form/Slider/Slider.module.css +99 -0
- package/src/components/interaction/form/Slider/Slider.spec.tsx +53 -0
- package/src/components/interaction/form/Slider/Slider.stories.tsx +18 -0
- package/src/components/interaction/form/Slider/Slider.tsx +71 -0
- package/src/components/interaction/form/Slider/index.ts +1 -0
- package/src/components/interaction/form/Switch/Switch.module.css +114 -0
- package/src/components/interaction/form/Switch/Switch.spec.tsx +48 -0
- package/src/components/interaction/form/Switch/Switch.stories.tsx +31 -0
- package/src/components/interaction/form/Switch/Switch.tsx +54 -0
- package/src/components/interaction/form/Switch/index.ts +1 -0
- package/src/components/interaction/form/Textarea/Textarea.module.css +44 -0
- package/src/components/interaction/form/Textarea/Textarea.spec.tsx +53 -0
- package/src/components/interaction/form/Textarea/Textarea.stories.tsx +18 -0
- package/src/components/interaction/form/Textarea/Textarea.tsx +44 -0
- package/src/components/interaction/form/Textarea/index.ts +1 -0
- package/src/components/interaction/form/atoms/InputContainer.module.css +9 -0
- package/src/components/interaction/form/atoms/InputContainer.tsx +9 -0
- package/src/components/interaction/form/atoms/Label.module.css +10 -0
- package/src/components/interaction/form/atoms/Label.tsx +15 -0
- package/src/components/interaction/form/atoms/Message.module.css +11 -0
- package/src/components/interaction/form/atoms/Message.tsx +17 -0
- package/src/components/layout/ButtonGroup/ButtonGroup.module.css +59 -0
- package/src/components/layout/ButtonGroup/ButtonGroup.spec.tsx +20 -0
- package/src/components/layout/ButtonGroup/ButtonGroup.stories.tsx +28 -0
- package/src/components/layout/ButtonGroup/ButtonGroup.tsx +17 -0
- package/src/components/layout/ButtonGroup/index.ts +1 -0
- package/src/components/layout/Card/Card.module.css +72 -0
- package/src/components/layout/Card/Card.spec.tsx +33 -0
- package/src/components/layout/Card/Card.stories.tsx +32 -0
- package/src/components/layout/Card/Card.tsx +45 -0
- package/src/components/layout/Card/index.ts +1 -0
- package/src/components/layout/IconWrapper/IconWrapper.module.css +24 -0
- package/src/components/layout/IconWrapper/IconWrapper.spec.tsx +19 -0
- package/src/components/layout/IconWrapper/IconWrapper.stories.tsx +22 -0
- package/src/components/layout/IconWrapper/IconWrapper.tsx +14 -0
- package/src/components/layout/IconWrapper/index.ts +1 -0
- package/src/components/layout/SectionHeader/SectionHeader.module.css +75 -0
- package/src/components/layout/SectionHeader/SectionHeader.spec.tsx +31 -0
- package/src/components/layout/SectionHeader/SectionHeader.stories.tsx +21 -0
- package/src/components/layout/SectionHeader/SectionHeader.tsx +32 -0
- package/src/components/layout/SectionHeader/index.ts +1 -0
- package/src/components/ui/Accordion/Accordion.module.css +87 -0
- package/src/components/ui/Accordion/Accordion.spec.tsx +78 -0
- package/src/components/ui/Accordion/Accordion.stories.tsx +34 -0
- package/src/components/ui/Accordion/Accordion.tsx +82 -0
- package/src/components/ui/Accordion/index.ts +1 -0
- package/src/components/ui/Alert/Alert.module.css +91 -0
- package/src/components/ui/Alert/Alert.spec.tsx +63 -0
- package/src/components/ui/Alert/Alert.stories.tsx +53 -0
- package/src/components/ui/Alert/Alert.tsx +54 -0
- package/src/components/ui/Alert/index.ts +1 -0
- package/src/components/ui/Avatar/Avatar.module.css +42 -0
- package/src/components/ui/Avatar/Avatar.spec.tsx +49 -0
- package/src/components/ui/Avatar/Avatar.stories.tsx +44 -0
- package/src/components/ui/Avatar/Avatar.tsx +45 -0
- package/src/components/ui/Avatar/index.ts +1 -0
- package/src/components/ui/Badge/Badge.module.css +46 -0
- package/src/components/ui/Badge/Badge.spec.tsx +19 -0
- package/src/components/ui/Badge/Badge.stories.tsx +29 -0
- package/src/components/ui/Badge/Badge.tsx +13 -0
- package/src/components/ui/Badge/index.ts +1 -0
- package/src/components/ui/Breadcrumb/Breadcrumb.module.css +50 -0
- package/src/components/ui/Breadcrumb/Breadcrumb.spec.tsx +44 -0
- package/src/components/ui/Breadcrumb/Breadcrumb.stories.tsx +48 -0
- package/src/components/ui/Breadcrumb/Breadcrumb.tsx +41 -0
- package/src/components/ui/Breadcrumb/index.ts +1 -0
- package/src/components/ui/Calendar/Calendar.module.css +120 -0
- package/src/components/ui/Calendar/Calendar.spec.tsx +64 -0
- package/src/components/ui/Calendar/Calendar.stories.tsx +59 -0
- package/src/components/ui/Calendar/Calendar.tsx +184 -0
- package/src/components/ui/Calendar/index.ts +1 -0
- package/src/components/ui/Carousel/Carousel.module.css +66 -0
- package/src/components/ui/Carousel/Carousel.spec.tsx +29 -0
- package/src/components/ui/Carousel/Carousel.stories.tsx +30 -0
- package/src/components/ui/Carousel/Carousel.tsx +64 -0
- package/src/components/ui/Carousel/index.ts +1 -0
- package/src/components/ui/DescriptionList/DescriptionList.module.css +43 -0
- package/src/components/ui/DescriptionList/DescriptionList.spec.tsx +31 -0
- package/src/components/ui/DescriptionList/DescriptionList.stories.tsx +21 -0
- package/src/components/ui/DescriptionList/DescriptionList.tsx +30 -0
- package/src/components/ui/DescriptionList/index.ts +1 -0
- package/src/components/ui/Link/Link.module.css +64 -0
- package/src/components/ui/Link/Link.spec.tsx +43 -0
- package/src/components/ui/Link/Link.stories.tsx +55 -0
- package/src/components/ui/Link/Link.tsx +42 -0
- package/src/components/ui/Link/index.ts +1 -0
- package/src/components/ui/Loading/Loading.module.css +33 -0
- package/src/components/ui/Loading/Loading.spec.tsx +19 -0
- package/src/components/ui/Loading/Loading.stories.tsx +27 -0
- package/src/components/ui/Loading/Loading.tsx +15 -0
- package/src/components/ui/Loading/index.ts +1 -0
- package/src/components/ui/NotificationBanner/NotificationBanner.module.css +79 -0
- package/src/components/ui/NotificationBanner/NotificationBanner.spec.tsx +42 -0
- package/src/components/ui/NotificationBanner/NotificationBanner.stories.tsx +30 -0
- package/src/components/ui/NotificationBanner/NotificationBanner.tsx +45 -0
- package/src/components/ui/NotificationBanner/index.ts +1 -0
- package/src/components/ui/Pagination/Pagination.module.css +78 -0
- package/src/components/ui/Pagination/Pagination.spec.tsx +67 -0
- package/src/components/ui/Pagination/Pagination.stories.tsx +40 -0
- package/src/components/ui/Pagination/Pagination.tsx +87 -0
- package/src/components/ui/Pagination/index.ts +1 -0
- package/src/components/ui/Progress/Progress.module.css +51 -0
- package/src/components/ui/Progress/Progress.spec.tsx +55 -0
- package/src/components/ui/Progress/Progress.stories.tsx +30 -0
- package/src/components/ui/Progress/Progress.tsx +43 -0
- package/src/components/ui/Progress/index.ts +1 -0
- package/src/components/ui/ProgressCircle/ProgressCircle.module.css +40 -0
- package/src/components/ui/ProgressCircle/ProgressCircle.spec.tsx +34 -0
- package/src/components/ui/ProgressCircle/ProgressCircle.stories.tsx +18 -0
- package/src/components/ui/ProgressCircle/ProgressCircle.tsx +75 -0
- package/src/components/ui/ProgressCircle/index.ts +1 -0
- package/src/components/ui/Separator/Separator.module.css +23 -0
- package/src/components/ui/Separator/Separator.spec.tsx +30 -0
- package/src/components/ui/Separator/Separator.stories.tsx +40 -0
- package/src/components/ui/Separator/Separator.tsx +21 -0
- package/src/components/ui/Separator/index.ts +1 -0
- package/src/components/ui/Skeleton/Skeleton.module.css +24 -0
- package/src/components/ui/Skeleton/Skeleton.spec.tsx +19 -0
- package/src/components/ui/Skeleton/Skeleton.stories.tsx +25 -0
- package/src/components/ui/Skeleton/Skeleton.tsx +12 -0
- package/src/components/ui/Skeleton/index.ts +1 -0
- package/src/components/ui/SkipLink/SkipLink.module.css +30 -0
- package/src/components/ui/SkipLink/SkipLink.spec.tsx +24 -0
- package/src/components/ui/SkipLink/SkipLink.stories.tsx +24 -0
- package/src/components/ui/SkipLink/SkipLink.tsx +14 -0
- package/src/components/ui/SkipLink/index.ts +1 -0
- package/src/components/ui/Table/Table.module.css +111 -0
- package/src/components/ui/Table/Table.spec.tsx +69 -0
- package/src/components/ui/Table/Table.stories.tsx +53 -0
- package/src/components/ui/Table/Table.tsx +98 -0
- package/src/components/ui/Table/index.ts +1 -0
- package/src/components/ui/Tabs/Tabs.module.css +61 -0
- package/src/components/ui/Tabs/Tabs.spec.tsx +91 -0
- package/src/components/ui/Tabs/Tabs.stories.tsx +59 -0
- package/src/components/ui/Tabs/Tabs.tsx +100 -0
- package/src/components/ui/Tabs/index.ts +1 -0
- package/src/components/ui/Tooltip/Tooltip.module.css +69 -0
- package/src/components/ui/Tooltip/Tooltip.spec.tsx +46 -0
- package/src/components/ui/Tooltip/Tooltip.stories.tsx +69 -0
- package/src/components/ui/Tooltip/Tooltip.tsx +38 -0
- package/src/components/ui/Tooltip/index.ts +1 -0
- package/src/components/ui/Typography/Typography.module.css +41 -0
- package/src/components/ui/Typography/Typography.spec.tsx +39 -0
- package/src/components/ui/Typography/Typography.stories.tsx +31 -0
- package/src/components/ui/Typography/Typography.tsx +28 -0
- package/src/components/ui/Typography/index.ts +1 -0
- package/src/css/index.css +55 -0
- package/src/index.ts +54 -0
- package/src/test/setup.ts +1 -0
- package/src/typings.d.ts +4 -0
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import { render, screen } from '@testing-library/react';
|
|
2
|
+
import userEvent from '@testing-library/user-event';
|
|
3
|
+
import { NumberInput } from './NumberInput';
|
|
4
|
+
|
|
5
|
+
describe('NumberInput', () => {
|
|
6
|
+
it('renders a number input with label', () => {
|
|
7
|
+
render(<NumberInput label="Quantity" name="qty" />);
|
|
8
|
+
expect(screen.getByRole('spinbutton', { name: 'Quantity' })).toBeInTheDocument();
|
|
9
|
+
});
|
|
10
|
+
|
|
11
|
+
it('renders with defaultValue', () => {
|
|
12
|
+
render(<NumberInput label="Quantity" name="qty" defaultValue={5} />);
|
|
13
|
+
expect(screen.getByRole('spinbutton')).toHaveValue(5);
|
|
14
|
+
});
|
|
15
|
+
|
|
16
|
+
it('renders increase and decrease buttons', () => {
|
|
17
|
+
render(<NumberInput label="Quantity" name="qty" />);
|
|
18
|
+
expect(screen.getByRole('button', { name: 'Increase' })).toBeInTheDocument();
|
|
19
|
+
expect(screen.getByRole('button', { name: 'Decrease' })).toBeInTheDocument();
|
|
20
|
+
});
|
|
21
|
+
|
|
22
|
+
it('shows error message', () => {
|
|
23
|
+
render(<NumberInput label="Qty" name="qty" error="Value required" />);
|
|
24
|
+
expect(screen.getByText('Value required')).toBeInTheDocument();
|
|
25
|
+
});
|
|
26
|
+
|
|
27
|
+
it('shows hint message', () => {
|
|
28
|
+
render(<NumberInput label="Qty" name="qty" hint="Enter a number" />);
|
|
29
|
+
expect(screen.getByText('Enter a number')).toBeInTheDocument();
|
|
30
|
+
});
|
|
31
|
+
|
|
32
|
+
it('marks input as invalid when error present', () => {
|
|
33
|
+
render(<NumberInput label="Qty" name="qty" error="Required" />);
|
|
34
|
+
expect(screen.getByRole('spinbutton')).toHaveAttribute('aria-invalid', 'true');
|
|
35
|
+
});
|
|
36
|
+
|
|
37
|
+
it('calls onChange when value changes', async () => {
|
|
38
|
+
const onChange = vi.fn();
|
|
39
|
+
render(<NumberInput label="Qty" name="qty" defaultValue={0} onChange={onChange} />);
|
|
40
|
+
await userEvent.click(screen.getByRole('button', { name: 'Increase' }));
|
|
41
|
+
expect(onChange).toHaveBeenCalledWith(1);
|
|
42
|
+
});
|
|
43
|
+
|
|
44
|
+
it('disables both buttons when disabled', () => {
|
|
45
|
+
render(<NumberInput label="Qty" name="qty" disabled />);
|
|
46
|
+
expect(screen.getByRole('button', { name: 'Increase' })).toBeDisabled();
|
|
47
|
+
expect(screen.getByRole('button', { name: 'Decrease' })).toBeDisabled();
|
|
48
|
+
});
|
|
49
|
+
});
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import type { Meta, StoryObj } from '@storybook/react';
|
|
2
|
+
import { NumberInput } from './NumberInput';
|
|
3
|
+
|
|
4
|
+
const meta = {
|
|
5
|
+
title: 'Form/NumberInput',
|
|
6
|
+
component: NumberInput,
|
|
7
|
+
tags: ['autodocs'],
|
|
8
|
+
} satisfies Meta<typeof NumberInput>;
|
|
9
|
+
|
|
10
|
+
export default meta;
|
|
11
|
+
type Story = StoryObj<typeof meta>;
|
|
12
|
+
|
|
13
|
+
export const Default: Story = { args: { label: 'Quantity', name: 'qty', defaultValue: 1 } };
|
|
14
|
+
export const WithRange: Story = { args: { label: 'Rating', name: 'rating', min: 1, max: 10, defaultValue: 5 } };
|
|
15
|
+
export const WithStep: Story = { args: { label: 'Price', name: 'price', min: 0, max: 100, step: 5, defaultValue: 0, hint: 'Increments of 5' } };
|
|
16
|
+
export const WithError: Story = { args: { label: 'Count', name: 'count', defaultValue: 0, error: 'Must be at least 1' } };
|
|
17
|
+
export const Disabled: Story = { args: { label: 'Quantity', name: 'qty', defaultValue: 3, disabled: true } };
|
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
import { useId, useRef } from 'react';
|
|
2
|
+
import css from './NumberInput.module.css';
|
|
3
|
+
import { Label } from '../atoms/Label';
|
|
4
|
+
import { Message } from '../atoms/Message';
|
|
5
|
+
import { InputContainer } from '../atoms/InputContainer';
|
|
6
|
+
import { cn } from '@boostdev/design-system-foundation';
|
|
7
|
+
|
|
8
|
+
interface NumberInputProps {
|
|
9
|
+
label: string;
|
|
10
|
+
name: string;
|
|
11
|
+
value?: number;
|
|
12
|
+
defaultValue?: number;
|
|
13
|
+
min?: number;
|
|
14
|
+
max?: number;
|
|
15
|
+
step?: number;
|
|
16
|
+
disabled?: boolean;
|
|
17
|
+
error?: string;
|
|
18
|
+
hint?: string;
|
|
19
|
+
onChange?: (value: number) => void;
|
|
20
|
+
className?: string;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
export function NumberInput({
|
|
24
|
+
label,
|
|
25
|
+
name,
|
|
26
|
+
value,
|
|
27
|
+
defaultValue,
|
|
28
|
+
min,
|
|
29
|
+
max,
|
|
30
|
+
step = 1,
|
|
31
|
+
disabled = false,
|
|
32
|
+
error,
|
|
33
|
+
hint,
|
|
34
|
+
onChange,
|
|
35
|
+
className,
|
|
36
|
+
}: Readonly<NumberInputProps>) {
|
|
37
|
+
const uid = name + useId();
|
|
38
|
+
const hintId = uid + 'hint';
|
|
39
|
+
const errorId = uid + 'error';
|
|
40
|
+
const describedBy = error ? errorId : hintId;
|
|
41
|
+
const inputRef = useRef<HTMLInputElement>(null);
|
|
42
|
+
|
|
43
|
+
const clamp = (v: number): number => {
|
|
44
|
+
const withMin = min !== undefined ? Math.max(min, v) : v;
|
|
45
|
+
const withMax = max !== undefined ? Math.min(max, withMin) : withMin;
|
|
46
|
+
return withMax;
|
|
47
|
+
};
|
|
48
|
+
|
|
49
|
+
const adjust = (delta: number) => {
|
|
50
|
+
if (!inputRef.current) return;
|
|
51
|
+
const current = parseFloat(inputRef.current.value) || 0;
|
|
52
|
+
const next = clamp(current + delta);
|
|
53
|
+
inputRef.current.value = String(next);
|
|
54
|
+
onChange?.(next);
|
|
55
|
+
};
|
|
56
|
+
|
|
57
|
+
return (
|
|
58
|
+
<InputContainer className={cn(css.formGroup, className)}>
|
|
59
|
+
<Label id={uid} label={label} />
|
|
60
|
+
<div className={css.inputRow}>
|
|
61
|
+
<button
|
|
62
|
+
type="button"
|
|
63
|
+
className={css.stepper}
|
|
64
|
+
aria-label="Decrease"
|
|
65
|
+
disabled={disabled || (min !== undefined && (value ?? defaultValue ?? 0) <= min)}
|
|
66
|
+
onClick={() => adjust(-step)}
|
|
67
|
+
tabIndex={-1}
|
|
68
|
+
>
|
|
69
|
+
<svg aria-hidden="true" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="2.5">
|
|
70
|
+
<path strokeLinecap="round" strokeLinejoin="round" d="M5 12h14" />
|
|
71
|
+
</svg>
|
|
72
|
+
</button>
|
|
73
|
+
<input
|
|
74
|
+
ref={inputRef}
|
|
75
|
+
id={uid}
|
|
76
|
+
type="number"
|
|
77
|
+
name={name}
|
|
78
|
+
defaultValue={defaultValue}
|
|
79
|
+
value={value}
|
|
80
|
+
min={min}
|
|
81
|
+
max={max}
|
|
82
|
+
step={step}
|
|
83
|
+
disabled={disabled}
|
|
84
|
+
aria-invalid={!!error}
|
|
85
|
+
aria-describedby={describedBy}
|
|
86
|
+
className={cn(css.input, error ? css.inputError : undefined)}
|
|
87
|
+
onChange={e => onChange?.(parseFloat(e.target.value))}
|
|
88
|
+
/>
|
|
89
|
+
<button
|
|
90
|
+
type="button"
|
|
91
|
+
className={css.stepper}
|
|
92
|
+
aria-label="Increase"
|
|
93
|
+
disabled={disabled || (max !== undefined && (value ?? defaultValue ?? 0) >= max)}
|
|
94
|
+
onClick={() => adjust(step)}
|
|
95
|
+
tabIndex={-1}
|
|
96
|
+
>
|
|
97
|
+
<svg aria-hidden="true" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="2.5">
|
|
98
|
+
<path strokeLinecap="round" strokeLinejoin="round" d="M12 5v14M5 12h14" />
|
|
99
|
+
</svg>
|
|
100
|
+
</button>
|
|
101
|
+
</div>
|
|
102
|
+
<Message inputId={uid} type="error" message={error} />
|
|
103
|
+
<Message inputId={uid} type="hint" message={hint} />
|
|
104
|
+
</InputContainer>
|
|
105
|
+
);
|
|
106
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { NumberInput } from './NumberInput';
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
@layer component {
|
|
2
|
+
.radioGroup {
|
|
3
|
+
--inputSize: calc(var(--space_s) * 2);
|
|
4
|
+
--labelPosition: calc(var(--inputSize) + var(--space_m));
|
|
5
|
+
|
|
6
|
+
display: flex;
|
|
7
|
+
flex-direction: column;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
.inputWrapper {
|
|
11
|
+
display: flex;
|
|
12
|
+
align-items: stretch;
|
|
13
|
+
gap: var(--space_xs);
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
.radio {
|
|
17
|
+
flex-shrink: 0;
|
|
18
|
+
margin-block-start: 0.25em;
|
|
19
|
+
width: var(--inputSize);
|
|
20
|
+
height: var(--inputSize);
|
|
21
|
+
border: 1px solid var(--color_border);
|
|
22
|
+
border-radius: 50%;
|
|
23
|
+
appearance: none;
|
|
24
|
+
background-color: var(--color_bg);
|
|
25
|
+
cursor: pointer;
|
|
26
|
+
position: relative;
|
|
27
|
+
transition: background-color 0.3s ease, border-color 0.3s ease;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
.radio:checked {
|
|
31
|
+
background-color: var(--color_green);
|
|
32
|
+
border-color: var(--color_green);
|
|
33
|
+
box-shadow: 0 0 0 2px var(--color_green);
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
.radio:checked::after {
|
|
37
|
+
content: '';
|
|
38
|
+
position: absolute;
|
|
39
|
+
left: 0.6em;
|
|
40
|
+
top: 0.25em;
|
|
41
|
+
width: 0.5em;
|
|
42
|
+
height: 1em;
|
|
43
|
+
border: solid var(--color_on-green);
|
|
44
|
+
border-width: 0 2px 2px 0;
|
|
45
|
+
transform: rotate(45deg);
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
.radio:focus {
|
|
49
|
+
outline: none;
|
|
50
|
+
border-color: var(--color_interactive);
|
|
51
|
+
box-shadow: 0 0 0 2px var(--color_green);
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
.radioError {
|
|
55
|
+
border-color: var(--color_error);
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
.radioError:focus {
|
|
59
|
+
border-color: var(--color_error);
|
|
60
|
+
box-shadow: 0 0 0 2px rgb(from var(--color_error) r g b / 20%);
|
|
61
|
+
}
|
|
62
|
+
}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { render, screen } from '@testing-library/react';
|
|
2
|
+
import userEvent from '@testing-library/user-event';
|
|
3
|
+
import { Radio } from './Radio';
|
|
4
|
+
|
|
5
|
+
describe('Radio', () => {
|
|
6
|
+
it('renders with a label', () => {
|
|
7
|
+
render(<Radio label="Option A" name="choice" value="a" />);
|
|
8
|
+
expect(screen.getByLabelText('Option A')).toBeInTheDocument();
|
|
9
|
+
});
|
|
10
|
+
|
|
11
|
+
it('renders a radio input', () => {
|
|
12
|
+
render(<Radio label="Option" name="opt" value="x" />);
|
|
13
|
+
expect(screen.getByRole('radio')).toBeInTheDocument();
|
|
14
|
+
});
|
|
15
|
+
|
|
16
|
+
it('can be selected', async () => {
|
|
17
|
+
const user = userEvent.setup();
|
|
18
|
+
render(<Radio label="Option" name="opt" value="x" />);
|
|
19
|
+
const radio = screen.getByRole('radio');
|
|
20
|
+
await user.click(radio);
|
|
21
|
+
expect(radio).toBeChecked();
|
|
22
|
+
});
|
|
23
|
+
|
|
24
|
+
it('shows an error message', () => {
|
|
25
|
+
render(<Radio label="Option" name="opt" value="x" error="Required" />);
|
|
26
|
+
expect(screen.getByText('Required')).toBeInTheDocument();
|
|
27
|
+
});
|
|
28
|
+
|
|
29
|
+
it('shows a hint message', () => {
|
|
30
|
+
render(<Radio label="Option" name="opt" value="x" hint="Choose carefully" />);
|
|
31
|
+
expect(screen.getByText('Choose carefully')).toBeInTheDocument();
|
|
32
|
+
});
|
|
33
|
+
|
|
34
|
+
it('is disabled when disabled prop is set', () => {
|
|
35
|
+
render(<Radio label="Disabled" name="disabled" value="x" disabled />);
|
|
36
|
+
expect(screen.getByRole('radio')).toBeDisabled();
|
|
37
|
+
});
|
|
38
|
+
});
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import type { Meta, StoryObj } from '@storybook/react';
|
|
2
|
+
import { Radio } from './Radio';
|
|
3
|
+
|
|
4
|
+
const meta = {
|
|
5
|
+
title: 'Form/Radio',
|
|
6
|
+
component: Radio,
|
|
7
|
+
tags: ['autodocs'],
|
|
8
|
+
} satisfies Meta<typeof Radio>;
|
|
9
|
+
|
|
10
|
+
export default meta;
|
|
11
|
+
type Story = StoryObj<typeof meta>;
|
|
12
|
+
|
|
13
|
+
export const Default: Story = { args: { label: 'Option A', name: 'choice', value: 'a' } };
|
|
14
|
+
export const Selected: Story = { args: { label: 'Selected', name: 'choice2', value: 'b', defaultChecked: true } };
|
|
15
|
+
export const WithError: Story = { args: { label: 'Required', name: 'choice3', value: 'c', error: 'Please select an option' } };
|
|
16
|
+
export const WithHint: Story = { args: { label: 'Option', name: 'choice4', value: 'd', hint: 'Choose carefully' } };
|
|
17
|
+
export const Group: Story = {
|
|
18
|
+
render: () => (
|
|
19
|
+
<fieldset>
|
|
20
|
+
<legend>Pick one</legend>
|
|
21
|
+
<Radio label="Option A" name="group" value="a" />
|
|
22
|
+
<Radio label="Option B" name="group" value="b" />
|
|
23
|
+
<Radio label="Option C" name="group" value="c" />
|
|
24
|
+
</fieldset>
|
|
25
|
+
),
|
|
26
|
+
};
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { InputHTMLAttributes, useId } from 'react';
|
|
2
|
+
import css from './Radio.module.css';
|
|
3
|
+
import { Message } from '../atoms/Message';
|
|
4
|
+
import { Label } from '../atoms/Label';
|
|
5
|
+
import { InputContainer } from '../atoms/InputContainer';
|
|
6
|
+
import { cn } from '@boostdev/design-system-foundation';
|
|
7
|
+
|
|
8
|
+
interface RadioProps extends Omit<InputHTMLAttributes<HTMLInputElement>, 'type'> {
|
|
9
|
+
label: string;
|
|
10
|
+
name: string;
|
|
11
|
+
error?: string;
|
|
12
|
+
hint?: string;
|
|
13
|
+
className?: string;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
export function Radio({ label, name, error, hint, className, ...props }: RadioProps) {
|
|
17
|
+
const id = name + useId();
|
|
18
|
+
const hintId = id + 'hint';
|
|
19
|
+
const errorId = id + 'error';
|
|
20
|
+
const describedBy = !!error ? errorId : hintId;
|
|
21
|
+
|
|
22
|
+
return (
|
|
23
|
+
<InputContainer className={cn(css.radioGroup, className)}>
|
|
24
|
+
<div className={css.inputWrapper}>
|
|
25
|
+
<input
|
|
26
|
+
aria-describedby={describedBy}
|
|
27
|
+
type="radio"
|
|
28
|
+
id={id}
|
|
29
|
+
name={name}
|
|
30
|
+
className={`${css.radio} ${error ? css.radioError : ''}`}
|
|
31
|
+
{...props}
|
|
32
|
+
/>
|
|
33
|
+
<Label id={id} label={label} />
|
|
34
|
+
</div>
|
|
35
|
+
<Message inputId={id} type="error" message={error} />
|
|
36
|
+
<Message inputId={id} type="hint" message={hint} />
|
|
37
|
+
</InputContainer>
|
|
38
|
+
);
|
|
39
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { Radio } from './Radio';
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
@layer component {
|
|
2
|
+
.formGroup {
|
|
3
|
+
display: flex;
|
|
4
|
+
flex-direction: column;
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
.selectWrapper {
|
|
8
|
+
position: relative;
|
|
9
|
+
display: flex;
|
|
10
|
+
align-items: center;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
.select {
|
|
14
|
+
--select_border-color: var(--color_on-bg);
|
|
15
|
+
--select_focus-ring: 0 0 0 2px rgb(from var(--color_interactive) r g b / 20%);
|
|
16
|
+
|
|
17
|
+
appearance: none;
|
|
18
|
+
width: 100%;
|
|
19
|
+
font-family: var(--font_family--body);
|
|
20
|
+
font-size: var(--font_size--body);
|
|
21
|
+
padding: var(--space_s);
|
|
22
|
+
padding-inline-end: var(--space_xxl);
|
|
23
|
+
border: 1px solid var(--select_border-color);
|
|
24
|
+
border-radius: var(--border_radius--xs);
|
|
25
|
+
background-color: var(--color_bg);
|
|
26
|
+
color: var(--color_on-bg);
|
|
27
|
+
cursor: pointer;
|
|
28
|
+
transition: var(--animation_transition);
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
.select:focus {
|
|
32
|
+
--select_border-color: var(--color_interactive);
|
|
33
|
+
|
|
34
|
+
outline: none;
|
|
35
|
+
box-shadow: var(--select_focus-ring);
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
.select:disabled {
|
|
39
|
+
opacity: 0.5;
|
|
40
|
+
cursor: not-allowed;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
.selectError {
|
|
44
|
+
--select_border-color: var(--color_error);
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
.selectError:focus {
|
|
48
|
+
--select_focus-ring: 0 0 0 2px rgb(from var(--color_error) r g b / 20%);
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
.chevron {
|
|
52
|
+
position: absolute;
|
|
53
|
+
inset-inline-end: var(--space_s);
|
|
54
|
+
display: flex;
|
|
55
|
+
align-items: center;
|
|
56
|
+
pointer-events: none;
|
|
57
|
+
color: var(--color_on-bg);
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
.chevron svg {
|
|
61
|
+
width: 1rem;
|
|
62
|
+
height: 1rem;
|
|
63
|
+
}
|
|
64
|
+
}
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import { render, screen } from '@testing-library/react';
|
|
2
|
+
import userEvent from '@testing-library/user-event';
|
|
3
|
+
import { Select } from './Select';
|
|
4
|
+
|
|
5
|
+
const options = [
|
|
6
|
+
{ value: 'nl', label: 'Netherlands' },
|
|
7
|
+
{ value: 'be', label: 'Belgium' },
|
|
8
|
+
{ value: 'de', label: 'Germany', disabled: true },
|
|
9
|
+
];
|
|
10
|
+
|
|
11
|
+
describe('Select', () => {
|
|
12
|
+
it('renders with a label', () => {
|
|
13
|
+
render(<Select label="Country" name="country" options={options} />);
|
|
14
|
+
expect(screen.getByLabelText('Country')).toBeInTheDocument();
|
|
15
|
+
});
|
|
16
|
+
|
|
17
|
+
it('renders a combobox', () => {
|
|
18
|
+
render(<Select label="Country" name="country" options={options} />);
|
|
19
|
+
expect(screen.getByRole('combobox')).toBeInTheDocument();
|
|
20
|
+
});
|
|
21
|
+
|
|
22
|
+
it('renders all options', () => {
|
|
23
|
+
render(<Select label="Country" name="country" options={options} />);
|
|
24
|
+
expect(screen.getByRole('option', { name: 'Netherlands' })).toBeInTheDocument();
|
|
25
|
+
expect(screen.getByRole('option', { name: 'Belgium' })).toBeInTheDocument();
|
|
26
|
+
expect(screen.getByRole('option', { name: 'Germany' })).toBeInTheDocument();
|
|
27
|
+
});
|
|
28
|
+
|
|
29
|
+
it('renders a placeholder option', () => {
|
|
30
|
+
render(<Select label="Country" name="country" options={options} placeholder="Pick a country" />);
|
|
31
|
+
expect(screen.getByRole('option', { name: 'Pick a country' })).toBeInTheDocument();
|
|
32
|
+
});
|
|
33
|
+
|
|
34
|
+
it('marks a disabled option as disabled', () => {
|
|
35
|
+
render(<Select label="Country" name="country" options={options} />);
|
|
36
|
+
expect(screen.getByRole('option', { name: 'Germany' })).toBeDisabled();
|
|
37
|
+
});
|
|
38
|
+
|
|
39
|
+
it('shows an error message', () => {
|
|
40
|
+
render(<Select label="Country" name="country" options={options} error="Required" />);
|
|
41
|
+
expect(screen.getByText('Required')).toBeInTheDocument();
|
|
42
|
+
});
|
|
43
|
+
|
|
44
|
+
it('shows a hint message', () => {
|
|
45
|
+
render(<Select label="Country" name="country" options={options} hint="Select your country" />);
|
|
46
|
+
expect(screen.getByText('Select your country')).toBeInTheDocument();
|
|
47
|
+
});
|
|
48
|
+
|
|
49
|
+
it('is disabled when the disabled prop is set', () => {
|
|
50
|
+
render(<Select label="Country" name="country" options={options} disabled />);
|
|
51
|
+
expect(screen.getByRole('combobox')).toBeDisabled();
|
|
52
|
+
});
|
|
53
|
+
|
|
54
|
+
it('calls onChange when an option is selected', async () => {
|
|
55
|
+
const user = userEvent.setup();
|
|
56
|
+
const onChange = vi.fn();
|
|
57
|
+
render(<Select label="Country" name="country" options={options} onChange={onChange} />);
|
|
58
|
+
await user.selectOptions(screen.getByRole('combobox'), 'nl');
|
|
59
|
+
expect(onChange).toHaveBeenCalled();
|
|
60
|
+
});
|
|
61
|
+
});
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import type { Meta, StoryObj } from '@storybook/react';
|
|
2
|
+
import { Select } from './Select';
|
|
3
|
+
|
|
4
|
+
const options = [
|
|
5
|
+
{ value: 'nl', label: 'Netherlands' },
|
|
6
|
+
{ value: 'be', label: 'Belgium' },
|
|
7
|
+
{ value: 'de', label: 'Germany' },
|
|
8
|
+
{ value: 'fr', label: 'France' },
|
|
9
|
+
];
|
|
10
|
+
|
|
11
|
+
const meta = {
|
|
12
|
+
title: 'Form/Select',
|
|
13
|
+
component: Select,
|
|
14
|
+
tags: ['autodocs'],
|
|
15
|
+
} satisfies Meta<typeof Select>;
|
|
16
|
+
|
|
17
|
+
export default meta;
|
|
18
|
+
type Story = StoryObj<typeof meta>;
|
|
19
|
+
|
|
20
|
+
export const Default: Story = { args: { label: 'Country', name: 'country', options } };
|
|
21
|
+
export const WithPlaceholder: Story = { args: { label: 'Country', name: 'country', options, placeholder: 'Select a country…' } };
|
|
22
|
+
export const WithError: Story = { args: { label: 'Country', name: 'country', options, error: 'Please select a country' } };
|
|
23
|
+
export const WithHint: Story = { args: { label: 'Country', name: 'country', options, hint: 'We use this to calculate shipping costs' } };
|
|
24
|
+
export const Disabled: Story = { args: { label: 'Country', name: 'country', options, disabled: true } };
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
import { SelectHTMLAttributes, useId, ReactNode } from 'react';
|
|
2
|
+
import css from './Select.module.css';
|
|
3
|
+
import { cn } from '@boostdev/design-system-foundation';
|
|
4
|
+
import { InputContainer } from '../atoms/InputContainer';
|
|
5
|
+
import { Label } from '../atoms/Label';
|
|
6
|
+
import { Message } from '../atoms/Message';
|
|
7
|
+
|
|
8
|
+
interface SelectOption {
|
|
9
|
+
value: string;
|
|
10
|
+
label: string;
|
|
11
|
+
disabled?: boolean;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
interface SelectProps extends Omit<SelectHTMLAttributes<HTMLSelectElement>, 'children'> {
|
|
15
|
+
label: ReactNode;
|
|
16
|
+
name: string;
|
|
17
|
+
options: SelectOption[];
|
|
18
|
+
placeholder?: string;
|
|
19
|
+
error?: string;
|
|
20
|
+
hint?: string;
|
|
21
|
+
className?: string;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
export function Select({
|
|
25
|
+
label,
|
|
26
|
+
name,
|
|
27
|
+
options,
|
|
28
|
+
placeholder,
|
|
29
|
+
error,
|
|
30
|
+
hint,
|
|
31
|
+
className,
|
|
32
|
+
...props
|
|
33
|
+
}: Readonly<SelectProps>) {
|
|
34
|
+
const id = name + useId();
|
|
35
|
+
const hintId = id + 'hint';
|
|
36
|
+
const errorId = id + 'error';
|
|
37
|
+
const describedBy = error ? errorId : hintId;
|
|
38
|
+
|
|
39
|
+
return (
|
|
40
|
+
<InputContainer className={cn(css.formGroup, className)}>
|
|
41
|
+
<Label id={id} label={label} />
|
|
42
|
+
<div className={css.selectWrapper}>
|
|
43
|
+
<select
|
|
44
|
+
id={id}
|
|
45
|
+
name={name}
|
|
46
|
+
aria-invalid={!!error}
|
|
47
|
+
aria-describedby={describedBy}
|
|
48
|
+
className={cn(css.select, error ? css.selectError : undefined)}
|
|
49
|
+
{...props}
|
|
50
|
+
>
|
|
51
|
+
{placeholder && (
|
|
52
|
+
<option value="" disabled>
|
|
53
|
+
{placeholder}
|
|
54
|
+
</option>
|
|
55
|
+
)}
|
|
56
|
+
{options.map(({ value, label: optLabel, disabled }) => (
|
|
57
|
+
<option key={value} value={value} disabled={disabled}>
|
|
58
|
+
{optLabel}
|
|
59
|
+
</option>
|
|
60
|
+
))}
|
|
61
|
+
</select>
|
|
62
|
+
<span className={css.chevron} aria-hidden="true">
|
|
63
|
+
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="2">
|
|
64
|
+
<path strokeLinecap="round" strokeLinejoin="round" d="M6 9l6 6 6-6" />
|
|
65
|
+
</svg>
|
|
66
|
+
</span>
|
|
67
|
+
</div>
|
|
68
|
+
<Message inputId={id} type="error" message={error} />
|
|
69
|
+
<Message inputId={id} type="hint" message={hint} />
|
|
70
|
+
</InputContainer>
|
|
71
|
+
);
|
|
72
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { Select } from './Select';
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
@layer component {
|
|
2
|
+
.formGroup {
|
|
3
|
+
display: flex;
|
|
4
|
+
flex-direction: column;
|
|
5
|
+
gap: var(--space_xxs);
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
.labelRow {
|
|
9
|
+
display: flex;
|
|
10
|
+
justify-content: space-between;
|
|
11
|
+
align-items: baseline;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
.value {
|
|
15
|
+
font-size: var(--font_size--body--s);
|
|
16
|
+
font-variant-numeric: tabular-nums;
|
|
17
|
+
color: var(--color_on-bg--subtle);
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
.slider {
|
|
21
|
+
--slider_fill: 0%;
|
|
22
|
+
--slider_track-height: var(--space_xxs);
|
|
23
|
+
--slider_thumb-size: calc(var(--space_s) * 2);
|
|
24
|
+
|
|
25
|
+
appearance: none;
|
|
26
|
+
width: 100%;
|
|
27
|
+
height: var(--slider_track-height);
|
|
28
|
+
border-radius: 999px;
|
|
29
|
+
background: linear-gradient(
|
|
30
|
+
to right,
|
|
31
|
+
var(--color_green) 0%,
|
|
32
|
+
var(--color_green) var(--slider_fill),
|
|
33
|
+
var(--color_bg--subtle) var(--slider_fill),
|
|
34
|
+
var(--color_bg--subtle) 100%
|
|
35
|
+
);
|
|
36
|
+
cursor: pointer;
|
|
37
|
+
transition: var(--animation_transition);
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
.slider:focus-visible {
|
|
41
|
+
outline: var(--outline_default);
|
|
42
|
+
outline-offset: var(--outline_offset);
|
|
43
|
+
border-radius: 999px;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
.slider:disabled {
|
|
47
|
+
opacity: 0.4;
|
|
48
|
+
cursor: not-allowed;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
/* Thumb — Webkit */
|
|
52
|
+
.slider::-webkit-slider-thumb {
|
|
53
|
+
appearance: none;
|
|
54
|
+
width: var(--slider_thumb-size);
|
|
55
|
+
height: var(--slider_thumb-size);
|
|
56
|
+
border-radius: 50%;
|
|
57
|
+
background-color: var(--color_green);
|
|
58
|
+
box-shadow: var(--shadow_s);
|
|
59
|
+
transition: var(--animation_transition);
|
|
60
|
+
cursor: pointer;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
/* Thumb — Firefox */
|
|
64
|
+
.slider::-moz-range-thumb {
|
|
65
|
+
width: var(--slider_thumb-size);
|
|
66
|
+
height: var(--slider_thumb-size);
|
|
67
|
+
border: none;
|
|
68
|
+
border-radius: 50%;
|
|
69
|
+
background-color: var(--color_green);
|
|
70
|
+
box-shadow: var(--shadow_s);
|
|
71
|
+
cursor: pointer;
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
.sliderError {
|
|
75
|
+
background: linear-gradient(
|
|
76
|
+
to right,
|
|
77
|
+
var(--color_error) 0%,
|
|
78
|
+
var(--color_error) var(--slider_fill),
|
|
79
|
+
var(--color_bg--subtle) var(--slider_fill),
|
|
80
|
+
var(--color_bg--subtle) 100%
|
|
81
|
+
);
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
.sliderError::-webkit-slider-thumb {
|
|
85
|
+
background-color: var(--color_error);
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
.sliderError::-moz-range-thumb {
|
|
89
|
+
background-color: var(--color_error);
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
@media (prefers-reduced-motion: reduce) {
|
|
93
|
+
.slider,
|
|
94
|
+
.slider::-webkit-slider-thumb,
|
|
95
|
+
.slider::-moz-range-thumb {
|
|
96
|
+
transition: none;
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
}
|