@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,262 @@
|
|
|
1
|
+
/* ============================================
|
|
2
|
+
DRAWER COMPONENT
|
|
3
|
+
Edge-anchored modal panel that slides in
|
|
4
|
+
============================================ */
|
|
5
|
+
|
|
6
|
+
.ds-drawer {
|
|
7
|
+
position: fixed;
|
|
8
|
+
inset: 0;
|
|
9
|
+
z-index: 100;
|
|
10
|
+
display: flex;
|
|
11
|
+
visibility: hidden; /* keeps panel controls out of the tab order when closed */
|
|
12
|
+
pointer-events: none;
|
|
13
|
+
transition: visibility var(--motion-duration-slow) var(--motion-ease-standard);
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
.ds-drawer--open {
|
|
17
|
+
visibility: visible;
|
|
18
|
+
pointer-events: auto;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
/* Anchor the panel to the requested edge */
|
|
22
|
+
.ds-drawer--left {
|
|
23
|
+
justify-content: flex-start;
|
|
24
|
+
align-items: stretch;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
.ds-drawer--right {
|
|
28
|
+
justify-content: flex-end;
|
|
29
|
+
align-items: stretch;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
.ds-drawer--top {
|
|
33
|
+
align-items: flex-start;
|
|
34
|
+
justify-content: stretch;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
.ds-drawer--bottom {
|
|
38
|
+
align-items: flex-end;
|
|
39
|
+
justify-content: stretch;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
/* ============================================
|
|
43
|
+
SCRIM
|
|
44
|
+
============================================ */
|
|
45
|
+
|
|
46
|
+
.ds-drawer__scrim {
|
|
47
|
+
position: absolute;
|
|
48
|
+
inset: 0;
|
|
49
|
+
background-color: var(--color-scrim);
|
|
50
|
+
opacity: 0;
|
|
51
|
+
transition: opacity var(--motion-duration-slow) var(--motion-ease-standard);
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
.ds-drawer--open .ds-drawer__scrim {
|
|
55
|
+
opacity: 1;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
/* ============================================
|
|
59
|
+
PANEL
|
|
60
|
+
============================================ */
|
|
61
|
+
|
|
62
|
+
.ds-drawer__panel {
|
|
63
|
+
position: relative;
|
|
64
|
+
z-index: 1;
|
|
65
|
+
display: flex;
|
|
66
|
+
flex-direction: column;
|
|
67
|
+
gap: var(--gap-md); /* 16px */
|
|
68
|
+
padding: var(--padding-lg); /* 20px */
|
|
69
|
+
background-color: var(--color-bg-page-primary);
|
|
70
|
+
box-shadow: var(--shadow-modal);
|
|
71
|
+
transition: transform var(--motion-duration-slow) var(--motion-ease-standard);
|
|
72
|
+
outline: none;
|
|
73
|
+
overflow: hidden;
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
/* Edge-specific border + resting (off-screen) transform */
|
|
77
|
+
.ds-drawer--left .ds-drawer__panel {
|
|
78
|
+
height: 100%;
|
|
79
|
+
border-right: var(--border-xs) solid var(--color-bg-container-border);
|
|
80
|
+
transform: translateX(-100%);
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
.ds-drawer--right .ds-drawer__panel {
|
|
84
|
+
height: 100%;
|
|
85
|
+
border-left: var(--border-xs) solid var(--color-bg-container-border);
|
|
86
|
+
transform: translateX(100%);
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
.ds-drawer--top .ds-drawer__panel {
|
|
90
|
+
width: 100%;
|
|
91
|
+
border-bottom: var(--border-xs) solid var(--color-bg-container-border);
|
|
92
|
+
transform: translateY(-100%);
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
.ds-drawer--bottom .ds-drawer__panel {
|
|
96
|
+
width: 100%;
|
|
97
|
+
border-top: var(--border-xs) solid var(--color-bg-container-border);
|
|
98
|
+
transform: translateY(100%);
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
.ds-drawer--open .ds-drawer__panel {
|
|
102
|
+
transform: translate(0, 0);
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
/* ============================================
|
|
106
|
+
SIZES — measured along the slide axis
|
|
107
|
+
============================================ */
|
|
108
|
+
|
|
109
|
+
.ds-drawer--left.ds-drawer--sm .ds-drawer__panel,
|
|
110
|
+
.ds-drawer--right.ds-drawer--sm .ds-drawer__panel {
|
|
111
|
+
width: 320px;
|
|
112
|
+
max-width: 100vw;
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
.ds-drawer--left.ds-drawer--md .ds-drawer__panel,
|
|
116
|
+
.ds-drawer--right.ds-drawer--md .ds-drawer__panel {
|
|
117
|
+
width: 420px;
|
|
118
|
+
max-width: 100vw;
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
.ds-drawer--left.ds-drawer--lg .ds-drawer__panel,
|
|
122
|
+
.ds-drawer--right.ds-drawer--lg .ds-drawer__panel {
|
|
123
|
+
width: 560px;
|
|
124
|
+
max-width: 100vw;
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
.ds-drawer--top.ds-drawer--sm .ds-drawer__panel,
|
|
128
|
+
.ds-drawer--bottom.ds-drawer--sm .ds-drawer__panel {
|
|
129
|
+
max-height: 30vh;
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
.ds-drawer--top.ds-drawer--md .ds-drawer__panel,
|
|
133
|
+
.ds-drawer--bottom.ds-drawer--md .ds-drawer__panel {
|
|
134
|
+
max-height: 50vh;
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
.ds-drawer--top.ds-drawer--lg .ds-drawer__panel,
|
|
138
|
+
.ds-drawer--bottom.ds-drawer--lg .ds-drawer__panel {
|
|
139
|
+
max-height: 75vh;
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
/* ============================================
|
|
143
|
+
HEADER
|
|
144
|
+
============================================ */
|
|
145
|
+
|
|
146
|
+
.ds-drawer__header {
|
|
147
|
+
display: flex;
|
|
148
|
+
align-items: flex-start;
|
|
149
|
+
justify-content: space-between;
|
|
150
|
+
gap: var(--gap-md); /* 16px */
|
|
151
|
+
flex-shrink: 0;
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
.ds-drawer__heading {
|
|
155
|
+
display: flex;
|
|
156
|
+
flex-direction: column;
|
|
157
|
+
gap: var(--gap-xs); /* 4px */
|
|
158
|
+
min-width: 0;
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
.ds-drawer__title {
|
|
162
|
+
font-family: var(--font-heading-3-family);
|
|
163
|
+
font-size: var(--font-heading-3-size);
|
|
164
|
+
font-weight: var(--font-heading-3-weight);
|
|
165
|
+
line-height: var(--font-heading-3-line-height);
|
|
166
|
+
letter-spacing: var(--font-heading-3-letter-spacing);
|
|
167
|
+
color: var(--color-text-primary);
|
|
168
|
+
margin: 0;
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
.ds-drawer__description {
|
|
172
|
+
font-family: var(--font-paragraph-sm-family);
|
|
173
|
+
font-size: var(--font-paragraph-sm-size);
|
|
174
|
+
font-weight: var(--font-paragraph-sm-weight);
|
|
175
|
+
line-height: var(--font-paragraph-sm-line-height);
|
|
176
|
+
letter-spacing: var(--font-paragraph-sm-letter-spacing);
|
|
177
|
+
color: var(--color-text-tertiary);
|
|
178
|
+
margin: 0;
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
/* Close button — ghost icon button */
|
|
182
|
+
.ds-drawer__close {
|
|
183
|
+
flex-shrink: 0;
|
|
184
|
+
display: inline-flex;
|
|
185
|
+
align-items: center;
|
|
186
|
+
justify-content: center;
|
|
187
|
+
width: 32px;
|
|
188
|
+
height: 32px;
|
|
189
|
+
padding: 0;
|
|
190
|
+
border: none;
|
|
191
|
+
border-radius: var(--radius-full); /* pill */
|
|
192
|
+
background-color: transparent;
|
|
193
|
+
cursor: pointer;
|
|
194
|
+
transition: background-color var(--motion-duration-base) var(--motion-ease-standard);
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
.ds-drawer__close:hover {
|
|
198
|
+
background-color: var(--color-action-passive-bg-hover);
|
|
199
|
+
}
|
|
200
|
+
|
|
201
|
+
.ds-drawer__close:focus-visible {
|
|
202
|
+
outline: 2px solid var(--color-action-primary-bg);
|
|
203
|
+
outline-offset: 2px;
|
|
204
|
+
}
|
|
205
|
+
|
|
206
|
+
.ds-drawer__close-icon {
|
|
207
|
+
--icon-size: var(--icon-size-sm);
|
|
208
|
+
line-height: 1;
|
|
209
|
+
color: var(--color-icon-primary);
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
/* ============================================
|
|
213
|
+
BODY
|
|
214
|
+
============================================ */
|
|
215
|
+
|
|
216
|
+
.ds-drawer__body {
|
|
217
|
+
flex: 1;
|
|
218
|
+
overflow-y: auto;
|
|
219
|
+
min-height: 0;
|
|
220
|
+
font-family: var(--font-paragraph-family);
|
|
221
|
+
font-size: var(--font-paragraph-size);
|
|
222
|
+
font-weight: var(--font-paragraph-weight);
|
|
223
|
+
line-height: var(--font-paragraph-line-height);
|
|
224
|
+
letter-spacing: var(--font-paragraph-letter-spacing);
|
|
225
|
+
color: var(--color-text-secondary);
|
|
226
|
+
}
|
|
227
|
+
|
|
228
|
+
/* ============================================
|
|
229
|
+
FOOTER
|
|
230
|
+
============================================ */
|
|
231
|
+
|
|
232
|
+
.ds-drawer__footer {
|
|
233
|
+
display: flex;
|
|
234
|
+
justify-content: flex-end;
|
|
235
|
+
gap: var(--gap-sm); /* 8px */
|
|
236
|
+
padding-top: var(--padding-xs); /* 6px */
|
|
237
|
+
flex-shrink: 0;
|
|
238
|
+
}
|
|
239
|
+
|
|
240
|
+
/* ============================================
|
|
241
|
+
RESPONSIVE
|
|
242
|
+
Side drawers go full-width on narrow screens
|
|
243
|
+
============================================ */
|
|
244
|
+
|
|
245
|
+
@media (max-width: 480px) {
|
|
246
|
+
.ds-drawer--left .ds-drawer__panel,
|
|
247
|
+
.ds-drawer--right .ds-drawer__panel {
|
|
248
|
+
width: 100vw;
|
|
249
|
+
}
|
|
250
|
+
}
|
|
251
|
+
|
|
252
|
+
/* ============================================
|
|
253
|
+
REDUCED MOTION
|
|
254
|
+
============================================ */
|
|
255
|
+
|
|
256
|
+
@media (prefers-reduced-motion: reduce) {
|
|
257
|
+
.ds-drawer,
|
|
258
|
+
.ds-drawer__panel,
|
|
259
|
+
.ds-drawer__scrim {
|
|
260
|
+
transition: none;
|
|
261
|
+
}
|
|
262
|
+
}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { default as React } from 'react';
|
|
2
|
+
export interface DrawerProps {
|
|
3
|
+
/** Whether the drawer is open */
|
|
4
|
+
open: boolean;
|
|
5
|
+
/** Callback when the drawer requests to close */
|
|
6
|
+
onOpenChange: (open: boolean) => void;
|
|
7
|
+
/** Drawer title */
|
|
8
|
+
title: string;
|
|
9
|
+
/** Optional subtitle under the title */
|
|
10
|
+
description?: string;
|
|
11
|
+
/** Drawer body content */
|
|
12
|
+
children?: React.ReactNode;
|
|
13
|
+
/** Optional footer slot — typically a row of Buttons */
|
|
14
|
+
footer?: React.ReactNode;
|
|
15
|
+
/** Edge the panel slides in from */
|
|
16
|
+
side?: 'left' | 'right' | 'top' | 'bottom';
|
|
17
|
+
/** Panel size along the axis it slides on */
|
|
18
|
+
size?: 'sm' | 'md' | 'lg';
|
|
19
|
+
/** Whether ESC, scrim click, and the close button can dismiss */
|
|
20
|
+
dismissible?: boolean;
|
|
21
|
+
/** Additional CSS classes */
|
|
22
|
+
className?: string;
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* Drawer component — an edge-anchored panel that slides in over the page.
|
|
26
|
+
* Shares Dialog's modal semantics (focus trap, focus restore, scroll lock,
|
|
27
|
+
* ESC/scrim dismissal) but is anchored to a viewport edge, which suits
|
|
28
|
+
* filter panels, detail views, and mobile navigation.
|
|
29
|
+
*/
|
|
30
|
+
export declare const Drawer: ({ open, onOpenChange, title, description, children, footer, side, size, dismissible, className, }: DrawerProps) => React.ReactPortal | null;
|
|
@@ -0,0 +1,134 @@
|
|
|
1
|
+
import { jsxs, jsx } from "react/jsx-runtime";
|
|
2
|
+
import { useRef, useId, useSyncExternalStore, useEffect } from "react";
|
|
3
|
+
import ReactDOM from "react-dom";
|
|
4
|
+
import "./Drawer.css";
|
|
5
|
+
import "../../fonts/material-symbols.css";
|
|
6
|
+
const emptySubscribe = () => () => {
|
|
7
|
+
};
|
|
8
|
+
const FOCUSABLE = 'button:not([disabled]), [href], input:not([disabled]), select:not([disabled]), textarea:not([disabled]), [tabindex]:not([tabindex="-1"])';
|
|
9
|
+
const Drawer = ({
|
|
10
|
+
open,
|
|
11
|
+
onOpenChange,
|
|
12
|
+
title,
|
|
13
|
+
description,
|
|
14
|
+
children,
|
|
15
|
+
footer,
|
|
16
|
+
side = "right",
|
|
17
|
+
size = "md",
|
|
18
|
+
dismissible = true,
|
|
19
|
+
className = ""
|
|
20
|
+
}) => {
|
|
21
|
+
const panelRef = useRef(null);
|
|
22
|
+
const previousFocusRef = useRef(null);
|
|
23
|
+
const titleId = useId();
|
|
24
|
+
const descId = useId();
|
|
25
|
+
const baseClass = "ds-drawer";
|
|
26
|
+
const mounted = useSyncExternalStore(emptySubscribe, () => true, () => false);
|
|
27
|
+
useEffect(() => {
|
|
28
|
+
if (open) {
|
|
29
|
+
previousFocusRef.current = document.activeElement;
|
|
30
|
+
}
|
|
31
|
+
}, [open]);
|
|
32
|
+
useEffect(() => {
|
|
33
|
+
if (!open) return;
|
|
34
|
+
const panel = panelRef.current;
|
|
35
|
+
if (panel) {
|
|
36
|
+
const first = panel.querySelector(FOCUSABLE);
|
|
37
|
+
(first ?? panel).focus();
|
|
38
|
+
}
|
|
39
|
+
const handleKeyDown = (e) => {
|
|
40
|
+
if (e.key === "Escape" && dismissible) {
|
|
41
|
+
onOpenChange(false);
|
|
42
|
+
return;
|
|
43
|
+
}
|
|
44
|
+
if (e.key === "Tab" && panel) {
|
|
45
|
+
const focusable = panel.querySelectorAll(FOCUSABLE);
|
|
46
|
+
if (focusable.length === 0) return;
|
|
47
|
+
const first = focusable[0];
|
|
48
|
+
const last = focusable[focusable.length - 1];
|
|
49
|
+
if (e.shiftKey && document.activeElement === first) {
|
|
50
|
+
e.preventDefault();
|
|
51
|
+
last.focus();
|
|
52
|
+
} else if (!e.shiftKey && document.activeElement === last) {
|
|
53
|
+
e.preventDefault();
|
|
54
|
+
first.focus();
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
};
|
|
58
|
+
document.addEventListener("keydown", handleKeyDown);
|
|
59
|
+
return () => document.removeEventListener("keydown", handleKeyDown);
|
|
60
|
+
}, [open, dismissible, onOpenChange]);
|
|
61
|
+
useEffect(() => {
|
|
62
|
+
if (!open && previousFocusRef.current) {
|
|
63
|
+
previousFocusRef.current.focus();
|
|
64
|
+
previousFocusRef.current = null;
|
|
65
|
+
}
|
|
66
|
+
}, [open]);
|
|
67
|
+
useEffect(() => {
|
|
68
|
+
if (open) {
|
|
69
|
+
document.body.style.overflow = "hidden";
|
|
70
|
+
} else {
|
|
71
|
+
document.body.style.overflow = "";
|
|
72
|
+
}
|
|
73
|
+
return () => {
|
|
74
|
+
document.body.style.overflow = "";
|
|
75
|
+
};
|
|
76
|
+
}, [open]);
|
|
77
|
+
const handleScrimClick = () => {
|
|
78
|
+
if (dismissible) onOpenChange(false);
|
|
79
|
+
};
|
|
80
|
+
const classes = [
|
|
81
|
+
baseClass,
|
|
82
|
+
`${baseClass}--${side}`,
|
|
83
|
+
`${baseClass}--${size}`,
|
|
84
|
+
open ? `${baseClass}--open` : "",
|
|
85
|
+
className
|
|
86
|
+
].filter(Boolean).join(" ");
|
|
87
|
+
const drawer = /* @__PURE__ */ jsxs("div", { className: classes, children: [
|
|
88
|
+
/* @__PURE__ */ jsx("div", { className: `${baseClass}__scrim`, onClick: handleScrimClick }),
|
|
89
|
+
/* @__PURE__ */ jsxs(
|
|
90
|
+
"div",
|
|
91
|
+
{
|
|
92
|
+
className: `${baseClass}__panel`,
|
|
93
|
+
ref: panelRef,
|
|
94
|
+
role: "dialog",
|
|
95
|
+
"aria-modal": "true",
|
|
96
|
+
"aria-labelledby": titleId,
|
|
97
|
+
"aria-describedby": description ? descId : void 0,
|
|
98
|
+
tabIndex: -1,
|
|
99
|
+
children: [
|
|
100
|
+
/* @__PURE__ */ jsxs("div", { className: `${baseClass}__header`, children: [
|
|
101
|
+
/* @__PURE__ */ jsxs("div", { className: `${baseClass}__heading`, children: [
|
|
102
|
+
/* @__PURE__ */ jsx("h2", { className: `${baseClass}__title`, id: titleId, children: title }),
|
|
103
|
+
description && /* @__PURE__ */ jsx("p", { className: `${baseClass}__description`, id: descId, children: description })
|
|
104
|
+
] }),
|
|
105
|
+
dismissible && /* @__PURE__ */ jsx(
|
|
106
|
+
"button",
|
|
107
|
+
{
|
|
108
|
+
type: "button",
|
|
109
|
+
className: `${baseClass}__close`,
|
|
110
|
+
onClick: () => onOpenChange(false),
|
|
111
|
+
"aria-label": "Close drawer",
|
|
112
|
+
children: /* @__PURE__ */ jsx(
|
|
113
|
+
"span",
|
|
114
|
+
{
|
|
115
|
+
className: `${baseClass}__close-icon material-symbols-rounded`,
|
|
116
|
+
"aria-hidden": "true",
|
|
117
|
+
children: "close"
|
|
118
|
+
}
|
|
119
|
+
)
|
|
120
|
+
}
|
|
121
|
+
)
|
|
122
|
+
] }),
|
|
123
|
+
children && /* @__PURE__ */ jsx("div", { className: `${baseClass}__body`, children }),
|
|
124
|
+
footer && /* @__PURE__ */ jsx("div", { className: `${baseClass}__footer`, children: footer })
|
|
125
|
+
]
|
|
126
|
+
}
|
|
127
|
+
)
|
|
128
|
+
] });
|
|
129
|
+
if (!mounted) return null;
|
|
130
|
+
return ReactDOM.createPortal(drawer, document.body);
|
|
131
|
+
};
|
|
132
|
+
export {
|
|
133
|
+
Drawer
|
|
134
|
+
};
|