@robr0/design-system 0.1.0
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/LICENSE +21 -0
- package/README.md +127 -0
- package/charts.d.ts +14 -0
- package/charts.js +20 -0
- package/components/Accordion/Accordion.css +119 -0
- package/components/Accordion/Accordion.d.ts +24 -0
- package/components/Accordion/Accordion.js +76 -0
- package/components/Alert/Alert.css +252 -0
- package/components/Alert/Alert.d.ts +24 -0
- package/components/Alert/Alert.js +53 -0
- package/components/AlertDialog/AlertDialog.css +131 -0
- package/components/AlertDialog/AlertDialog.d.ts +29 -0
- package/components/AlertDialog/AlertDialog.js +143 -0
- package/components/AppLayout/AppLayout.css +52 -0
- package/components/AppLayout/AppLayout.d.ts +27 -0
- package/components/AppLayout/AppLayout.js +45 -0
- package/components/AppSidebar/AppSidebar.css +434 -0
- package/components/AppSidebar/AppSidebar.d.ts +67 -0
- package/components/AppSidebar/AppSidebar.js +272 -0
- package/components/Avatar/Avatar.css +133 -0
- package/components/Avatar/Avatar.d.ts +20 -0
- package/components/Avatar/Avatar.js +56 -0
- package/components/Avatar/demoAvatars.d.ts +14 -0
- package/components/Avatar/demoAvatars.js +16 -0
- package/components/Badge/Badge.css +68 -0
- package/components/Badge/Badge.d.ts +13 -0
- package/components/Badge/Badge.js +15 -0
- package/components/Breadcrumb/Breadcrumb.css +92 -0
- package/components/Breadcrumb/Breadcrumb.d.ts +19 -0
- package/components/Breadcrumb/Breadcrumb.js +39 -0
- package/components/Button/Button.css +381 -0
- package/components/Button/Button.d.ts +39 -0
- package/components/Button/Button.js +71 -0
- package/components/ButtonGroup/ButtonGroup.css +39 -0
- package/components/ButtonGroup/ButtonGroup.d.ts +13 -0
- package/components/ButtonGroup/ButtonGroup.js +37 -0
- package/components/Card/Card.css +169 -0
- package/components/Card/Card.d.ts +30 -0
- package/components/Card/Card.js +90 -0
- package/components/Carousel/Carousel.css +112 -0
- package/components/Carousel/Carousel.d.ts +25 -0
- package/components/Carousel/Carousel.js +126 -0
- package/components/Chart/AreaChart.d.ts +36 -0
- package/components/Chart/AreaChart.js +99 -0
- package/components/Chart/BarChart.d.ts +34 -0
- package/components/Chart/BarChart.js +107 -0
- package/components/Chart/Chart.css +176 -0
- package/components/Chart/LineChart.d.ts +34 -0
- package/components/Chart/LineChart.js +90 -0
- package/components/Chart/PieChart.d.ts +34 -0
- package/components/Chart/PieChart.js +106 -0
- package/components/Chart/RadarChart.d.ts +34 -0
- package/components/Chart/RadarChart.js +91 -0
- package/components/Chart/RadialChart.d.ts +37 -0
- package/components/Chart/RadialChart.js +119 -0
- package/components/Chart/ScatterChart.d.ts +36 -0
- package/components/Chart/ScatterChart.js +109 -0
- package/components/Chart/StackedBarChart.d.ts +34 -0
- package/components/Chart/StackedBarChart.js +111 -0
- package/components/Chart/Treemap.d.ts +33 -0
- package/components/Chart/Treemap.js +109 -0
- package/components/Checkbox/Checkbox.css +164 -0
- package/components/Checkbox/Checkbox.d.ts +45 -0
- package/components/Checkbox/Checkbox.js +125 -0
- package/components/Chip/Chip.css +195 -0
- package/components/Chip/Chip.d.ts +27 -0
- package/components/Chip/Chip.js +80 -0
- package/components/CircularButton/CircularButton.css +206 -0
- package/components/CircularButton/CircularButton.d.ts +30 -0
- package/components/CircularButton/CircularButton.js +54 -0
- package/components/CodeBlock/CodeBlock.css +180 -0
- package/components/CodeBlock/CodeBlock.d.ts +23 -0
- package/components/CodeBlock/CodeBlock.js +85 -0
- package/components/ColourSwatch/ColourSwatch.css +88 -0
- package/components/ColourSwatch/ColourSwatch.d.ts +34 -0
- package/components/ColourSwatch/ColourSwatch.js +42 -0
- package/components/Combobox/Combobox.css +411 -0
- package/components/Combobox/Combobox.d.ts +73 -0
- package/components/Combobox/Combobox.js +312 -0
- package/components/CommandPalette/CommandPalette.css +310 -0
- package/components/CommandPalette/CommandPalette.d.ts +60 -0
- package/components/CommandPalette/CommandPalette.js +263 -0
- package/components/ContactCard/ContactCard.css +123 -0
- package/components/ContactCard/ContactCard.d.ts +23 -0
- package/components/ContactCard/ContactCard.js +78 -0
- package/components/ContributionGraph/ContributionGraph.css +142 -0
- package/components/ContributionGraph/ContributionGraph.d.ts +26 -0
- package/components/ContributionGraph/ContributionGraph.js +125 -0
- package/components/DateInput/DateInput.css +163 -0
- package/components/DateInput/DateInput.d.ts +43 -0
- package/components/DateInput/DateInput.js +69 -0
- package/components/DatePicker/DatePicker.css +198 -0
- package/components/DatePicker/DatePicker.d.ts +22 -0
- package/components/DatePicker/DatePicker.js +170 -0
- package/components/Dialog/Dialog.css +176 -0
- package/components/Dialog/Dialog.d.ts +28 -0
- package/components/Dialog/Dialog.js +132 -0
- package/components/Divider/Divider.css +100 -0
- package/components/Divider/Divider.d.ts +18 -0
- package/components/Divider/Divider.js +31 -0
- package/components/Drawer/Drawer.css +262 -0
- package/components/Drawer/Drawer.d.ts +30 -0
- package/components/Drawer/Drawer.js +134 -0
- package/components/Dropdown/Dropdown.css +300 -0
- package/components/Dropdown/Dropdown.d.ts +48 -0
- package/components/Dropdown/Dropdown.js +196 -0
- package/components/DropdownMenu/DropdownMenu.css +303 -0
- package/components/DropdownMenu/DropdownMenu.d.ts +42 -0
- package/components/DropdownMenu/DropdownMenu.js +322 -0
- package/components/EmptyState/EmptyState.css +115 -0
- package/components/EmptyState/EmptyState.d.ts +27 -0
- package/components/EmptyState/EmptyState.js +32 -0
- package/components/EntityCard/EntityCard.css +69 -0
- package/components/EntityCard/EntityCard.d.ts +18 -0
- package/components/EntityCard/EntityCard.js +26 -0
- package/components/Figure/Figure.css +61 -0
- package/components/Figure/Figure.d.ts +17 -0
- package/components/Figure/Figure.js +35 -0
- package/components/FileInput/FileInput.css +308 -0
- package/components/FileInput/FileInput.d.ts +54 -0
- package/components/FileInput/FileInput.js +177 -0
- package/components/Input/Input.css +193 -0
- package/components/Input/Input.d.ts +40 -0
- package/components/Input/Input.js +71 -0
- package/components/Instructions/Instructions.css +216 -0
- package/components/Instructions/Instructions.d.ts +28 -0
- package/components/Instructions/Instructions.js +32 -0
- package/components/LinkList/LinkList.css +71 -0
- package/components/LinkList/LinkList.d.ts +20 -0
- package/components/LinkList/LinkList.js +41 -0
- package/components/MotionSwatch/MotionSwatch.css +176 -0
- package/components/MotionSwatch/MotionSwatch.d.ts +25 -0
- package/components/MotionSwatch/MotionSwatch.js +74 -0
- package/components/Nav/Nav.css +51 -0
- package/components/Nav/Nav.d.ts +19 -0
- package/components/Nav/Nav.js +26 -0
- package/components/Pagination/Pagination.css +126 -0
- package/components/Pagination/Pagination.d.ts +22 -0
- package/components/Pagination/Pagination.js +83 -0
- package/components/Popover/Popover.css +99 -0
- package/components/Popover/Popover.d.ts +28 -0
- package/components/Popover/Popover.js +102 -0
- package/components/ProgressBar/ProgressBar.css +60 -0
- package/components/ProgressBar/ProgressBar.d.ts +16 -0
- package/components/ProgressBar/ProgressBar.js +27 -0
- package/components/Quote/Quote.css +79 -0
- package/components/Quote/Quote.d.ts +18 -0
- package/components/Quote/Quote.js +26 -0
- package/components/RadioButton/RadioButton.css +132 -0
- package/components/RadioButton/RadioButton.d.ts +43 -0
- package/components/RadioButton/RadioButton.js +77 -0
- package/components/SectionTitle/SectionTitle.css +37 -0
- package/components/SectionTitle/SectionTitle.d.ts +10 -0
- package/components/SectionTitle/SectionTitle.js +17 -0
- package/components/SegmentedControl/SegmentedControl.css +129 -0
- package/components/SegmentedControl/SegmentedControl.d.ts +33 -0
- package/components/SegmentedControl/SegmentedControl.js +91 -0
- package/components/SelectionCard/SelectionCard.css +251 -0
- package/components/SelectionCard/SelectionCard.d.ts +26 -0
- package/components/SelectionCard/SelectionCard.js +85 -0
- package/components/Skeleton/Skeleton.css +79 -0
- package/components/Skeleton/Skeleton.d.ts +16 -0
- package/components/Skeleton/Skeleton.js +30 -0
- package/components/Slider/Slider.css +86 -0
- package/components/Slider/Slider.d.ts +25 -0
- package/components/Slider/Slider.js +46 -0
- package/components/SpacingSwatch/SpacingSwatch.css +108 -0
- package/components/SpacingSwatch/SpacingSwatch.d.ts +20 -0
- package/components/SpacingSwatch/SpacingSwatch.js +50 -0
- package/components/Spinner/Spinner.css +73 -0
- package/components/Spinner/Spinner.d.ts +14 -0
- package/components/Spinner/Spinner.js +42 -0
- package/components/Stat/Stat.css +78 -0
- package/components/Stat/Stat.d.ts +19 -0
- package/components/Stat/Stat.js +30 -0
- package/components/Table/Table.css +186 -0
- package/components/Table/Table.d.ts +45 -0
- package/components/Table/Table.js +65 -0
- package/components/Tabs/Tabs.css +140 -0
- package/components/Tabs/Tabs.d.ts +28 -0
- package/components/Tabs/Tabs.js +77 -0
- package/components/Textarea/Textarea.css +152 -0
- package/components/Textarea/Textarea.d.ts +40 -0
- package/components/Textarea/Textarea.js +74 -0
- package/components/Timeline/Timeline.css +339 -0
- package/components/Timeline/Timeline.d.ts +63 -0
- package/components/Timeline/Timeline.js +69 -0
- package/components/Toast/Toast.css +342 -0
- package/components/Toast/Toast.d.ts +63 -0
- package/components/Toast/Toast.js +213 -0
- package/components/ToggleGroup/ToggleGroup.css +84 -0
- package/components/ToggleGroup/ToggleGroup.d.ts +30 -0
- package/components/ToggleGroup/ToggleGroup.js +53 -0
- package/components/ToggleSwitch/ToggleSwitch.css +139 -0
- package/components/ToggleSwitch/ToggleSwitch.d.ts +23 -0
- package/components/ToggleSwitch/ToggleSwitch.js +50 -0
- package/components/Tooltip/Tooltip.css +122 -0
- package/components/Tooltip/Tooltip.d.ts +21 -0
- package/components/Tooltip/Tooltip.js +63 -0
- package/components/TypographySwatch/TypographySwatch.css +81 -0
- package/components/TypographySwatch/TypographySwatch.d.ts +24 -0
- package/components/TypographySwatch/TypographySwatch.js +40 -0
- package/components/registry.d.ts +20 -0
- package/components/registry.js +7 -0
- package/components/registry.json +67 -0
- package/components/registry.json.d.ts +70 -0
- package/components/registry.json.js +8 -0
- package/fonts/MaterialSymbolsRounded-VariableFont_FILL,GRAD,opsz,wght.woff2 +0 -0
- package/fonts/material-symbols.css +94 -0
- package/index.d.ts +62 -0
- package/index.js +123 -0
- package/package.json +63 -0
- package/tokens/registry.d.ts +22 -0
- package/tokens/registry.js +14 -0
- package/tokens/registry.json +203 -0
- package/tokens/registry.json.d.ts +206 -0
- package/tokens/registry.json.js +8 -0
- package/tokens/tokens-dark.css +119 -0
- package/tokens/tokens-light.css +159 -0
- package/tokens/tokens-motion.css +68 -0
- package/tokens/tokens-primitives.css +176 -0
- package/tokens/tokens-typography.css +116 -0
- package/tokens/tokens.css +11 -0
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
2
|
+
import "react";
|
|
3
|
+
import "./Timeline.css";
|
|
4
|
+
import "../../fonts/material-symbols.css";
|
|
5
|
+
const BASE_CLASS = "ds-timeline";
|
|
6
|
+
const renderRoleDates = (role) => {
|
|
7
|
+
if (!role.start) return null;
|
|
8
|
+
return /* @__PURE__ */ jsxs("span", { className: `${BASE_CLASS}__role-dates`, children: [
|
|
9
|
+
role.start,
|
|
10
|
+
" –",
|
|
11
|
+
" ",
|
|
12
|
+
role.present ? /* @__PURE__ */ jsx("span", { className: `${BASE_CLASS}__present`, children: "Present" }) : role.end
|
|
13
|
+
] });
|
|
14
|
+
};
|
|
15
|
+
const CompanyTimeline = ({ items, className = "" }) => {
|
|
16
|
+
const classes = [BASE_CLASS, `${BASE_CLASS}--vertical`, `${BASE_CLASS}--company`, className].filter(Boolean).join(" ");
|
|
17
|
+
return /* @__PURE__ */ jsx("ol", { className: classes, children: items.map((company, index) => /* @__PURE__ */ jsxs("li", { className: `${BASE_CLASS}__item`, children: [
|
|
18
|
+
/* @__PURE__ */ jsx("span", { className: `${BASE_CLASS}__marker ${BASE_CLASS}__marker--logo`, "aria-hidden": "true", children: company.logo }),
|
|
19
|
+
/* @__PURE__ */ jsxs("div", { className: `${BASE_CLASS}__content`, children: [
|
|
20
|
+
/* @__PURE__ */ jsx("span", { className: `${BASE_CLASS}__company-name`, children: company.name }),
|
|
21
|
+
/* @__PURE__ */ jsx("div", { className: `${BASE_CLASS}__roles`, children: company.roles.map((role, roleIndex) => /* @__PURE__ */ jsxs("div", { className: `${BASE_CLASS}__role`, children: [
|
|
22
|
+
/* @__PURE__ */ jsxs("div", { className: `${BASE_CLASS}__role-header`, children: [
|
|
23
|
+
/* @__PURE__ */ jsx("h3", { className: `${BASE_CLASS}__role-title`, children: role.title }),
|
|
24
|
+
renderRoleDates(role)
|
|
25
|
+
] }),
|
|
26
|
+
role.description && /* @__PURE__ */ jsx("p", { className: `${BASE_CLASS}__role-description`, children: role.description }),
|
|
27
|
+
role.bullets && role.bullets.length > 0 && /* @__PURE__ */ jsx("ul", { className: `${BASE_CLASS}__role-bullets`, children: role.bullets.map((bullet, bulletIndex) => /* @__PURE__ */ jsx("li", { children: bullet }, bulletIndex)) })
|
|
28
|
+
] }, `${role.title}-${roleIndex}`)) })
|
|
29
|
+
] })
|
|
30
|
+
] }, `${company.name}-${index}`)) });
|
|
31
|
+
};
|
|
32
|
+
const Timeline = (props) => {
|
|
33
|
+
if (props.variant === "company") {
|
|
34
|
+
return /* @__PURE__ */ jsx(CompanyTimeline, { ...props });
|
|
35
|
+
}
|
|
36
|
+
const { items, orientation = "vertical", numbered = false, className = "" } = props;
|
|
37
|
+
const classes = [
|
|
38
|
+
BASE_CLASS,
|
|
39
|
+
`${BASE_CLASS}--${orientation}`,
|
|
40
|
+
numbered && `${BASE_CLASS}--numbered`,
|
|
41
|
+
className
|
|
42
|
+
].filter(Boolean).join(" ");
|
|
43
|
+
const renderMarker = (item, index) => {
|
|
44
|
+
if (item.icon) {
|
|
45
|
+
return /* @__PURE__ */ jsx("span", { className: `material-symbols-rounded ${BASE_CLASS}__marker-icon`, "aria-hidden": "true", children: item.icon });
|
|
46
|
+
}
|
|
47
|
+
if (numbered) {
|
|
48
|
+
return /* @__PURE__ */ jsx("span", { "aria-hidden": "true", children: index + 1 });
|
|
49
|
+
}
|
|
50
|
+
return null;
|
|
51
|
+
};
|
|
52
|
+
return /* @__PURE__ */ jsx("ol", { className: classes, children: items.map((item, index) => /* @__PURE__ */ jsxs("li", { className: `${BASE_CLASS}__item`, children: [
|
|
53
|
+
/* @__PURE__ */ jsx(
|
|
54
|
+
"span",
|
|
55
|
+
{
|
|
56
|
+
className: `${BASE_CLASS}__marker${item.icon ? ` ${BASE_CLASS}__marker--icon` : numbered ? ` ${BASE_CLASS}__marker--badge` : ""}`,
|
|
57
|
+
children: renderMarker(item, index)
|
|
58
|
+
}
|
|
59
|
+
),
|
|
60
|
+
/* @__PURE__ */ jsxs("div", { className: `${BASE_CLASS}__content`, children: [
|
|
61
|
+
item.meta && /* @__PURE__ */ jsx("span", { className: `${BASE_CLASS}__meta`, children: item.meta }),
|
|
62
|
+
/* @__PURE__ */ jsx("span", { className: `${BASE_CLASS}__title`, children: item.title }),
|
|
63
|
+
item.description && /* @__PURE__ */ jsx("div", { className: `${BASE_CLASS}__description`, children: item.description })
|
|
64
|
+
] })
|
|
65
|
+
] }, `${item.title}-${index}`)) });
|
|
66
|
+
};
|
|
67
|
+
export {
|
|
68
|
+
Timeline
|
|
69
|
+
};
|
|
@@ -0,0 +1,342 @@
|
|
|
1
|
+
/* ============================================
|
|
2
|
+
TOAST CONTAINER
|
|
3
|
+
Fixed position stack for notifications
|
|
4
|
+
============================================ */
|
|
5
|
+
|
|
6
|
+
.ds-toast-container {
|
|
7
|
+
position: fixed;
|
|
8
|
+
z-index: 200;
|
|
9
|
+
display: flex;
|
|
10
|
+
flex-direction: column;
|
|
11
|
+
gap: var(--gap-sm); /* 8px */
|
|
12
|
+
pointer-events: none;
|
|
13
|
+
padding: var(--padding-md); /* 16px */
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
.ds-toast-container--top-right {
|
|
17
|
+
top: 0;
|
|
18
|
+
right: 0;
|
|
19
|
+
align-items: flex-end;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
.ds-toast-container--top-left {
|
|
23
|
+
top: 0;
|
|
24
|
+
left: 0;
|
|
25
|
+
align-items: flex-start;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
.ds-toast-container--bottom-right {
|
|
29
|
+
bottom: 0;
|
|
30
|
+
right: 0;
|
|
31
|
+
align-items: flex-end;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
.ds-toast-container--bottom-left {
|
|
35
|
+
bottom: 0;
|
|
36
|
+
left: 0;
|
|
37
|
+
align-items: flex-start;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
.ds-toast-container--top-center {
|
|
41
|
+
top: 0;
|
|
42
|
+
left: 50%;
|
|
43
|
+
transform: translateX(-50%);
|
|
44
|
+
align-items: center;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
.ds-toast-container--bottom-center {
|
|
48
|
+
bottom: 0;
|
|
49
|
+
left: 50%;
|
|
50
|
+
transform: translateX(-50%);
|
|
51
|
+
align-items: center;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
/* ============================================
|
|
55
|
+
INDIVIDUAL TOAST
|
|
56
|
+
============================================ */
|
|
57
|
+
|
|
58
|
+
.ds-toast {
|
|
59
|
+
display: flex;
|
|
60
|
+
align-items: flex-start;
|
|
61
|
+
gap: var(--gap-sm); /* 8px */
|
|
62
|
+
padding: var(--padding-md); /* 16px */
|
|
63
|
+
border: var(--border-xs) solid transparent;
|
|
64
|
+
border-radius: var(--radius-sm); /* 8px */
|
|
65
|
+
min-width: 300px;
|
|
66
|
+
max-width: 420px;
|
|
67
|
+
box-shadow: var(--shadow-floating);
|
|
68
|
+
pointer-events: auto;
|
|
69
|
+
position: relative;
|
|
70
|
+
overflow: hidden;
|
|
71
|
+
animation: ds-toast-enter var(--motion-duration-slow) var(--motion-ease-standard) forwards;
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
.ds-toast--exiting {
|
|
75
|
+
animation: ds-toast-exit var(--motion-duration-base) var(--motion-ease-standard) forwards;
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
/* ============================================
|
|
79
|
+
ICON
|
|
80
|
+
============================================ */
|
|
81
|
+
|
|
82
|
+
.ds-toast__icon {
|
|
83
|
+
flex-shrink: 0;
|
|
84
|
+
--icon-size: var(--icon-size-md);
|
|
85
|
+
line-height: 1;
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
/* ============================================
|
|
89
|
+
CONTENT
|
|
90
|
+
============================================ */
|
|
91
|
+
|
|
92
|
+
.ds-toast__content {
|
|
93
|
+
flex: 1;
|
|
94
|
+
display: flex;
|
|
95
|
+
flex-direction: column;
|
|
96
|
+
gap: var(--gap-xxs); /* 2px */
|
|
97
|
+
min-width: 0;
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
.ds-toast__title {
|
|
101
|
+
font-family: var(--font-paragraph-em-family);
|
|
102
|
+
font-size: var(--font-paragraph-em-size);
|
|
103
|
+
font-weight: var(--font-paragraph-em-weight);
|
|
104
|
+
line-height: var(--font-paragraph-em-line-height);
|
|
105
|
+
letter-spacing: var(--font-paragraph-em-letter-spacing);
|
|
106
|
+
margin: 0;
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
.ds-toast__description {
|
|
110
|
+
font-family: var(--font-paragraph-family);
|
|
111
|
+
font-size: var(--font-paragraph-size);
|
|
112
|
+
font-weight: var(--font-paragraph-weight);
|
|
113
|
+
line-height: var(--font-paragraph-line-height);
|
|
114
|
+
letter-spacing: var(--font-paragraph-letter-spacing);
|
|
115
|
+
margin: 0;
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
/* ============================================
|
|
119
|
+
DISMISS BUTTON
|
|
120
|
+
============================================ */
|
|
121
|
+
|
|
122
|
+
.ds-toast__dismiss {
|
|
123
|
+
flex-shrink: 0;
|
|
124
|
+
display: flex;
|
|
125
|
+
align-items: center;
|
|
126
|
+
justify-content: center;
|
|
127
|
+
width: 24px;
|
|
128
|
+
height: 24px;
|
|
129
|
+
padding: 0;
|
|
130
|
+
border: none;
|
|
131
|
+
background: none;
|
|
132
|
+
cursor: pointer;
|
|
133
|
+
border-radius: var(--radius-sm); /* 8px */
|
|
134
|
+
transition: background-color var(--motion-duration-base) var(--motion-ease-standard);
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
.ds-toast__dismiss .material-symbols-rounded {
|
|
138
|
+
--icon-size: var(--icon-size-md);
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
.ds-toast__dismiss:hover {
|
|
142
|
+
background-color: var(--color-action-passive-bg-hover);
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
.ds-toast__dismiss:focus-visible {
|
|
146
|
+
outline: 2px solid var(--color-action-primary-bg);
|
|
147
|
+
outline-offset: 2px;
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
/* ============================================
|
|
151
|
+
PROGRESS BAR
|
|
152
|
+
============================================ */
|
|
153
|
+
|
|
154
|
+
.ds-toast__progress {
|
|
155
|
+
position: absolute;
|
|
156
|
+
bottom: 0;
|
|
157
|
+
left: 0;
|
|
158
|
+
height: 3px;
|
|
159
|
+
width: 100%;
|
|
160
|
+
transform-origin: left;
|
|
161
|
+
animation: ds-toast-progress linear forwards;
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
/* ============================================
|
|
165
|
+
VARIANT — INFO
|
|
166
|
+
============================================ */
|
|
167
|
+
|
|
168
|
+
.ds-toast--info {
|
|
169
|
+
background-color: var(--color-status-info-bg);
|
|
170
|
+
border-color: var(--color-status-info-border);
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
.ds-toast--info .ds-toast__icon {
|
|
174
|
+
color: var(--color-status-info-border);
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
.ds-toast--info .ds-toast__title {
|
|
178
|
+
color: var(--color-status-info-text);
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
.ds-toast--info .ds-toast__description {
|
|
182
|
+
color: var(--color-status-info-text);
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
.ds-toast--info .ds-toast__dismiss {
|
|
186
|
+
color: var(--color-status-info-text);
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
.ds-toast--info .ds-toast__progress {
|
|
190
|
+
background-color: var(--color-status-info-border);
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
/* ============================================
|
|
194
|
+
VARIANT — POSITIVE
|
|
195
|
+
============================================ */
|
|
196
|
+
|
|
197
|
+
.ds-toast--positive {
|
|
198
|
+
background-color: var(--color-status-positive-bg);
|
|
199
|
+
border-color: var(--color-status-positive-border);
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
.ds-toast--positive .ds-toast__icon {
|
|
203
|
+
color: var(--color-status-positive-border);
|
|
204
|
+
}
|
|
205
|
+
|
|
206
|
+
.ds-toast--positive .ds-toast__title {
|
|
207
|
+
color: var(--color-status-positive-text);
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
.ds-toast--positive .ds-toast__description {
|
|
211
|
+
color: var(--color-status-positive-text);
|
|
212
|
+
}
|
|
213
|
+
|
|
214
|
+
.ds-toast--positive .ds-toast__dismiss {
|
|
215
|
+
color: var(--color-status-positive-text);
|
|
216
|
+
}
|
|
217
|
+
|
|
218
|
+
.ds-toast--positive .ds-toast__progress {
|
|
219
|
+
background-color: var(--color-status-positive-border);
|
|
220
|
+
}
|
|
221
|
+
|
|
222
|
+
/* ============================================
|
|
223
|
+
VARIANT — WARNING
|
|
224
|
+
============================================ */
|
|
225
|
+
|
|
226
|
+
.ds-toast--warning {
|
|
227
|
+
background-color: var(--color-status-warning-bg);
|
|
228
|
+
border-color: var(--color-status-warning-border);
|
|
229
|
+
}
|
|
230
|
+
|
|
231
|
+
.ds-toast--warning .ds-toast__icon {
|
|
232
|
+
color: var(--color-status-warning-border);
|
|
233
|
+
}
|
|
234
|
+
|
|
235
|
+
.ds-toast--warning .ds-toast__title {
|
|
236
|
+
color: var(--color-status-warning-text);
|
|
237
|
+
}
|
|
238
|
+
|
|
239
|
+
.ds-toast--warning .ds-toast__description {
|
|
240
|
+
color: var(--color-status-warning-text);
|
|
241
|
+
}
|
|
242
|
+
|
|
243
|
+
.ds-toast--warning .ds-toast__dismiss {
|
|
244
|
+
color: var(--color-status-warning-text);
|
|
245
|
+
}
|
|
246
|
+
|
|
247
|
+
.ds-toast--warning .ds-toast__progress {
|
|
248
|
+
background-color: var(--color-status-warning-border);
|
|
249
|
+
}
|
|
250
|
+
|
|
251
|
+
/* ============================================
|
|
252
|
+
VARIANT — ERROR
|
|
253
|
+
============================================ */
|
|
254
|
+
|
|
255
|
+
.ds-toast--error {
|
|
256
|
+
background-color: var(--color-status-error-bg);
|
|
257
|
+
border-color: var(--color-status-error-border);
|
|
258
|
+
}
|
|
259
|
+
|
|
260
|
+
.ds-toast--error .ds-toast__icon {
|
|
261
|
+
color: var(--color-status-error-border);
|
|
262
|
+
}
|
|
263
|
+
|
|
264
|
+
.ds-toast--error .ds-toast__title {
|
|
265
|
+
color: var(--color-status-error-text);
|
|
266
|
+
}
|
|
267
|
+
|
|
268
|
+
.ds-toast--error .ds-toast__description {
|
|
269
|
+
color: var(--color-status-error-text);
|
|
270
|
+
}
|
|
271
|
+
|
|
272
|
+
.ds-toast--error .ds-toast__dismiss {
|
|
273
|
+
color: var(--color-status-error-text);
|
|
274
|
+
}
|
|
275
|
+
|
|
276
|
+
.ds-toast--error .ds-toast__progress {
|
|
277
|
+
background-color: var(--color-status-error-border);
|
|
278
|
+
}
|
|
279
|
+
|
|
280
|
+
/* ============================================
|
|
281
|
+
VARIANT — NEUTRAL
|
|
282
|
+
============================================ */
|
|
283
|
+
|
|
284
|
+
.ds-toast--neutral {
|
|
285
|
+
background-color: var(--color-status-neutral-bg);
|
|
286
|
+
border-color: var(--color-status-neutral-border);
|
|
287
|
+
}
|
|
288
|
+
|
|
289
|
+
.ds-toast--neutral .ds-toast__icon {
|
|
290
|
+
color: var(--color-status-neutral-border);
|
|
291
|
+
}
|
|
292
|
+
|
|
293
|
+
.ds-toast--neutral .ds-toast__title {
|
|
294
|
+
color: var(--color-status-neutral-text);
|
|
295
|
+
}
|
|
296
|
+
|
|
297
|
+
.ds-toast--neutral .ds-toast__description {
|
|
298
|
+
color: var(--color-status-neutral-text);
|
|
299
|
+
}
|
|
300
|
+
|
|
301
|
+
.ds-toast--neutral .ds-toast__dismiss {
|
|
302
|
+
color: var(--color-status-neutral-text);
|
|
303
|
+
}
|
|
304
|
+
|
|
305
|
+
.ds-toast--neutral .ds-toast__progress {
|
|
306
|
+
background-color: var(--color-status-neutral-border);
|
|
307
|
+
}
|
|
308
|
+
|
|
309
|
+
/* ============================================
|
|
310
|
+
ANIMATIONS
|
|
311
|
+
============================================ */
|
|
312
|
+
|
|
313
|
+
@keyframes ds-toast-enter {
|
|
314
|
+
from {
|
|
315
|
+
opacity: 0;
|
|
316
|
+
transform: translateY(8px);
|
|
317
|
+
}
|
|
318
|
+
to {
|
|
319
|
+
opacity: 1;
|
|
320
|
+
transform: translateY(0);
|
|
321
|
+
}
|
|
322
|
+
}
|
|
323
|
+
|
|
324
|
+
@keyframes ds-toast-exit {
|
|
325
|
+
from {
|
|
326
|
+
opacity: 1;
|
|
327
|
+
transform: translateY(0);
|
|
328
|
+
}
|
|
329
|
+
to {
|
|
330
|
+
opacity: 0;
|
|
331
|
+
transform: translateY(8px);
|
|
332
|
+
}
|
|
333
|
+
}
|
|
334
|
+
|
|
335
|
+
@keyframes ds-toast-progress {
|
|
336
|
+
from {
|
|
337
|
+
transform: scaleX(1);
|
|
338
|
+
}
|
|
339
|
+
to {
|
|
340
|
+
transform: scaleX(0);
|
|
341
|
+
}
|
|
342
|
+
}
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import { ReactNode } from 'react';
|
|
2
|
+
export interface ToastData {
|
|
3
|
+
/** Unique ID (auto-generated if not provided) */
|
|
4
|
+
id?: string;
|
|
5
|
+
/** Toast title text */
|
|
6
|
+
title?: string;
|
|
7
|
+
/** Toast description / body text */
|
|
8
|
+
description?: string;
|
|
9
|
+
/** Toast variant determines colour and icon */
|
|
10
|
+
variant?: 'info' | 'positive' | 'warning' | 'error' | 'neutral';
|
|
11
|
+
/** Auto-dismiss duration in ms (0 = no auto-dismiss) */
|
|
12
|
+
duration?: number;
|
|
13
|
+
/** Whether the toast can be manually dismissed */
|
|
14
|
+
dismissible?: boolean;
|
|
15
|
+
/** Custom icon override — Material Symbol name */
|
|
16
|
+
icon?: string;
|
|
17
|
+
}
|
|
18
|
+
export interface ToastProviderProps {
|
|
19
|
+
/** Children that can access the toast context */
|
|
20
|
+
children: ReactNode;
|
|
21
|
+
/** Position of the toast stack */
|
|
22
|
+
position?: 'top-right' | 'top-left' | 'bottom-right' | 'bottom-left' | 'top-center' | 'bottom-center';
|
|
23
|
+
/** Maximum number of visible toasts */
|
|
24
|
+
maxToasts?: number;
|
|
25
|
+
}
|
|
26
|
+
export interface ToastContextValue {
|
|
27
|
+
/** Add a toast */
|
|
28
|
+
toast: (data: ToastData) => string;
|
|
29
|
+
/** Dismiss a specific toast by ID */
|
|
30
|
+
dismiss: (id: string) => void;
|
|
31
|
+
/** Dismiss all toasts */
|
|
32
|
+
dismissAll: () => void;
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* Hook to access the toast API.
|
|
36
|
+
* Must be used within a ToastProvider.
|
|
37
|
+
*/
|
|
38
|
+
export declare const useToast: () => ToastContextValue;
|
|
39
|
+
/**
|
|
40
|
+
* ToastProvider wraps your application and provides the
|
|
41
|
+
* toast context. Renders a fixed container that stacks
|
|
42
|
+
* toast notifications.
|
|
43
|
+
*/
|
|
44
|
+
export declare const ToastProvider: ({ children, position, maxToasts, }: ToastProviderProps) => import("react").JSX.Element;
|
|
45
|
+
export interface ToastProps {
|
|
46
|
+
/** Toast title text */
|
|
47
|
+
title?: string;
|
|
48
|
+
/** Toast description / body text */
|
|
49
|
+
description?: string;
|
|
50
|
+
/** Toast variant */
|
|
51
|
+
variant?: 'info' | 'positive' | 'warning' | 'error' | 'neutral';
|
|
52
|
+
/** Whether the toast can be manually dismissed */
|
|
53
|
+
dismissible?: boolean;
|
|
54
|
+
/** Custom icon override — Material Symbol name */
|
|
55
|
+
icon?: string;
|
|
56
|
+
/** Additional CSS classes */
|
|
57
|
+
className?: string;
|
|
58
|
+
}
|
|
59
|
+
/**
|
|
60
|
+
* Standalone Toast component for static display.
|
|
61
|
+
* For dynamic toast notifications, use ToastProvider + useToast.
|
|
62
|
+
*/
|
|
63
|
+
export declare const Toast: ({ title, description, variant, dismissible, icon, className, }: ToastProps) => import("react").JSX.Element;
|
|
@@ -0,0 +1,213 @@
|
|
|
1
|
+
import { jsxs, jsx } from "react/jsx-runtime";
|
|
2
|
+
import { useState, useSyncExternalStore, useCallback, useContext, createContext, useRef, useEffect } from "react";
|
|
3
|
+
import ReactDOM from "react-dom";
|
|
4
|
+
import "./Toast.css";
|
|
5
|
+
import "../../fonts/material-symbols.css";
|
|
6
|
+
const emptySubscribe = () => () => {
|
|
7
|
+
};
|
|
8
|
+
const ToastContext = createContext(null);
|
|
9
|
+
const useToast = () => {
|
|
10
|
+
const context = useContext(ToastContext);
|
|
11
|
+
if (!context) {
|
|
12
|
+
throw new Error("useToast must be used within a ToastProvider");
|
|
13
|
+
}
|
|
14
|
+
return context;
|
|
15
|
+
};
|
|
16
|
+
const defaultIcons = {
|
|
17
|
+
info: "info",
|
|
18
|
+
positive: "check_circle",
|
|
19
|
+
warning: "warning",
|
|
20
|
+
error: "error",
|
|
21
|
+
neutral: "info"
|
|
22
|
+
};
|
|
23
|
+
let toastCounter = 0;
|
|
24
|
+
const ToastItem = ({
|
|
25
|
+
id,
|
|
26
|
+
title,
|
|
27
|
+
description,
|
|
28
|
+
variant,
|
|
29
|
+
dismissible,
|
|
30
|
+
icon,
|
|
31
|
+
duration,
|
|
32
|
+
onDismiss
|
|
33
|
+
}) => {
|
|
34
|
+
const [exiting, setExiting] = useState(false);
|
|
35
|
+
const [pauseTimer, setPauseTimer] = useState(false);
|
|
36
|
+
const timerRef = useRef(void 0);
|
|
37
|
+
const remainingRef = useRef(duration);
|
|
38
|
+
const startTimeRef = useRef(0);
|
|
39
|
+
const baseClass = "ds-toast";
|
|
40
|
+
const handleDismiss = useCallback(() => {
|
|
41
|
+
setExiting(true);
|
|
42
|
+
setTimeout(() => onDismiss(id), 200);
|
|
43
|
+
}, [id, onDismiss]);
|
|
44
|
+
useEffect(() => {
|
|
45
|
+
if (duration <= 0 || pauseTimer) return;
|
|
46
|
+
startTimeRef.current = Date.now();
|
|
47
|
+
timerRef.current = setTimeout(handleDismiss, remainingRef.current);
|
|
48
|
+
return () => {
|
|
49
|
+
clearTimeout(timerRef.current);
|
|
50
|
+
remainingRef.current -= Date.now() - startTimeRef.current;
|
|
51
|
+
if (remainingRef.current < 0) remainingRef.current = 0;
|
|
52
|
+
};
|
|
53
|
+
}, [duration, pauseTimer, handleDismiss]);
|
|
54
|
+
const iconName = icon || defaultIcons[variant];
|
|
55
|
+
const classes = [
|
|
56
|
+
baseClass,
|
|
57
|
+
`${baseClass}--${variant}`,
|
|
58
|
+
exiting ? `${baseClass}--exiting` : ""
|
|
59
|
+
].filter(Boolean).join(" ");
|
|
60
|
+
return /* @__PURE__ */ jsxs(
|
|
61
|
+
"div",
|
|
62
|
+
{
|
|
63
|
+
className: classes,
|
|
64
|
+
role: "status",
|
|
65
|
+
"aria-live": variant === "error" || variant === "warning" ? "assertive" : "polite",
|
|
66
|
+
onMouseEnter: () => setPauseTimer(true),
|
|
67
|
+
onMouseLeave: () => setPauseTimer(false),
|
|
68
|
+
onFocus: () => setPauseTimer(true),
|
|
69
|
+
onBlur: () => setPauseTimer(false),
|
|
70
|
+
children: [
|
|
71
|
+
/* @__PURE__ */ jsx(
|
|
72
|
+
"span",
|
|
73
|
+
{
|
|
74
|
+
className: `${baseClass}__icon material-symbols-rounded`,
|
|
75
|
+
"aria-hidden": "true",
|
|
76
|
+
children: iconName
|
|
77
|
+
}
|
|
78
|
+
),
|
|
79
|
+
/* @__PURE__ */ jsxs("div", { className: `${baseClass}__content`, children: [
|
|
80
|
+
title && /* @__PURE__ */ jsx("p", { className: `${baseClass}__title`, children: title }),
|
|
81
|
+
description && /* @__PURE__ */ jsx("p", { className: `${baseClass}__description`, children: description })
|
|
82
|
+
] }),
|
|
83
|
+
dismissible && /* @__PURE__ */ jsx(
|
|
84
|
+
"button",
|
|
85
|
+
{
|
|
86
|
+
type: "button",
|
|
87
|
+
className: `${baseClass}__dismiss`,
|
|
88
|
+
onClick: handleDismiss,
|
|
89
|
+
"aria-label": "Dismiss notification",
|
|
90
|
+
children: /* @__PURE__ */ jsx("span", { className: "material-symbols-rounded", "aria-hidden": "true", children: "close" })
|
|
91
|
+
}
|
|
92
|
+
),
|
|
93
|
+
duration > 0 && /* @__PURE__ */ jsx(
|
|
94
|
+
"div",
|
|
95
|
+
{
|
|
96
|
+
className: `${baseClass}__progress`,
|
|
97
|
+
style: {
|
|
98
|
+
animationDuration: `${duration}ms`,
|
|
99
|
+
animationPlayState: pauseTimer ? "paused" : "running"
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
)
|
|
103
|
+
]
|
|
104
|
+
}
|
|
105
|
+
);
|
|
106
|
+
};
|
|
107
|
+
const ToastProvider = ({
|
|
108
|
+
children,
|
|
109
|
+
position = "bottom-right",
|
|
110
|
+
maxToasts = 5
|
|
111
|
+
}) => {
|
|
112
|
+
const [toasts, setToasts] = useState([]);
|
|
113
|
+
const mounted = useSyncExternalStore(emptySubscribe, () => true, () => false);
|
|
114
|
+
const toast = useCallback(
|
|
115
|
+
(data) => {
|
|
116
|
+
const id = data.id || `toast-${++toastCounter}`;
|
|
117
|
+
const newToast = {
|
|
118
|
+
...data,
|
|
119
|
+
id,
|
|
120
|
+
variant: data.variant || "info",
|
|
121
|
+
duration: data.duration ?? 5e3,
|
|
122
|
+
dismissible: data.dismissible ?? true
|
|
123
|
+
};
|
|
124
|
+
setToasts((prev) => {
|
|
125
|
+
const next = [...prev, newToast];
|
|
126
|
+
if (next.length > maxToasts) {
|
|
127
|
+
return next.slice(next.length - maxToasts);
|
|
128
|
+
}
|
|
129
|
+
return next;
|
|
130
|
+
});
|
|
131
|
+
return id;
|
|
132
|
+
},
|
|
133
|
+
[maxToasts]
|
|
134
|
+
);
|
|
135
|
+
const dismiss = useCallback((id) => {
|
|
136
|
+
setToasts((prev) => prev.filter((t) => t.id !== id));
|
|
137
|
+
}, []);
|
|
138
|
+
const dismissAll = useCallback(() => {
|
|
139
|
+
setToasts([]);
|
|
140
|
+
}, []);
|
|
141
|
+
const baseClass = "ds-toast-container";
|
|
142
|
+
const containerClasses = [baseClass, `${baseClass}--${position}`].join(" ");
|
|
143
|
+
return /* @__PURE__ */ jsxs(ToastContext.Provider, { value: { toast, dismiss, dismissAll }, children: [
|
|
144
|
+
children,
|
|
145
|
+
mounted && ReactDOM.createPortal(
|
|
146
|
+
/* @__PURE__ */ jsx(
|
|
147
|
+
"div",
|
|
148
|
+
{
|
|
149
|
+
className: containerClasses,
|
|
150
|
+
role: "region",
|
|
151
|
+
"aria-label": "Notifications",
|
|
152
|
+
children: toasts.map((t) => /* @__PURE__ */ jsx(
|
|
153
|
+
ToastItem,
|
|
154
|
+
{
|
|
155
|
+
id: t.id,
|
|
156
|
+
title: t.title,
|
|
157
|
+
description: t.description,
|
|
158
|
+
variant: t.variant || "info",
|
|
159
|
+
dismissible: t.dismissible ?? true,
|
|
160
|
+
icon: t.icon,
|
|
161
|
+
duration: t.duration ?? 5e3,
|
|
162
|
+
onDismiss: dismiss
|
|
163
|
+
},
|
|
164
|
+
t.id
|
|
165
|
+
))
|
|
166
|
+
}
|
|
167
|
+
),
|
|
168
|
+
document.body
|
|
169
|
+
)
|
|
170
|
+
] });
|
|
171
|
+
};
|
|
172
|
+
const Toast = ({
|
|
173
|
+
title,
|
|
174
|
+
description,
|
|
175
|
+
variant = "info",
|
|
176
|
+
dismissible = true,
|
|
177
|
+
icon,
|
|
178
|
+
className = ""
|
|
179
|
+
}) => {
|
|
180
|
+
const baseClass = "ds-toast";
|
|
181
|
+
const iconName = icon || defaultIcons[variant];
|
|
182
|
+
const classes = [baseClass, `${baseClass}--${variant}`, className].filter(Boolean).join(" ");
|
|
183
|
+
return /* @__PURE__ */ jsxs("div", { className: classes, role: "status", children: [
|
|
184
|
+
/* @__PURE__ */ jsx(
|
|
185
|
+
"span",
|
|
186
|
+
{
|
|
187
|
+
className: `${baseClass}__icon material-symbols-rounded`,
|
|
188
|
+
"aria-hidden": "true",
|
|
189
|
+
children: iconName
|
|
190
|
+
}
|
|
191
|
+
),
|
|
192
|
+
/* @__PURE__ */ jsxs("div", { className: `${baseClass}__content`, children: [
|
|
193
|
+
title && /* @__PURE__ */ jsx("p", { className: `${baseClass}__title`, children: title }),
|
|
194
|
+
description && /* @__PURE__ */ jsx("p", { className: `${baseClass}__description`, children: description })
|
|
195
|
+
] }),
|
|
196
|
+
dismissible && /* @__PURE__ */ jsx(
|
|
197
|
+
"button",
|
|
198
|
+
{
|
|
199
|
+
type: "button",
|
|
200
|
+
className: `${baseClass}__dismiss`,
|
|
201
|
+
onClick: () => {
|
|
202
|
+
},
|
|
203
|
+
"aria-label": "Dismiss notification",
|
|
204
|
+
children: /* @__PURE__ */ jsx("span", { className: "material-symbols-rounded", "aria-hidden": "true", children: "close" })
|
|
205
|
+
}
|
|
206
|
+
)
|
|
207
|
+
] });
|
|
208
|
+
};
|
|
209
|
+
export {
|
|
210
|
+
Toast,
|
|
211
|
+
ToastProvider,
|
|
212
|
+
useToast
|
|
213
|
+
};
|