@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,46 @@
|
|
|
1
|
+
@layer component {
|
|
2
|
+
.badge {
|
|
3
|
+
/* Component tokens — override from a parent context or inline style */
|
|
4
|
+
--badge_bg: var(--color_blue);
|
|
5
|
+
--badge_text: var(--color_on-blue);
|
|
6
|
+
--badge_radius: 2em;
|
|
7
|
+
--badge_font-size: var(--font_size--body--s);
|
|
8
|
+
|
|
9
|
+
display: inline-flex;
|
|
10
|
+
align-items: center;
|
|
11
|
+
justify-content: center;
|
|
12
|
+
padding: var(--space_xxs) var(--space_xs);
|
|
13
|
+
border-radius: var(--badge_radius);
|
|
14
|
+
font-size: var(--badge_font-size);
|
|
15
|
+
font-weight: var(--font_weight--semibold);
|
|
16
|
+
line-height: 1;
|
|
17
|
+
white-space: nowrap;
|
|
18
|
+
background-color: var(--badge_bg);
|
|
19
|
+
color: var(--badge_text);
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
.--variant_primary {
|
|
23
|
+
--badge_bg: var(--color_interactive);
|
|
24
|
+
--badge_text: var(--color_on-interactive);
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
.--variant_secondary {
|
|
28
|
+
--badge_bg: var(--color_bg);
|
|
29
|
+
--badge_text: var(--color_on-bg);
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
.--variant_success {
|
|
33
|
+
--badge_bg: var(--color_success);
|
|
34
|
+
--badge_text: var(--color_on-success);
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
.--variant_error {
|
|
38
|
+
--badge_bg: var(--color_error);
|
|
39
|
+
--badge_text: var(--color_on-error);
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
.--variant_warning {
|
|
43
|
+
--badge_bg: var(--color_warning);
|
|
44
|
+
--badge_text: var(--color_on-warning);
|
|
45
|
+
}
|
|
46
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { render, screen } from '@testing-library/react';
|
|
2
|
+
import { Badge } from './Badge';
|
|
3
|
+
|
|
4
|
+
describe('Badge', () => {
|
|
5
|
+
it('renders children', () => {
|
|
6
|
+
render(<Badge>Hello</Badge>);
|
|
7
|
+
expect(screen.getByText('Hello')).toBeInTheDocument();
|
|
8
|
+
});
|
|
9
|
+
|
|
10
|
+
it('renders as a span', () => {
|
|
11
|
+
render(<Badge>Test</Badge>);
|
|
12
|
+
expect(screen.getByText('Test').tagName).toBe('SPAN');
|
|
13
|
+
});
|
|
14
|
+
|
|
15
|
+
it('accepts a custom className', () => {
|
|
16
|
+
render(<Badge className="custom">Test</Badge>);
|
|
17
|
+
expect(screen.getByText('Test')).toHaveClass('custom');
|
|
18
|
+
});
|
|
19
|
+
});
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import type { Meta, StoryObj } from '@storybook/react';
|
|
2
|
+
import { Badge } from './Badge';
|
|
3
|
+
|
|
4
|
+
const meta = {
|
|
5
|
+
title: 'UI/Badge',
|
|
6
|
+
component: Badge,
|
|
7
|
+
tags: ['autodocs'],
|
|
8
|
+
argTypes: {
|
|
9
|
+
variant: { control: 'select', options: ['primary', 'secondary', 'success', 'error', 'warning'] },
|
|
10
|
+
},
|
|
11
|
+
} satisfies Meta<typeof Badge>;
|
|
12
|
+
|
|
13
|
+
export default meta;
|
|
14
|
+
type Story = StoryObj<typeof meta>;
|
|
15
|
+
|
|
16
|
+
export const Primary: Story = { args: { children: 'Primary', variant: 'primary' } };
|
|
17
|
+
export const Secondary: Story = { args: { children: 'Secondary', variant: 'secondary' } };
|
|
18
|
+
export const Success: Story = { args: { children: 'Success', variant: 'success' } };
|
|
19
|
+
export const Error: Story = { args: { children: 'Error', variant: 'error' } };
|
|
20
|
+
export const Warning: Story = { args: { children: 'Warning', variant: 'warning' } };
|
|
21
|
+
export const AllVariants: Story = {
|
|
22
|
+
render: () => (
|
|
23
|
+
<div style={{ display: 'flex', gap: '8px', flexWrap: 'wrap' }}>
|
|
24
|
+
{(['primary', 'secondary', 'success', 'error', 'warning'] as const).map(v => (
|
|
25
|
+
<Badge key={v} variant={v}>{v}</Badge>
|
|
26
|
+
))}
|
|
27
|
+
</div>
|
|
28
|
+
),
|
|
29
|
+
};
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { ReactNode } from 'react';
|
|
2
|
+
import css from './Badge.module.css';
|
|
3
|
+
import { cn } from '@boostdev/design-system-foundation';
|
|
4
|
+
|
|
5
|
+
interface BadgeProps {
|
|
6
|
+
children: ReactNode;
|
|
7
|
+
variant?: 'primary' | 'secondary' | 'success' | 'error' | 'warning';
|
|
8
|
+
className?: string;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
export function Badge({ children, variant = 'primary', className }: BadgeProps) {
|
|
12
|
+
return <span className={cn(css.badge, css[`--variant_${variant}`], className)}>{children}</span>;
|
|
13
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { Badge } from './Badge';
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
@layer component {
|
|
2
|
+
.breadcrumb {
|
|
3
|
+
font-size: var(--font_size--body--s);
|
|
4
|
+
}
|
|
5
|
+
|
|
6
|
+
.list {
|
|
7
|
+
display: flex;
|
|
8
|
+
flex-wrap: wrap;
|
|
9
|
+
align-items: center;
|
|
10
|
+
gap: var(--space_xxs);
|
|
11
|
+
list-style: none;
|
|
12
|
+
margin: 0;
|
|
13
|
+
padding: 0;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
.item {
|
|
17
|
+
display: flex;
|
|
18
|
+
align-items: center;
|
|
19
|
+
gap: var(--space_xxs);
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
.link {
|
|
23
|
+
color: var(--color_interactive);
|
|
24
|
+
text-decoration: none;
|
|
25
|
+
transition: var(--animation_transition);
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
.link:focus-visible {
|
|
29
|
+
outline: var(--outline_default);
|
|
30
|
+
outline-offset: var(--outline_offset);
|
|
31
|
+
border-radius: var(--border_radius--xs);
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
@media (hover: hover) and (pointer: fine) {
|
|
35
|
+
.link:hover {
|
|
36
|
+
text-decoration: underline;
|
|
37
|
+
text-underline-offset: 0.2em;
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
.separator {
|
|
42
|
+
color: var(--color_on-bg--subtle);
|
|
43
|
+
user-select: none;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
.current {
|
|
47
|
+
color: var(--color_on-bg--subtle);
|
|
48
|
+
font-weight: var(--font_weight--semibold);
|
|
49
|
+
}
|
|
50
|
+
}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { render, screen } from '@testing-library/react';
|
|
2
|
+
import { Breadcrumb } from './Breadcrumb';
|
|
3
|
+
|
|
4
|
+
const items = [
|
|
5
|
+
{ label: 'Home', href: '/' },
|
|
6
|
+
{ label: 'Products', href: '/products' },
|
|
7
|
+
{ label: 'Shoes' },
|
|
8
|
+
];
|
|
9
|
+
|
|
10
|
+
describe('Breadcrumb', () => {
|
|
11
|
+
it('renders a navigation landmark', () => {
|
|
12
|
+
render(<Breadcrumb items={items} />);
|
|
13
|
+
expect(screen.getByRole('navigation', { name: 'Breadcrumb' })).toBeInTheDocument();
|
|
14
|
+
});
|
|
15
|
+
|
|
16
|
+
it('renders all items', () => {
|
|
17
|
+
render(<Breadcrumb items={items} />);
|
|
18
|
+
expect(screen.getByText('Home')).toBeInTheDocument();
|
|
19
|
+
expect(screen.getByText('Products')).toBeInTheDocument();
|
|
20
|
+
expect(screen.getByText('Shoes')).toBeInTheDocument();
|
|
21
|
+
});
|
|
22
|
+
|
|
23
|
+
it('renders intermediate items as links', () => {
|
|
24
|
+
render(<Breadcrumb items={items} />);
|
|
25
|
+
expect(screen.getByRole('link', { name: 'Home' })).toHaveAttribute('href', '/');
|
|
26
|
+
expect(screen.getByRole('link', { name: 'Products' })).toHaveAttribute('href', '/products');
|
|
27
|
+
});
|
|
28
|
+
|
|
29
|
+
it('renders the last item as current page, not a link', () => {
|
|
30
|
+
render(<Breadcrumb items={items} />);
|
|
31
|
+
expect(screen.queryByRole('link', { name: 'Shoes' })).not.toBeInTheDocument();
|
|
32
|
+
expect(screen.getByText('Shoes')).toHaveAttribute('aria-current', 'page');
|
|
33
|
+
});
|
|
34
|
+
|
|
35
|
+
it('renders a single item as the current page', () => {
|
|
36
|
+
render(<Breadcrumb items={[{ label: 'Home' }]} />);
|
|
37
|
+
expect(screen.getByText('Home')).toHaveAttribute('aria-current', 'page');
|
|
38
|
+
});
|
|
39
|
+
|
|
40
|
+
it('accepts a custom className', () => {
|
|
41
|
+
render(<Breadcrumb items={items} className="custom" />);
|
|
42
|
+
expect(screen.getByRole('navigation')).toHaveClass('custom');
|
|
43
|
+
});
|
|
44
|
+
});
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import type { Meta, StoryObj } from '@storybook/react';
|
|
2
|
+
import { Breadcrumb } from './Breadcrumb';
|
|
3
|
+
|
|
4
|
+
const meta = {
|
|
5
|
+
title: 'UI/Breadcrumb',
|
|
6
|
+
component: Breadcrumb,
|
|
7
|
+
tags: ['autodocs'],
|
|
8
|
+
} satisfies Meta<typeof Breadcrumb>;
|
|
9
|
+
|
|
10
|
+
export default meta;
|
|
11
|
+
type Story = StoryObj<typeof meta>;
|
|
12
|
+
|
|
13
|
+
export const Default: Story = {
|
|
14
|
+
args: {
|
|
15
|
+
items: [
|
|
16
|
+
{ label: 'Home', href: '/' },
|
|
17
|
+
{ label: 'Products', href: '/products' },
|
|
18
|
+
{ label: 'Running shoes' },
|
|
19
|
+
],
|
|
20
|
+
},
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
export const TwoLevels: Story = {
|
|
24
|
+
args: {
|
|
25
|
+
items: [
|
|
26
|
+
{ label: 'Home', href: '/' },
|
|
27
|
+
{ label: 'About' },
|
|
28
|
+
],
|
|
29
|
+
},
|
|
30
|
+
};
|
|
31
|
+
|
|
32
|
+
export const SingleLevel: Story = {
|
|
33
|
+
args: {
|
|
34
|
+
items: [{ label: 'Home' }],
|
|
35
|
+
},
|
|
36
|
+
};
|
|
37
|
+
|
|
38
|
+
export const DeepNested: Story = {
|
|
39
|
+
args: {
|
|
40
|
+
items: [
|
|
41
|
+
{ label: 'Home', href: '/' },
|
|
42
|
+
{ label: 'Shop', href: '/shop' },
|
|
43
|
+
{ label: 'Men', href: '/shop/men' },
|
|
44
|
+
{ label: 'Footwear', href: '/shop/men/footwear' },
|
|
45
|
+
{ label: 'Running shoes' },
|
|
46
|
+
],
|
|
47
|
+
},
|
|
48
|
+
};
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import css from './Breadcrumb.module.css';
|
|
2
|
+
import { cn } from '@boostdev/design-system-foundation';
|
|
3
|
+
|
|
4
|
+
interface BreadcrumbItem {
|
|
5
|
+
label: string;
|
|
6
|
+
href?: string;
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
interface BreadcrumbProps {
|
|
10
|
+
items: BreadcrumbItem[];
|
|
11
|
+
className?: string;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
export function Breadcrumb({ items, className }: Readonly<BreadcrumbProps>) {
|
|
15
|
+
return (
|
|
16
|
+
<nav aria-label="Breadcrumb" className={cn(css.breadcrumb, className)}>
|
|
17
|
+
<ol className={css.list}>
|
|
18
|
+
{items.map((item, index) => {
|
|
19
|
+
const isLast = index === items.length - 1;
|
|
20
|
+
|
|
21
|
+
return (
|
|
22
|
+
<li key={item.label} className={css.item}>
|
|
23
|
+
{isLast ? (
|
|
24
|
+
<span aria-current="page" className={css.current}>
|
|
25
|
+
{item.label}
|
|
26
|
+
</span>
|
|
27
|
+
) : (
|
|
28
|
+
<>
|
|
29
|
+
<a href={item.href} className={css.link}>
|
|
30
|
+
{item.label}
|
|
31
|
+
</a>
|
|
32
|
+
<span className={css.separator} aria-hidden="true">›</span>
|
|
33
|
+
</>
|
|
34
|
+
)}
|
|
35
|
+
</li>
|
|
36
|
+
);
|
|
37
|
+
})}
|
|
38
|
+
</ol>
|
|
39
|
+
</nav>
|
|
40
|
+
);
|
|
41
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { Breadcrumb } from './Breadcrumb';
|
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
@layer component {
|
|
2
|
+
.calendar {
|
|
3
|
+
display: inline-flex;
|
|
4
|
+
flex-direction: column;
|
|
5
|
+
gap: var(--space_s);
|
|
6
|
+
background-color: var(--color_bg);
|
|
7
|
+
border: 1px solid var(--color_bg--subtle);
|
|
8
|
+
border-radius: var(--border_radius--m);
|
|
9
|
+
padding: var(--space_m);
|
|
10
|
+
box-shadow: var(--shadow_s);
|
|
11
|
+
width: 20rem;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
.header {
|
|
15
|
+
display: flex;
|
|
16
|
+
align-items: center;
|
|
17
|
+
justify-content: space-between;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
.monthYear {
|
|
21
|
+
font-size: var(--font_size--body);
|
|
22
|
+
font-weight: var(--font_weight--semibold);
|
|
23
|
+
color: var(--color_on-bg);
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
.navBtn {
|
|
27
|
+
all: unset;
|
|
28
|
+
display: flex;
|
|
29
|
+
align-items: center;
|
|
30
|
+
justify-content: center;
|
|
31
|
+
width: 2rem;
|
|
32
|
+
height: 2rem;
|
|
33
|
+
border-radius: 50%;
|
|
34
|
+
cursor: pointer;
|
|
35
|
+
color: var(--color_on-bg);
|
|
36
|
+
transition: var(--animation_transition);
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
.navBtn svg {
|
|
40
|
+
width: 1rem;
|
|
41
|
+
height: 1rem;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
.navBtn:focus-visible {
|
|
45
|
+
outline: var(--outline_default);
|
|
46
|
+
outline-offset: var(--outline_offset);
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
@media (hover: hover) and (pointer: fine) {
|
|
50
|
+
.navBtn:hover {
|
|
51
|
+
background-color: var(--color_bg--subtle);
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
.grid {
|
|
56
|
+
border-collapse: collapse;
|
|
57
|
+
width: 100%;
|
|
58
|
+
table-layout: fixed;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
.weekday {
|
|
62
|
+
font-size: var(--font_size--body--s);
|
|
63
|
+
font-weight: var(--font_weight--semibold);
|
|
64
|
+
color: var(--color_on-bg--muted);
|
|
65
|
+
text-align: center;
|
|
66
|
+
padding-block-end: var(--space_xs);
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
.empty {
|
|
70
|
+
padding: 0;
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
.day {
|
|
74
|
+
all: unset;
|
|
75
|
+
display: flex;
|
|
76
|
+
align-items: center;
|
|
77
|
+
justify-content: center;
|
|
78
|
+
width: 100%;
|
|
79
|
+
aspect-ratio: 1;
|
|
80
|
+
border-radius: 50%;
|
|
81
|
+
font-size: var(--font_size--body--s);
|
|
82
|
+
color: var(--color_on-bg);
|
|
83
|
+
cursor: pointer;
|
|
84
|
+
transition: var(--animation_transition);
|
|
85
|
+
box-sizing: border-box;
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
.day:focus-visible {
|
|
89
|
+
outline: var(--outline_default);
|
|
90
|
+
outline-offset: var(--outline_offset);
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
@media (hover: hover) and (pointer: fine) {
|
|
94
|
+
.day:not(.disabled, .selected):hover {
|
|
95
|
+
background-color: var(--color_bg--subtle);
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
.today {
|
|
100
|
+
border: 2px solid var(--color_interactive);
|
|
101
|
+
font-weight: var(--font_weight--semibold);
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
.selected {
|
|
105
|
+
background-color: var(--color_interactive);
|
|
106
|
+
color: var(--color_on-interactive);
|
|
107
|
+
font-weight: var(--font_weight--semibold);
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
.disabled {
|
|
111
|
+
opacity: 0.35;
|
|
112
|
+
cursor: not-allowed;
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
@media (prefers-reduced-motion: reduce) {
|
|
116
|
+
.day {
|
|
117
|
+
transition: none;
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
}
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import { render, screen } from '@testing-library/react';
|
|
2
|
+
import userEvent from '@testing-library/user-event';
|
|
3
|
+
import { Calendar } from './Calendar';
|
|
4
|
+
|
|
5
|
+
// Pin to a known date for deterministic tests
|
|
6
|
+
const FIXED_DATE = new Date(2024, 0, 15); // January 15, 2024
|
|
7
|
+
|
|
8
|
+
describe('Calendar', () => {
|
|
9
|
+
it('renders navigation buttons', () => {
|
|
10
|
+
render(<Calendar value={FIXED_DATE} onChange={() => {}} />);
|
|
11
|
+
expect(screen.getByRole('button', { name: 'Previous month' })).toBeInTheDocument();
|
|
12
|
+
expect(screen.getByRole('button', { name: 'Next month' })).toBeInTheDocument();
|
|
13
|
+
});
|
|
14
|
+
|
|
15
|
+
it('renders the current month and year', () => {
|
|
16
|
+
render(<Calendar value={FIXED_DATE} onChange={() => {}} />);
|
|
17
|
+
expect(screen.getByText('January 2024')).toBeInTheDocument();
|
|
18
|
+
});
|
|
19
|
+
|
|
20
|
+
it('renders day buttons', () => {
|
|
21
|
+
render(<Calendar value={FIXED_DATE} onChange={() => {}} />);
|
|
22
|
+
// January 2024 has 31 days
|
|
23
|
+
expect(screen.getAllByRole('button').filter(b => b.textContent?.match(/^\d+$/))).toHaveLength(31);
|
|
24
|
+
});
|
|
25
|
+
|
|
26
|
+
it('navigates to next month', async () => {
|
|
27
|
+
render(<Calendar value={FIXED_DATE} onChange={() => {}} />);
|
|
28
|
+
await userEvent.click(screen.getByRole('button', { name: 'Next month' }));
|
|
29
|
+
expect(screen.getByText('February 2024')).toBeInTheDocument();
|
|
30
|
+
});
|
|
31
|
+
|
|
32
|
+
it('navigates to previous month', async () => {
|
|
33
|
+
render(<Calendar value={FIXED_DATE} onChange={() => {}} />);
|
|
34
|
+
await userEvent.click(screen.getByRole('button', { name: 'Previous month' }));
|
|
35
|
+
expect(screen.getByText('December 2023')).toBeInTheDocument();
|
|
36
|
+
});
|
|
37
|
+
|
|
38
|
+
it('calls onChange when a date is selected', async () => {
|
|
39
|
+
const onChange = vi.fn();
|
|
40
|
+
render(<Calendar value={FIXED_DATE} onChange={onChange} />);
|
|
41
|
+
// Click on the 20th
|
|
42
|
+
const buttons = screen.getAllByRole('button').filter(b => b.textContent === '20');
|
|
43
|
+
await userEvent.click(buttons[0]);
|
|
44
|
+
expect(onChange).toHaveBeenCalledOnce();
|
|
45
|
+
const called = onChange.mock.calls[0][0] as Date;
|
|
46
|
+
expect(called.getDate()).toBe(20);
|
|
47
|
+
expect(called.getMonth()).toBe(0); // January
|
|
48
|
+
});
|
|
49
|
+
|
|
50
|
+
it('renders day-of-week headers', () => {
|
|
51
|
+
render(<Calendar value={FIXED_DATE} onChange={() => {}} />);
|
|
52
|
+
expect(screen.getByText('Mo')).toBeInTheDocument();
|
|
53
|
+
expect(screen.getByText('Su')).toBeInTheDocument();
|
|
54
|
+
});
|
|
55
|
+
|
|
56
|
+
it('disables days outside min/max range', () => {
|
|
57
|
+
const min = new Date(2024, 0, 10);
|
|
58
|
+
const max = new Date(2024, 0, 20);
|
|
59
|
+
render(<Calendar value={FIXED_DATE} min={min} max={max} onChange={() => {}} />);
|
|
60
|
+
// Day 5 should be disabled
|
|
61
|
+
const day5 = screen.getAllByRole('button').find(b => b.textContent === '5' && b.hasAttribute('disabled'));
|
|
62
|
+
expect(day5).toBeDefined();
|
|
63
|
+
});
|
|
64
|
+
});
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import { useState } from 'react';
|
|
2
|
+
import type { Meta, StoryObj } from '@storybook/react';
|
|
3
|
+
import { Calendar } from './Calendar';
|
|
4
|
+
|
|
5
|
+
const meta = {
|
|
6
|
+
title: 'UI/Calendar',
|
|
7
|
+
component: Calendar,
|
|
8
|
+
tags: ['autodocs'],
|
|
9
|
+
decorators: [
|
|
10
|
+
Story => (
|
|
11
|
+
<div style={{ display: 'flex', justifyContent: 'center', padding: '2rem' }}>
|
|
12
|
+
<Story />
|
|
13
|
+
</div>
|
|
14
|
+
),
|
|
15
|
+
],
|
|
16
|
+
} satisfies Meta<typeof Calendar>;
|
|
17
|
+
|
|
18
|
+
export default meta;
|
|
19
|
+
type Story = StoryObj<typeof meta>;
|
|
20
|
+
|
|
21
|
+
export const Default: Story = {
|
|
22
|
+
render: () => {
|
|
23
|
+
const [value, setValue] = useState<Date | undefined>();
|
|
24
|
+
return (
|
|
25
|
+
<div>
|
|
26
|
+
<Calendar value={value} onChange={setValue} />
|
|
27
|
+
{value && (
|
|
28
|
+
<p style={{ marginTop: '1rem', textAlign: 'center', fontSize: '0.875rem' }}>
|
|
29
|
+
Selected: {value.toLocaleDateString()}
|
|
30
|
+
</p>
|
|
31
|
+
)}
|
|
32
|
+
</div>
|
|
33
|
+
);
|
|
34
|
+
},
|
|
35
|
+
};
|
|
36
|
+
|
|
37
|
+
export const WithDefaultValue: Story = {
|
|
38
|
+
render: () => {
|
|
39
|
+
const [value, setValue] = useState<Date | undefined>(new Date(2024, 5, 15));
|
|
40
|
+
return <Calendar value={value} onChange={setValue} />;
|
|
41
|
+
},
|
|
42
|
+
};
|
|
43
|
+
|
|
44
|
+
export const WithMinMax: Story = {
|
|
45
|
+
render: () => {
|
|
46
|
+
const today = new Date();
|
|
47
|
+
const min = new Date(today.getFullYear(), today.getMonth(), 1);
|
|
48
|
+
const max = new Date(today.getFullYear(), today.getMonth() + 1, 0);
|
|
49
|
+
const [value, setValue] = useState<Date | undefined>();
|
|
50
|
+
return (
|
|
51
|
+
<div>
|
|
52
|
+
<Calendar value={value} min={min} max={max} onChange={setValue} />
|
|
53
|
+
<p style={{ marginTop: '0.5rem', textAlign: 'center', fontSize: '0.75rem', color: 'gray' }}>
|
|
54
|
+
Only current month dates are selectable
|
|
55
|
+
</p>
|
|
56
|
+
</div>
|
|
57
|
+
);
|
|
58
|
+
},
|
|
59
|
+
};
|