@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,69 @@
|
|
|
1
|
+
@layer component {
|
|
2
|
+
.wrapper {
|
|
3
|
+
position: relative;
|
|
4
|
+
display: inline-flex;
|
|
5
|
+
align-items: center;
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
.tooltip {
|
|
9
|
+
--tooltip_bg: var(--color_on-bg);
|
|
10
|
+
--tooltip_text: var(--color_bg);
|
|
11
|
+
|
|
12
|
+
position: absolute;
|
|
13
|
+
z-index: var(--z-index_popover);
|
|
14
|
+
padding: var(--space_xxs) var(--space_xs);
|
|
15
|
+
border-radius: var(--border_radius--xs);
|
|
16
|
+
background-color: var(--tooltip_bg);
|
|
17
|
+
color: var(--tooltip_text);
|
|
18
|
+
font-size: var(--font_size--body--s);
|
|
19
|
+
line-height: var(--font_line-height--body);
|
|
20
|
+
white-space: nowrap;
|
|
21
|
+
pointer-events: none;
|
|
22
|
+
|
|
23
|
+
/* Hidden by default */
|
|
24
|
+
visibility: hidden;
|
|
25
|
+
opacity: 0;
|
|
26
|
+
transition: opacity var(--animation_transition-duration) var(--animation_easing);
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
/* Show on hover and keyboard focus */
|
|
30
|
+
.wrapper:hover .tooltip,
|
|
31
|
+
.wrapper:focus-within .tooltip {
|
|
32
|
+
visibility: visible;
|
|
33
|
+
opacity: 1;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
/* Placement: top (default) */
|
|
37
|
+
.--placement_top {
|
|
38
|
+
bottom: calc(100% + var(--space_xs));
|
|
39
|
+
left: 50%;
|
|
40
|
+
transform: translateX(-50%);
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
/* Placement: bottom */
|
|
44
|
+
.--placement_bottom {
|
|
45
|
+
top: calc(100% + var(--space_xs));
|
|
46
|
+
left: 50%;
|
|
47
|
+
transform: translateX(-50%);
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
/* Placement: left */
|
|
51
|
+
.--placement_left {
|
|
52
|
+
right: calc(100% + var(--space_xs));
|
|
53
|
+
top: 50%;
|
|
54
|
+
transform: translateY(-50%);
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
/* Placement: right */
|
|
58
|
+
.--placement_right {
|
|
59
|
+
left: calc(100% + var(--space_xs));
|
|
60
|
+
top: 50%;
|
|
61
|
+
transform: translateY(-50%);
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
@media (prefers-reduced-motion: reduce) {
|
|
65
|
+
.tooltip {
|
|
66
|
+
transition: none;
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { render, screen } from '@testing-library/react';
|
|
2
|
+
import userEvent from '@testing-library/user-event';
|
|
3
|
+
import { Tooltip } from './Tooltip';
|
|
4
|
+
|
|
5
|
+
describe('Tooltip', () => {
|
|
6
|
+
it('renders the trigger element', () => {
|
|
7
|
+
render(
|
|
8
|
+
<Tooltip content="More info">
|
|
9
|
+
<button type="button">Hover me</button>
|
|
10
|
+
</Tooltip>
|
|
11
|
+
);
|
|
12
|
+
expect(screen.getByRole('button', { name: 'Hover me' })).toBeInTheDocument();
|
|
13
|
+
});
|
|
14
|
+
|
|
15
|
+
it('renders the tooltip content', () => {
|
|
16
|
+
render(
|
|
17
|
+
<Tooltip content="Tooltip text">
|
|
18
|
+
<button type="button">Trigger</button>
|
|
19
|
+
</Tooltip>
|
|
20
|
+
);
|
|
21
|
+
expect(screen.getByRole('tooltip')).toBeInTheDocument();
|
|
22
|
+
expect(screen.getByRole('tooltip')).toHaveTextContent('Tooltip text');
|
|
23
|
+
});
|
|
24
|
+
|
|
25
|
+
it('links trigger to tooltip via aria-describedby', () => {
|
|
26
|
+
render(
|
|
27
|
+
<Tooltip content="Helpful hint">
|
|
28
|
+
<button type="button">Action</button>
|
|
29
|
+
</Tooltip>
|
|
30
|
+
);
|
|
31
|
+
const trigger = screen.getByRole('button', { name: 'Action' });
|
|
32
|
+
const tooltip = screen.getByRole('tooltip');
|
|
33
|
+
expect(trigger).toHaveAttribute('aria-describedby', tooltip.id);
|
|
34
|
+
});
|
|
35
|
+
|
|
36
|
+
it('shows tooltip on focus', async () => {
|
|
37
|
+
const user = userEvent.setup();
|
|
38
|
+
render(
|
|
39
|
+
<Tooltip content="Focused">
|
|
40
|
+
<button type="button">Focus me</button>
|
|
41
|
+
</Tooltip>
|
|
42
|
+
);
|
|
43
|
+
await user.tab();
|
|
44
|
+
expect(screen.getByRole('tooltip')).toBeVisible();
|
|
45
|
+
});
|
|
46
|
+
});
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
import type { Meta, StoryObj } from '@storybook/react';
|
|
2
|
+
import { Tooltip } from './Tooltip';
|
|
3
|
+
|
|
4
|
+
const meta = {
|
|
5
|
+
title: 'UI/Tooltip',
|
|
6
|
+
component: Tooltip,
|
|
7
|
+
tags: ['autodocs'],
|
|
8
|
+
argTypes: {
|
|
9
|
+
placement: { control: 'radio', options: ['top', 'bottom', 'left', 'right'] },
|
|
10
|
+
},
|
|
11
|
+
decorators: [
|
|
12
|
+
Story => (
|
|
13
|
+
<div style={{ display: 'flex', alignItems: 'center', justifyContent: 'center', padding: '4rem' }}>
|
|
14
|
+
<Story />
|
|
15
|
+
</div>
|
|
16
|
+
),
|
|
17
|
+
],
|
|
18
|
+
} satisfies Meta<typeof Tooltip>;
|
|
19
|
+
|
|
20
|
+
export default meta;
|
|
21
|
+
type Story = StoryObj<typeof meta>;
|
|
22
|
+
|
|
23
|
+
export const Top: Story = {
|
|
24
|
+
args: { content: 'Helpful tip', placement: 'top' },
|
|
25
|
+
render: args => (
|
|
26
|
+
<Tooltip {...args}>
|
|
27
|
+
<button type="button">Hover or focus me</button>
|
|
28
|
+
</Tooltip>
|
|
29
|
+
),
|
|
30
|
+
};
|
|
31
|
+
|
|
32
|
+
export const Bottom: Story = {
|
|
33
|
+
args: { content: 'Below the trigger', placement: 'bottom' },
|
|
34
|
+
render: args => (
|
|
35
|
+
<Tooltip {...args}>
|
|
36
|
+
<button type="button">Bottom tooltip</button>
|
|
37
|
+
</Tooltip>
|
|
38
|
+
),
|
|
39
|
+
};
|
|
40
|
+
|
|
41
|
+
export const Left: Story = {
|
|
42
|
+
args: { content: 'On the left', placement: 'left' },
|
|
43
|
+
render: args => (
|
|
44
|
+
<Tooltip {...args}>
|
|
45
|
+
<button type="button">Left tooltip</button>
|
|
46
|
+
</Tooltip>
|
|
47
|
+
),
|
|
48
|
+
};
|
|
49
|
+
|
|
50
|
+
export const Right: Story = {
|
|
51
|
+
args: { content: 'On the right', placement: 'right' },
|
|
52
|
+
render: args => (
|
|
53
|
+
<Tooltip {...args}>
|
|
54
|
+
<button type="button">Right tooltip</button>
|
|
55
|
+
</Tooltip>
|
|
56
|
+
),
|
|
57
|
+
};
|
|
58
|
+
|
|
59
|
+
export const AllPlacements: Story = {
|
|
60
|
+
render: () => (
|
|
61
|
+
<div style={{ display: 'grid', gridTemplateColumns: 'repeat(2, 1fr)', gap: '3rem' }}>
|
|
62
|
+
{(['top', 'bottom', 'left', 'right'] as const).map(p => (
|
|
63
|
+
<Tooltip key={p} content={`Placement: ${p}`} placement={p}>
|
|
64
|
+
<button type="button">{p}</button>
|
|
65
|
+
</Tooltip>
|
|
66
|
+
))}
|
|
67
|
+
</div>
|
|
68
|
+
),
|
|
69
|
+
};
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { ReactElement, ReactNode, cloneElement, isValidElement, useId } from 'react';
|
|
2
|
+
import css from './Tooltip.module.css';
|
|
3
|
+
import { cn } from '@boostdev/design-system-foundation';
|
|
4
|
+
|
|
5
|
+
interface TooltipProps {
|
|
6
|
+
content: ReactNode;
|
|
7
|
+
placement?: 'top' | 'bottom' | 'left' | 'right';
|
|
8
|
+
children: ReactElement;
|
|
9
|
+
className?: string;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
export function Tooltip({
|
|
13
|
+
content,
|
|
14
|
+
placement = 'top',
|
|
15
|
+
children,
|
|
16
|
+
className,
|
|
17
|
+
}: Readonly<TooltipProps>) {
|
|
18
|
+
const tooltipId = useId();
|
|
19
|
+
|
|
20
|
+
const trigger = isValidElement(children)
|
|
21
|
+
? cloneElement(children as ReactElement<Record<string, unknown>>, {
|
|
22
|
+
'aria-describedby': tooltipId,
|
|
23
|
+
})
|
|
24
|
+
: children;
|
|
25
|
+
|
|
26
|
+
return (
|
|
27
|
+
<span className={cn(css.wrapper, className)}>
|
|
28
|
+
{trigger}
|
|
29
|
+
<span
|
|
30
|
+
id={tooltipId}
|
|
31
|
+
role="tooltip"
|
|
32
|
+
className={cn(css.tooltip, css[`--placement_${placement}`])}
|
|
33
|
+
>
|
|
34
|
+
{content}
|
|
35
|
+
</span>
|
|
36
|
+
</span>
|
|
37
|
+
);
|
|
38
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { Tooltip } from './Tooltip';
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
@layer component {
|
|
2
|
+
.typography {
|
|
3
|
+
/* Component token — override from a parent context or inline style */
|
|
4
|
+
--typography_color: var(--color_on-bg);
|
|
5
|
+
|
|
6
|
+
margin: 0;
|
|
7
|
+
font-family: var(--font_family--body);
|
|
8
|
+
color: var(--typography_color);
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
.--h1 {
|
|
12
|
+
font-family: var(--font_family--heading);
|
|
13
|
+
font-size: var(--font_size--heading-1);
|
|
14
|
+
font-weight: var(--font_weight--bold);
|
|
15
|
+
line-height: var(--font_line-height--heading);
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
.--h2 {
|
|
19
|
+
font-family: var(--font_family--heading);
|
|
20
|
+
font-size: var(--font_size--heading-2);
|
|
21
|
+
font-weight: var(--font_weight--semibold);
|
|
22
|
+
line-height: var(--font_line-height--heading);
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
.--h3 {
|
|
26
|
+
font-family: var(--font_family--heading);
|
|
27
|
+
font-size: var(--font_size--heading-3);
|
|
28
|
+
font-weight: var(--font_weight--semibold);
|
|
29
|
+
line-height: var(--font_line-height--heading);
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
.--body {
|
|
33
|
+
font-size: var(--font_size--body);
|
|
34
|
+
line-height: var(--font_line-height--body);
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
.--body_s {
|
|
38
|
+
font-size: var(--font_size--body--s);
|
|
39
|
+
line-height: var(--font_line-height--body);
|
|
40
|
+
}
|
|
41
|
+
}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { render, screen } from '@testing-library/react';
|
|
2
|
+
import { Typography } from './Typography';
|
|
3
|
+
|
|
4
|
+
describe('Typography', () => {
|
|
5
|
+
it('renders an h1 for the h1 variant', () => {
|
|
6
|
+
render(<Typography variant="h1">Title</Typography>);
|
|
7
|
+
expect(screen.getByRole('heading', { level: 1 })).toBeInTheDocument();
|
|
8
|
+
});
|
|
9
|
+
|
|
10
|
+
it('renders an h2 for the h2 variant', () => {
|
|
11
|
+
render(<Typography variant="h2">Subtitle</Typography>);
|
|
12
|
+
expect(screen.getByRole('heading', { level: 2 })).toBeInTheDocument();
|
|
13
|
+
});
|
|
14
|
+
|
|
15
|
+
it('renders an h3 for the h3 variant', () => {
|
|
16
|
+
render(<Typography variant="h3">Sub</Typography>);
|
|
17
|
+
expect(screen.getByRole('heading', { level: 3 })).toBeInTheDocument();
|
|
18
|
+
});
|
|
19
|
+
|
|
20
|
+
it('renders a p for the body variant', () => {
|
|
21
|
+
render(<Typography variant="body">Text</Typography>);
|
|
22
|
+
expect(screen.getByText('Text').tagName).toBe('P');
|
|
23
|
+
});
|
|
24
|
+
|
|
25
|
+
it('renders a p for the body_s variant', () => {
|
|
26
|
+
render(<Typography variant="body_s">Small</Typography>);
|
|
27
|
+
expect(screen.getByText('Small').tagName).toBe('P');
|
|
28
|
+
});
|
|
29
|
+
|
|
30
|
+
it('allows overriding the element via component prop', () => {
|
|
31
|
+
render(<Typography variant="h1" component="span">Custom</Typography>);
|
|
32
|
+
expect(screen.getByText('Custom').tagName).toBe('SPAN');
|
|
33
|
+
});
|
|
34
|
+
|
|
35
|
+
it('renders children', () => {
|
|
36
|
+
render(<Typography>Content</Typography>);
|
|
37
|
+
expect(screen.getByText('Content')).toBeInTheDocument();
|
|
38
|
+
});
|
|
39
|
+
});
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import type { Meta, StoryObj } from '@storybook/react';
|
|
2
|
+
import { Typography } from './Typography';
|
|
3
|
+
|
|
4
|
+
const meta = {
|
|
5
|
+
title: 'UI/Typography',
|
|
6
|
+
component: Typography,
|
|
7
|
+
tags: ['autodocs'],
|
|
8
|
+
argTypes: {
|
|
9
|
+
variant: { control: 'select', options: ['h1', 'h2', 'h3', 'body', 'body_s'] },
|
|
10
|
+
},
|
|
11
|
+
} satisfies Meta<typeof Typography>;
|
|
12
|
+
|
|
13
|
+
export default meta;
|
|
14
|
+
type Story = StoryObj<typeof meta>;
|
|
15
|
+
|
|
16
|
+
export const H1: Story = { args: { variant: 'h1', children: 'Heading 1' } };
|
|
17
|
+
export const H2: Story = { args: { variant: 'h2', children: 'Heading 2' } };
|
|
18
|
+
export const H3: Story = { args: { variant: 'h3', children: 'Heading 3' } };
|
|
19
|
+
export const Body: Story = { args: { variant: 'body', children: 'Body text paragraph content.' } };
|
|
20
|
+
export const BodySmall: Story = { args: { variant: 'body_s', children: 'Small body text.' } };
|
|
21
|
+
export const AllVariants: Story = {
|
|
22
|
+
render: () => (
|
|
23
|
+
<div style={{ display: 'flex', flexDirection: 'column', gap: '16px' }}>
|
|
24
|
+
<Typography variant="h1">Heading 1</Typography>
|
|
25
|
+
<Typography variant="h2">Heading 2</Typography>
|
|
26
|
+
<Typography variant="h3">Heading 3</Typography>
|
|
27
|
+
<Typography variant="body">Body text</Typography>
|
|
28
|
+
<Typography variant="body_s">Small body</Typography>
|
|
29
|
+
</div>
|
|
30
|
+
),
|
|
31
|
+
};
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { ReactNode, ElementType } from 'react';
|
|
2
|
+
import css from './Typography.module.css';
|
|
3
|
+
import { cn } from '@boostdev/design-system-foundation';
|
|
4
|
+
|
|
5
|
+
type TypographyVariant = 'h1' | 'h2' | 'h3' | 'body' | 'body_s';
|
|
6
|
+
|
|
7
|
+
interface TypographyProps {
|
|
8
|
+
variant?: TypographyVariant;
|
|
9
|
+
component?: ElementType;
|
|
10
|
+
children: ReactNode;
|
|
11
|
+
className?: string;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
const variantToElement: Record<TypographyVariant, ElementType> = {
|
|
15
|
+
h1: 'h1',
|
|
16
|
+
h2: 'h2',
|
|
17
|
+
h3: 'h3',
|
|
18
|
+
body: 'p',
|
|
19
|
+
body_s: 'p',
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
export function Typography({ variant = 'body', component, children, className }: TypographyProps) {
|
|
23
|
+
const Component = component || variantToElement[variant];
|
|
24
|
+
|
|
25
|
+
return (
|
|
26
|
+
<Component className={cn(css.typography, css[`--${variant}`], className)}>{children}</Component>
|
|
27
|
+
);
|
|
28
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { Typography } from './Typography';
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
/* @boostdev/components — framework-agnostic CSS barrel */
|
|
2
|
+
|
|
3
|
+
/* UI */
|
|
4
|
+
@import '../components/ui/Accordion/Accordion.module.css';
|
|
5
|
+
@import '../components/ui/Alert/Alert.module.css';
|
|
6
|
+
@import '../components/ui/Avatar/Avatar.module.css';
|
|
7
|
+
@import '../components/ui/Badge/Badge.module.css';
|
|
8
|
+
@import '../components/ui/Breadcrumb/Breadcrumb.module.css';
|
|
9
|
+
@import '../components/ui/Calendar/Calendar.module.css';
|
|
10
|
+
@import '../components/ui/Carousel/Carousel.module.css';
|
|
11
|
+
@import '../components/ui/DescriptionList/DescriptionList.module.css';
|
|
12
|
+
@import '../components/ui/Link/Link.module.css';
|
|
13
|
+
@import '../components/ui/Loading/Loading.module.css';
|
|
14
|
+
@import '../components/ui/NotificationBanner/NotificationBanner.module.css';
|
|
15
|
+
@import '../components/ui/Pagination/Pagination.module.css';
|
|
16
|
+
@import '../components/ui/Progress/Progress.module.css';
|
|
17
|
+
@import '../components/ui/ProgressCircle/ProgressCircle.module.css';
|
|
18
|
+
@import '../components/ui/Separator/Separator.module.css';
|
|
19
|
+
@import '../components/ui/Skeleton/Skeleton.module.css';
|
|
20
|
+
@import '../components/ui/SkipLink/SkipLink.module.css';
|
|
21
|
+
@import '../components/ui/Table/Table.module.css';
|
|
22
|
+
@import '../components/ui/Tabs/Tabs.module.css';
|
|
23
|
+
@import '../components/ui/Tooltip/Tooltip.module.css';
|
|
24
|
+
@import '../components/ui/Typography/Typography.module.css';
|
|
25
|
+
|
|
26
|
+
/* Interaction */
|
|
27
|
+
@import '../components/interaction/Button/Button.module.css';
|
|
28
|
+
@import '../components/interaction/Command/Command.module.css';
|
|
29
|
+
@import '../components/interaction/Dialog/Dialog.module.css';
|
|
30
|
+
@import '../components/interaction/Drawer/Drawer.module.css';
|
|
31
|
+
@import '../components/interaction/DropdownMenu/DropdownMenu.module.css';
|
|
32
|
+
@import '../components/interaction/Popover/Popover.module.css';
|
|
33
|
+
@import '../components/interaction/Rating/Rating.module.css';
|
|
34
|
+
@import '../components/interaction/Toast/Toast.module.css';
|
|
35
|
+
|
|
36
|
+
/* Form */
|
|
37
|
+
@import '../components/interaction/form/Checkbox/Checkbox.module.css';
|
|
38
|
+
@import '../components/interaction/form/Combobox/Combobox.module.css';
|
|
39
|
+
@import '../components/interaction/form/FileInput/FileInput.module.css';
|
|
40
|
+
@import '../components/interaction/form/FormInput/FormInput.module.css';
|
|
41
|
+
@import '../components/interaction/form/NumberInput/NumberInput.module.css';
|
|
42
|
+
@import '../components/interaction/form/Radio/Radio.module.css';
|
|
43
|
+
@import '../components/interaction/form/Select/Select.module.css';
|
|
44
|
+
@import '../components/interaction/form/Slider/Slider.module.css';
|
|
45
|
+
@import '../components/interaction/form/Switch/Switch.module.css';
|
|
46
|
+
@import '../components/interaction/form/Textarea/Textarea.module.css';
|
|
47
|
+
@import '../components/interaction/form/atoms/InputContainer.module.css';
|
|
48
|
+
@import '../components/interaction/form/atoms/Label.module.css';
|
|
49
|
+
@import '../components/interaction/form/atoms/Message.module.css';
|
|
50
|
+
|
|
51
|
+
/* Layout */
|
|
52
|
+
@import '../components/layout/ButtonGroup/ButtonGroup.module.css';
|
|
53
|
+
@import '../components/layout/Card/Card.module.css';
|
|
54
|
+
@import '../components/layout/IconWrapper/IconWrapper.module.css';
|
|
55
|
+
@import '../components/layout/SectionHeader/SectionHeader.module.css';
|
package/src/index.ts
ADDED
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
// UI
|
|
2
|
+
export { Accordion } from './components/ui/Accordion';
|
|
3
|
+
export { Alert } from './components/ui/Alert';
|
|
4
|
+
export { Avatar } from './components/ui/Avatar';
|
|
5
|
+
export { Badge } from './components/ui/Badge';
|
|
6
|
+
export { Breadcrumb } from './components/ui/Breadcrumb';
|
|
7
|
+
export { Calendar } from './components/ui/Calendar';
|
|
8
|
+
export { Carousel } from './components/ui/Carousel';
|
|
9
|
+
export { DescriptionList } from './components/ui/DescriptionList';
|
|
10
|
+
export { Link } from './components/ui/Link';
|
|
11
|
+
export { Loading } from './components/ui/Loading';
|
|
12
|
+
export { NotificationBanner } from './components/ui/NotificationBanner';
|
|
13
|
+
export { Pagination } from './components/ui/Pagination';
|
|
14
|
+
export { Progress } from './components/ui/Progress';
|
|
15
|
+
export { ProgressCircle } from './components/ui/ProgressCircle';
|
|
16
|
+
export { Separator } from './components/ui/Separator';
|
|
17
|
+
export { Skeleton } from './components/ui/Skeleton';
|
|
18
|
+
export { SkipLink } from './components/ui/SkipLink';
|
|
19
|
+
export { Table } from './components/ui/Table';
|
|
20
|
+
export { Tabs } from './components/ui/Tabs';
|
|
21
|
+
export { Tooltip } from './components/ui/Tooltip';
|
|
22
|
+
export { Typography } from './components/ui/Typography';
|
|
23
|
+
|
|
24
|
+
// Interaction
|
|
25
|
+
export { Button } from './components/interaction/Button';
|
|
26
|
+
export { Command } from './components/interaction/Command';
|
|
27
|
+
export type { CommandItem } from './components/interaction/Command';
|
|
28
|
+
export { Dialog } from './components/interaction/Dialog';
|
|
29
|
+
export { Drawer } from './components/interaction/Drawer';
|
|
30
|
+
export { DropdownMenu } from './components/interaction/DropdownMenu';
|
|
31
|
+
export { Popover } from './components/interaction/Popover';
|
|
32
|
+
export { Rating } from './components/interaction/Rating';
|
|
33
|
+
export { ToastProvider, useToast } from './components/interaction/Toast';
|
|
34
|
+
|
|
35
|
+
// Form
|
|
36
|
+
export { Checkbox } from './components/interaction/form/Checkbox';
|
|
37
|
+
export { Combobox } from './components/interaction/form/Combobox';
|
|
38
|
+
export { FileInput } from './components/interaction/form/FileInput';
|
|
39
|
+
export { FormInput } from './components/interaction/form/FormInput';
|
|
40
|
+
export { NumberInput } from './components/interaction/form/NumberInput';
|
|
41
|
+
export { Radio } from './components/interaction/form/Radio';
|
|
42
|
+
export { Select } from './components/interaction/form/Select';
|
|
43
|
+
export { Slider } from './components/interaction/form/Slider';
|
|
44
|
+
export { Switch } from './components/interaction/form/Switch';
|
|
45
|
+
export { Textarea } from './components/interaction/form/Textarea';
|
|
46
|
+
|
|
47
|
+
// Layout
|
|
48
|
+
export { ButtonGroup } from './components/layout/ButtonGroup';
|
|
49
|
+
export { Card } from './components/layout/Card';
|
|
50
|
+
export { SectionHeader } from './components/layout/SectionHeader';
|
|
51
|
+
export { IconWrapper } from './components/layout/IconWrapper';
|
|
52
|
+
|
|
53
|
+
// Utilities
|
|
54
|
+
export { cn } from '@boostdev/design-system-foundation';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import '@testing-library/jest-dom';
|
package/src/typings.d.ts
ADDED