@czi-sds/mcp 0.15.0 → 0.17.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/README.md +2 -1
- package/data/component-docs/Accordion.md +291 -0
- package/data/component-docs/Autocomplete.md +525 -0
- package/data/component-docs/Banner.md +231 -0
- package/data/component-docs/Button.md +224 -0
- package/data/component-docs/ButtonDropdown.md +256 -0
- package/data/component-docs/ButtonGroup.md +320 -0
- package/data/component-docs/ButtonToggle.md +397 -0
- package/data/component-docs/Callout.md +268 -0
- package/data/component-docs/CellBasic.md +122 -0
- package/data/component-docs/CellComponent.md +63 -0
- package/data/component-docs/CellHeader.md +128 -0
- package/data/component-docs/ComplexFilter.md +294 -0
- package/data/component-docs/ContentCard.md +406 -0
- package/data/component-docs/Dialog.md +651 -0
- package/data/component-docs/Dropdown.md +155 -0
- package/data/component-docs/DropdownMenu.md +949 -0
- package/data/component-docs/HeatmapChart.md +782 -0
- package/data/component-docs/Hero.md +363 -0
- package/data/component-docs/Icon.md +283 -0
- package/data/component-docs/InputCheckbox.md +205 -0
- package/data/component-docs/InputDropdown.md +482 -0
- package/data/component-docs/InputRadio.md +173 -0
- package/data/component-docs/InputSearch.md +81 -0
- package/data/component-docs/InputSlider.md +189 -0
- package/data/component-docs/InputText.md +110 -0
- package/data/component-docs/InputToggle.md +141 -0
- package/data/component-docs/IntentMessage.md +293 -0
- package/data/component-docs/Legend.md +442 -0
- package/data/component-docs/Link.md +23 -0
- package/data/component-docs/List.md +300 -0
- package/data/component-docs/LoadingIndicator.md +198 -0
- package/data/component-docs/Menu.md +298 -0
- package/data/component-docs/MenuItem.md +100 -0
- package/data/component-docs/NavigationFooter.md +165 -0
- package/data/component-docs/NavigationHeader.md +500 -0
- package/data/component-docs/NavigationJumpTo.md +414 -0
- package/data/component-docs/Notification.md +288 -0
- package/data/component-docs/Pagination.md +67 -0
- package/data/component-docs/Panel.md +636 -0
- package/data/component-docs/Popover.md +448 -0
- package/data/component-docs/PreComposedTable.md +2947 -0
- package/data/component-docs/SegmentedControl.md +396 -0
- package/data/component-docs/StackedBarChart.md +475 -0
- package/data/component-docs/Table.md +2000 -0
- package/data/component-docs/TableHeader.md +53 -0
- package/data/component-docs/TableRow.md +74 -0
- package/data/component-docs/Tabs.md +455 -0
- package/data/component-docs/Tag.md +647 -0
- package/data/component-docs/TagFilter.md +131 -0
- package/data/component-docs/Tooltip.md +561 -0
- package/data/component-docs/TooltipCondensed.md +203 -0
- package/data/component-docs/TooltipTable.md +145 -0
- package/data/component-docs/index.json +262 -0
- package/data/component-list.json +2 -5
- package/data/component-props/Accordion.json +31 -11
- package/data/component-props/Alert.json +3 -3
- package/data/component-props/Autocomplete.json +150 -15
- package/data/component-props/Banner.json +31 -17
- package/data/component-props/Button.json +45 -20
- package/data/component-props/ButtonDropdown.json +36 -17
- package/data/component-props/ButtonDropdownLegacy.json +11 -11
- package/data/component-props/ButtonGroup.json +32 -11
- package/data/component-props/ButtonIcon.json +10 -10
- package/data/component-props/ButtonLegacy.json +19 -19
- package/data/component-props/ButtonToggle.json +32 -19
- package/data/component-props/ButtonToggleLegacy.json +11 -11
- package/data/component-props/Callout.json +58 -17
- package/data/component-props/CellBasic.json +94 -41
- package/data/component-props/CellComponent.json +23 -7
- package/data/component-props/CellHeader.json +62 -19
- package/data/component-props/ComplexFilter.json +52 -21
- package/data/component-props/ContentCard.json +70 -47
- package/data/component-props/Dialog.json +47 -14
- package/data/component-props/Dropdown.json +67 -31
- package/data/component-props/DropdownMenu.json +128 -23
- package/data/component-props/HeatmapChart.json +88 -12
- package/data/component-props/Hero.json +80 -39
- package/data/component-props/Icon.json +20 -9
- package/data/component-props/InputCheckbox.json +36 -14
- package/data/component-props/InputDropdown.json +75 -27
- package/data/component-props/InputRadio.json +31 -13
- package/data/component-props/InputSearch.json +41 -18
- package/data/component-props/InputSlider.json +46 -19
- package/data/component-props/InputText.json +26 -19
- package/data/component-props/InputToggle.json +26 -9
- package/data/component-props/IntentMessage.json +38 -9
- package/data/component-props/Link.json +13 -7
- package/data/component-props/LoadingIndicator.json +11 -3
- package/data/component-props/MenuItem.json +38 -19
- package/data/component-props/MenuSelect.json +8 -8
- package/data/component-props/NavigationFooter.json +49 -19
- package/data/component-props/NavigationHeader.json +150 -37
- package/data/component-props/NavigationJumpTo.json +33 -7
- package/data/component-props/Notification.json +39 -21
- package/data/component-props/Pagination.json +39 -11
- package/data/component-props/Panel.json +62 -9
- package/data/component-props/Popover.json +80 -7
- package/data/component-props/PreComposedTable.json +99 -27
- package/data/component-props/SegmentedControl.json +42 -3
- package/data/component-props/StackedBarChart.json +116 -42
- package/data/component-props/TableRow.json +38 -19
- package/data/component-props/Tabs.json +66 -9
- package/data/component-props/Tag.json +34 -17
- package/data/component-props/TagFilter.json +10 -3
- package/data/component-props/Tooltip.json +49 -18
- package/data/component-props/TooltipCondensed.json +18 -9
- package/data/component-props/TooltipTable.json +17 -7
- package/data/resources/{zeroheight-rules.md → documentation-rules.md} +43 -30
- package/data/resources/figma-rules.md +2 -2
- package/dist/stdio.js +483 -780
- package/package.json +12 -8
- package/data/component-props/ButtonDropdownV2.json +0 -34
- package/data/component-props/ButtonNew.json +0 -47
- package/data/component-props/ButtonToggleV2.json +0 -44
- package/data/component-props/ButtonV2.json +0 -43
- package/data/zeroheight-cache.json +0 -10259
- package/data/zeroheight-exports/Accordion.md +0 -774
- package/data/zeroheight-exports/Banner.md +0 -691
- package/data/zeroheight-exports/Borders.md +0 -117
- package/data/zeroheight-exports/Buttons.md +0 -1854
- package/data/zeroheight-exports/Callout.md +0 -931
- package/data/zeroheight-exports/Colors.md +0 -1755
- package/data/zeroheight-exports/Content-Card.md +0 -309
- package/data/zeroheight-exports/Contributing-to-SDS.md +0 -98
- package/data/zeroheight-exports/Control-Inputs.md +0 -2818
- package/data/zeroheight-exports/Corners.md +0 -104
- package/data/zeroheight-exports/Cover-page.md +0 -3
- package/data/zeroheight-exports/Dialog.md +0 -1367
- package/data/zeroheight-exports/Downloads.md +0 -236
- package/data/zeroheight-exports/Drop-Shadows.md +0 -79
- package/data/zeroheight-exports/Dropdown-Input.md +0 -1776
- package/data/zeroheight-exports/Dropdown-Menus.md +0 -913
- package/data/zeroheight-exports/Element-Status-Tracker.md +0 -267
- package/data/zeroheight-exports/Field-Inputs.md +0 -1405
- package/data/zeroheight-exports/Filters.md +0 -1111
- package/data/zeroheight-exports/Getting-Started.md +0 -1157
- package/data/zeroheight-exports/Hero.md +0 -414
- package/data/zeroheight-exports/Icons.md +0 -2067
- package/data/zeroheight-exports/Intent.md +0 -86
- package/data/zeroheight-exports/Introduction-to-Bases.md +0 -35
- package/data/zeroheight-exports/Introduction-to-Cells.md +0 -35
- package/data/zeroheight-exports/Introduction-to-DNA.md +0 -35
- package/data/zeroheight-exports/Introduction-to-Genes.md +0 -35
- package/data/zeroheight-exports/Introduction.md +0 -115
- package/data/zeroheight-exports/Link.md +0 -432
- package/data/zeroheight-exports/Lists.md +0 -986
- package/data/zeroheight-exports/Loading-Indicator.md +0 -41
- package/data/zeroheight-exports/Navigation.md +0 -1190
- package/data/zeroheight-exports/Notification.md +0 -1038
- package/data/zeroheight-exports/Panel.md +0 -1030
- package/data/zeroheight-exports/README.md +0 -122
- package/data/zeroheight-exports/Responsive-Design.md +0 -330
- package/data/zeroheight-exports/Search-Input.md +0 -91
- package/data/zeroheight-exports/Search.md +0 -822
- package/data/zeroheight-exports/Segmented-Control.md +0 -609
- package/data/zeroheight-exports/Spacing.md +0 -297
- package/data/zeroheight-exports/Table.md +0 -5345
- package/data/zeroheight-exports/Tabs.md +0 -1324
- package/data/zeroheight-exports/Tags.md +0 -1545
- package/data/zeroheight-exports/Text-Link.md +0 -268
- package/data/zeroheight-exports/Theming.md +0 -362
- package/data/zeroheight-exports/Tooltips.md +0 -2015
- package/data/zeroheight-exports/Typography.md +0 -800
|
@@ -0,0 +1,651 @@
|
|
|
1
|
+
# Dialog
|
|
2
|
+
|
|
3
|
+
## Source Code
|
|
4
|
+
|
|
5
|
+
The Dialog component's source code in the SDS codebase can be found [here](https://github.com/chanzuckerberg/sci-components/blob/main/packages/components/src/core/Dialog/index.tsx).
|
|
6
|
+
|
|
7
|
+
A Dialog is composed from four accessory components. They all ship from `@czi-sds/components` and live in the Dialog folder:
|
|
8
|
+
|
|
9
|
+
- DialogTitle renders the overline, title, subtitle, and close button [source code](https://github.com/chanzuckerberg/sci-components/tree/main/packages/components/src/core/Dialog/components/DialogTitle)
|
|
10
|
+
|
|
11
|
+
- DialogContent holds the body copy and scrolls when the content overflows [source code](https://github.com/chanzuckerberg/sci-components/tree/main/packages/components/src/core/Dialog/components/DialogContent)
|
|
12
|
+
|
|
13
|
+
- DialogActions lays out the action buttons in the footer [source code](https://github.com/chanzuckerberg/sci-components/tree/main/packages/components/src/core/Dialog/components/DialogActions)
|
|
14
|
+
|
|
15
|
+
- DialogPaper is the surface the Dialog is drawn on. It is applied for you, so you only need it when you want to restyle the surface [source code](https://github.com/chanzuckerberg/sci-components/tree/main/packages/components/src/core/Dialog/components/DialogPaper)
|
|
16
|
+
|
|
17
|
+
Dialog passes its `sdsSize` down to DialogPaper, DialogTitle, and DialogActions automatically, so you set the size once on Dialog. DialogContent does not take a size.
|
|
18
|
+
|
|
19
|
+
## Import
|
|
20
|
+
|
|
21
|
+
**React TypeScript**
|
|
22
|
+
|
|
23
|
+
```tsx
|
|
24
|
+
import {
|
|
25
|
+
Dialog,
|
|
26
|
+
DialogActions,
|
|
27
|
+
DialogContent,
|
|
28
|
+
DialogPaper,
|
|
29
|
+
DialogTitle,
|
|
30
|
+
DialogTitleSubtitle,
|
|
31
|
+
DialogTitleTitle,
|
|
32
|
+
} from "@czi-sds/components";
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
## Code examples
|
|
36
|
+
|
|
37
|
+
### Default Dialog
|
|
38
|
+
|
|
39
|
+
The minimum setup: a title, some content, and the open state you control. The `onClose` on DialogTitle renders the close button, and the one on Dialog handles the backdrop click and the Esc key.
|
|
40
|
+
|
|
41
|
+
**Example: DefaultDialog**
|
|
42
|
+
|
|
43
|
+
```tsx
|
|
44
|
+
// A dismissible Dialog: passing `onClose` to DialogTitle renders the close
|
|
45
|
+
// button, and `onClose` on Dialog handles the backdrop click and the Esc key.
|
|
46
|
+
|
|
47
|
+
import { useState } from "react";
|
|
48
|
+
import {
|
|
49
|
+
Button,
|
|
50
|
+
Dialog,
|
|
51
|
+
DialogContent,
|
|
52
|
+
DialogTitle,
|
|
53
|
+
} from "@czi-sds/components";
|
|
54
|
+
|
|
55
|
+
function App() {
|
|
56
|
+
const [isOpen, setIsOpen] = useState(false);
|
|
57
|
+
|
|
58
|
+
return (
|
|
59
|
+
<div className="app" style={{ padding: 20 }}>
|
|
60
|
+
<Button
|
|
61
|
+
sdsStyle="solid"
|
|
62
|
+
sdsType="primary"
|
|
63
|
+
onClick={() => setIsOpen(true)}
|
|
64
|
+
>
|
|
65
|
+
Open Dialog
|
|
66
|
+
</Button>
|
|
67
|
+
|
|
68
|
+
<Dialog open={isOpen} onClose={() => setIsOpen(false)}>
|
|
69
|
+
<DialogTitle
|
|
70
|
+
title="Learning Resources"
|
|
71
|
+
subtitle="Tutorials, guides, and articles"
|
|
72
|
+
onClose={() => setIsOpen(false)}
|
|
73
|
+
/>
|
|
74
|
+
<DialogContent>
|
|
75
|
+
Embark on a journey of continuous improvement with our treasure trove
|
|
76
|
+
of learning materials. This section hosts an array of tutorials,
|
|
77
|
+
guides, and insightful articles designed to enhance your skills and
|
|
78
|
+
deepen your understanding.
|
|
79
|
+
</DialogContent>
|
|
80
|
+
</Dialog>
|
|
81
|
+
</div>
|
|
82
|
+
);
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
export default App;
|
|
86
|
+
```
|
|
87
|
+
|
|
88
|
+
### Dialog Sizes
|
|
89
|
+
|
|
90
|
+
Each `sdsSize` sets a fixed width and a minimum height. The height still grows with the content, and the padding and title type scale with the size.
|
|
91
|
+
|
|
92
|
+
**Example: DialogSizes**
|
|
93
|
+
|
|
94
|
+
```tsx
|
|
95
|
+
// `sdsSize` sets a fixed paper width and a minimum height. It is forwarded to
|
|
96
|
+
// DialogPaper, DialogTitle, and DialogActions, so padding and type scale with it.
|
|
97
|
+
|
|
98
|
+
import { useState } from "react";
|
|
99
|
+
import {
|
|
100
|
+
Button,
|
|
101
|
+
Dialog,
|
|
102
|
+
DialogContent,
|
|
103
|
+
DialogTitle,
|
|
104
|
+
} from "@czi-sds/components";
|
|
105
|
+
|
|
106
|
+
const SIZES = ["xs", "s", "m", "l"] as const;
|
|
107
|
+
|
|
108
|
+
const DIMENSIONS = {
|
|
109
|
+
l: "1200 × 600px",
|
|
110
|
+
m: "900 × 480px",
|
|
111
|
+
s: "600 × 400px",
|
|
112
|
+
xs: "400 × 160px",
|
|
113
|
+
};
|
|
114
|
+
|
|
115
|
+
function App() {
|
|
116
|
+
const [openSize, setOpenSize] = useState<(typeof SIZES)[number] | null>(null);
|
|
117
|
+
|
|
118
|
+
return (
|
|
119
|
+
<div className="app" style={{ display: "flex", gap: "8px", padding: 20 }}>
|
|
120
|
+
{SIZES.map((size) => (
|
|
121
|
+
<Button
|
|
122
|
+
key={size}
|
|
123
|
+
sdsStyle="outline"
|
|
124
|
+
sdsType="primary"
|
|
125
|
+
onClick={() => setOpenSize(size)}
|
|
126
|
+
>
|
|
127
|
+
Open {size.toUpperCase()}
|
|
128
|
+
</Button>
|
|
129
|
+
))}
|
|
130
|
+
|
|
131
|
+
<Dialog
|
|
132
|
+
open={openSize !== null}
|
|
133
|
+
onClose={() => setOpenSize(null)}
|
|
134
|
+
sdsSize={openSize ?? "m"}
|
|
135
|
+
>
|
|
136
|
+
<DialogTitle
|
|
137
|
+
title={`Size ${(openSize ?? "m").toUpperCase()}`}
|
|
138
|
+
subtitle={DIMENSIONS[openSize ?? "m"]}
|
|
139
|
+
onClose={() => setOpenSize(null)}
|
|
140
|
+
/>
|
|
141
|
+
<DialogContent>
|
|
142
|
+
The width is fixed per size and the height grows with the content,
|
|
143
|
+
down to the minimum height.
|
|
144
|
+
</DialogContent>
|
|
145
|
+
</Dialog>
|
|
146
|
+
</div>
|
|
147
|
+
);
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
export default App;
|
|
151
|
+
```
|
|
152
|
+
|
|
153
|
+
### Dialog with Action Buttons
|
|
154
|
+
|
|
155
|
+
DialogActions places the buttons in the footer, right aligned by default, so the primary action is listed last.
|
|
156
|
+
|
|
157
|
+
**Example: DialogWithActionButtons**
|
|
158
|
+
|
|
159
|
+
```tsx
|
|
160
|
+
// DialogActions aligns its buttons to the right by default, so the primary
|
|
161
|
+
// action goes last.
|
|
162
|
+
|
|
163
|
+
import { useState } from "react";
|
|
164
|
+
import {
|
|
165
|
+
Button,
|
|
166
|
+
Dialog,
|
|
167
|
+
DialogActions,
|
|
168
|
+
DialogContent,
|
|
169
|
+
DialogTitle,
|
|
170
|
+
} from "@czi-sds/components";
|
|
171
|
+
|
|
172
|
+
function App() {
|
|
173
|
+
const [isOpen, setIsOpen] = useState(false);
|
|
174
|
+
|
|
175
|
+
function handleClose() {
|
|
176
|
+
setIsOpen(false);
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
return (
|
|
180
|
+
<div className="app" style={{ padding: 20 }}>
|
|
181
|
+
<Button
|
|
182
|
+
sdsStyle="solid"
|
|
183
|
+
sdsType="primary"
|
|
184
|
+
onClick={() => setIsOpen(true)}
|
|
185
|
+
>
|
|
186
|
+
Open Dialog
|
|
187
|
+
</Button>
|
|
188
|
+
|
|
189
|
+
<Dialog open={isOpen} onClose={handleClose} sdsSize="s">
|
|
190
|
+
<DialogTitle
|
|
191
|
+
title="Share this collection"
|
|
192
|
+
subtitle="Anyone with the link can view it"
|
|
193
|
+
onClose={handleClose}
|
|
194
|
+
/>
|
|
195
|
+
<DialogContent>
|
|
196
|
+
Sharing generates a public link. You can revoke access at any time
|
|
197
|
+
from the collection settings.
|
|
198
|
+
</DialogContent>
|
|
199
|
+
<DialogActions>
|
|
200
|
+
<Button sdsStyle="outline" sdsType="primary" onClick={handleClose}>
|
|
201
|
+
Cancel
|
|
202
|
+
</Button>
|
|
203
|
+
<Button sdsStyle="solid" sdsType="primary" onClick={handleClose}>
|
|
204
|
+
Share
|
|
205
|
+
</Button>
|
|
206
|
+
</DialogActions>
|
|
207
|
+
</Dialog>
|
|
208
|
+
</div>
|
|
209
|
+
);
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
export default App;
|
|
213
|
+
```
|
|
214
|
+
|
|
215
|
+
### Dialog with Left-Aligned Buttons
|
|
216
|
+
|
|
217
|
+
Setting `buttonPosition` to `"left"` moves the button row to the other side. List the primary action first so it stays on the outside edge.
|
|
218
|
+
|
|
219
|
+
**Example: DialogWithLeftAlignedButtons**
|
|
220
|
+
|
|
221
|
+
```tsx
|
|
222
|
+
// `buttonPosition="left"` flips the alignment, so the primary action is listed
|
|
223
|
+
// first to keep it closest to the left edge.
|
|
224
|
+
|
|
225
|
+
import { useState } from "react";
|
|
226
|
+
import {
|
|
227
|
+
Button,
|
|
228
|
+
Dialog,
|
|
229
|
+
DialogActions,
|
|
230
|
+
DialogContent,
|
|
231
|
+
DialogTitle,
|
|
232
|
+
} from "@czi-sds/components";
|
|
233
|
+
|
|
234
|
+
function App() {
|
|
235
|
+
const [isOpen, setIsOpen] = useState(false);
|
|
236
|
+
|
|
237
|
+
function handleClose() {
|
|
238
|
+
setIsOpen(false);
|
|
239
|
+
}
|
|
240
|
+
|
|
241
|
+
return (
|
|
242
|
+
<div className="app" style={{ padding: 20 }}>
|
|
243
|
+
<Button
|
|
244
|
+
sdsStyle="solid"
|
|
245
|
+
sdsType="primary"
|
|
246
|
+
onClick={() => setIsOpen(true)}
|
|
247
|
+
>
|
|
248
|
+
Open Dialog
|
|
249
|
+
</Button>
|
|
250
|
+
|
|
251
|
+
<Dialog open={isOpen} onClose={handleClose} sdsSize="s">
|
|
252
|
+
<DialogTitle
|
|
253
|
+
title="Delete this analysis?"
|
|
254
|
+
subtitle="This action cannot be undone"
|
|
255
|
+
onClose={handleClose}
|
|
256
|
+
/>
|
|
257
|
+
<DialogContent>
|
|
258
|
+
The analysis and all of its results will be permanently removed from
|
|
259
|
+
the project.
|
|
260
|
+
</DialogContent>
|
|
261
|
+
<DialogActions buttonPosition="left">
|
|
262
|
+
<Button sdsStyle="solid" sdsType="destructive" onClick={handleClose}>
|
|
263
|
+
Delete
|
|
264
|
+
</Button>
|
|
265
|
+
<Button sdsStyle="outline" sdsType="primary" onClick={handleClose}>
|
|
266
|
+
Cancel
|
|
267
|
+
</Button>
|
|
268
|
+
</DialogActions>
|
|
269
|
+
</Dialog>
|
|
270
|
+
</div>
|
|
271
|
+
);
|
|
272
|
+
}
|
|
273
|
+
|
|
274
|
+
export default App;
|
|
275
|
+
```
|
|
276
|
+
|
|
277
|
+
### Persistent Dialog
|
|
278
|
+
|
|
279
|
+
Passing `canClickOutsideClose` as `false` ignores both the backdrop click and the Esc key. Leaving `onClose` off DialogTitle also hides the close button, so the action buttons are the only way out and the Dialog needs at least one.
|
|
280
|
+
|
|
281
|
+
**Example: PersistentDialog**
|
|
282
|
+
|
|
283
|
+
```tsx
|
|
284
|
+
// `canClickOutsideClose={false}` blocks both the backdrop click and the Esc
|
|
285
|
+
// key. Leaving `onClose` off DialogTitle hides the close button, so an action
|
|
286
|
+
// button is the only way out.
|
|
287
|
+
|
|
288
|
+
import { useState } from "react";
|
|
289
|
+
import {
|
|
290
|
+
Button,
|
|
291
|
+
Dialog,
|
|
292
|
+
DialogActions,
|
|
293
|
+
DialogContent,
|
|
294
|
+
DialogTitle,
|
|
295
|
+
} from "@czi-sds/components";
|
|
296
|
+
|
|
297
|
+
function App() {
|
|
298
|
+
const [isOpen, setIsOpen] = useState(false);
|
|
299
|
+
|
|
300
|
+
return (
|
|
301
|
+
<div className="app" style={{ padding: 20 }}>
|
|
302
|
+
<Button
|
|
303
|
+
sdsStyle="solid"
|
|
304
|
+
sdsType="primary"
|
|
305
|
+
onClick={() => setIsOpen(true)}
|
|
306
|
+
>
|
|
307
|
+
Open Dialog
|
|
308
|
+
</Button>
|
|
309
|
+
|
|
310
|
+
<Dialog
|
|
311
|
+
open={isOpen}
|
|
312
|
+
onClose={() => setIsOpen(false)}
|
|
313
|
+
canClickOutsideClose={false}
|
|
314
|
+
sdsSize="s"
|
|
315
|
+
>
|
|
316
|
+
<DialogTitle
|
|
317
|
+
title="Leaving this site"
|
|
318
|
+
subtitle="You are about to open an external resource"
|
|
319
|
+
/>
|
|
320
|
+
<DialogContent>
|
|
321
|
+
The link opens a site that is not maintained by us. Any data you enter
|
|
322
|
+
there is subject to that site's privacy policy.
|
|
323
|
+
</DialogContent>
|
|
324
|
+
<DialogActions>
|
|
325
|
+
<Button
|
|
326
|
+
sdsStyle="outline"
|
|
327
|
+
sdsType="primary"
|
|
328
|
+
onClick={() => setIsOpen(false)}
|
|
329
|
+
>
|
|
330
|
+
Stay here
|
|
331
|
+
</Button>
|
|
332
|
+
<Button
|
|
333
|
+
sdsStyle="solid"
|
|
334
|
+
sdsType="primary"
|
|
335
|
+
onClick={() => setIsOpen(false)}
|
|
336
|
+
>
|
|
337
|
+
Continue
|
|
338
|
+
</Button>
|
|
339
|
+
</DialogActions>
|
|
340
|
+
</Dialog>
|
|
341
|
+
</div>
|
|
342
|
+
);
|
|
343
|
+
}
|
|
344
|
+
|
|
345
|
+
export default App;
|
|
346
|
+
```
|
|
347
|
+
|
|
348
|
+
### Multi-step Dialog
|
|
349
|
+
|
|
350
|
+
The overline is the place for a step count. Keep every step in the same size Dialog, and make the workflow persistent so progress cannot be lost by accident.
|
|
351
|
+
|
|
352
|
+
**Example: MultiStepDialog**
|
|
353
|
+
|
|
354
|
+
```tsx
|
|
355
|
+
// `overline` sits above the title and is the recommended place for the step
|
|
356
|
+
// count in a multi-step workflow.
|
|
357
|
+
|
|
358
|
+
import { useState } from "react";
|
|
359
|
+
import {
|
|
360
|
+
Button,
|
|
361
|
+
Dialog,
|
|
362
|
+
DialogActions,
|
|
363
|
+
DialogContent,
|
|
364
|
+
DialogTitle,
|
|
365
|
+
} from "@czi-sds/components";
|
|
366
|
+
|
|
367
|
+
const STEPS = [
|
|
368
|
+
{
|
|
369
|
+
body: "Pick the files you want to include. You can add more later.",
|
|
370
|
+
title: "Select your data",
|
|
371
|
+
},
|
|
372
|
+
{
|
|
373
|
+
body: "Choose the reference genome and the quality thresholds for the run.",
|
|
374
|
+
title: "Configure the analysis",
|
|
375
|
+
},
|
|
376
|
+
{
|
|
377
|
+
body: "Everything looks good. Starting the run will queue it immediately.",
|
|
378
|
+
title: "Review and submit",
|
|
379
|
+
},
|
|
380
|
+
];
|
|
381
|
+
|
|
382
|
+
function App() {
|
|
383
|
+
const [isOpen, setIsOpen] = useState(false);
|
|
384
|
+
const [step, setStep] = useState(0);
|
|
385
|
+
|
|
386
|
+
function handleClose() {
|
|
387
|
+
setIsOpen(false);
|
|
388
|
+
setStep(0);
|
|
389
|
+
}
|
|
390
|
+
|
|
391
|
+
const isLastStep = step === STEPS.length - 1;
|
|
392
|
+
|
|
393
|
+
return (
|
|
394
|
+
<div className="app" style={{ padding: 20 }}>
|
|
395
|
+
<Button
|
|
396
|
+
sdsStyle="solid"
|
|
397
|
+
sdsType="primary"
|
|
398
|
+
onClick={() => setIsOpen(true)}
|
|
399
|
+
>
|
|
400
|
+
Open Dialog
|
|
401
|
+
</Button>
|
|
402
|
+
|
|
403
|
+
<Dialog
|
|
404
|
+
open={isOpen}
|
|
405
|
+
onClose={handleClose}
|
|
406
|
+
canClickOutsideClose={false}
|
|
407
|
+
sdsSize="s"
|
|
408
|
+
>
|
|
409
|
+
<DialogTitle
|
|
410
|
+
overline={`Step ${step + 1} of ${STEPS.length}`}
|
|
411
|
+
title={STEPS[step].title}
|
|
412
|
+
subtitle="New analysis"
|
|
413
|
+
/>
|
|
414
|
+
<DialogContent>{STEPS[step].body}</DialogContent>
|
|
415
|
+
<DialogActions>
|
|
416
|
+
<Button
|
|
417
|
+
sdsStyle="outline"
|
|
418
|
+
sdsType="primary"
|
|
419
|
+
onClick={() => (step === 0 ? handleClose() : setStep(step - 1))}
|
|
420
|
+
>
|
|
421
|
+
{step === 0 ? "Cancel" : "Back"}
|
|
422
|
+
</Button>
|
|
423
|
+
<Button
|
|
424
|
+
sdsStyle="solid"
|
|
425
|
+
sdsType="primary"
|
|
426
|
+
onClick={() => (isLastStep ? handleClose() : setStep(step + 1))}
|
|
427
|
+
>
|
|
428
|
+
{isLastStep ? "Start run" : "Next"}
|
|
429
|
+
</Button>
|
|
430
|
+
</DialogActions>
|
|
431
|
+
</Dialog>
|
|
432
|
+
</div>
|
|
433
|
+
);
|
|
434
|
+
}
|
|
435
|
+
|
|
436
|
+
export default App;
|
|
437
|
+
```
|
|
438
|
+
|
|
439
|
+
### Dialog with a Long Content
|
|
440
|
+
|
|
441
|
+
The paper is capped at the viewport height, so DialogContent scrolls on its own while the title and the action buttons stay in place.
|
|
442
|
+
|
|
443
|
+
**Example: DialogWithALongContent**
|
|
444
|
+
|
|
445
|
+
```tsx
|
|
446
|
+
// The paper is capped at the viewport height, so DialogContent scrolls on its
|
|
447
|
+
// own and the title and action buttons stay in place.
|
|
448
|
+
|
|
449
|
+
import { useState } from "react";
|
|
450
|
+
import {
|
|
451
|
+
Button,
|
|
452
|
+
Dialog,
|
|
453
|
+
DialogActions,
|
|
454
|
+
DialogContent,
|
|
455
|
+
DialogTitle,
|
|
456
|
+
} from "@czi-sds/components";
|
|
457
|
+
|
|
458
|
+
const PARAGRAPH =
|
|
459
|
+
"Explore a diverse range of topics, from fundamental principles to advanced techniques, as we aim to empower you with knowledge that transcends boundaries. Whether you are a novice eager to build a strong foundation or a seasoned professional staying at the forefront of your industry, this material is your gateway to honing your expertise.";
|
|
460
|
+
|
|
461
|
+
function App() {
|
|
462
|
+
const [isOpen, setIsOpen] = useState(false);
|
|
463
|
+
|
|
464
|
+
function handleClose() {
|
|
465
|
+
setIsOpen(false);
|
|
466
|
+
}
|
|
467
|
+
|
|
468
|
+
return (
|
|
469
|
+
<div className="app" style={{ padding: 20 }}>
|
|
470
|
+
<Button
|
|
471
|
+
sdsStyle="solid"
|
|
472
|
+
sdsType="primary"
|
|
473
|
+
onClick={() => setIsOpen(true)}
|
|
474
|
+
>
|
|
475
|
+
Open Dialog
|
|
476
|
+
</Button>
|
|
477
|
+
|
|
478
|
+
<Dialog open={isOpen} onClose={handleClose} sdsSize="s">
|
|
479
|
+
<DialogTitle
|
|
480
|
+
title="Terms of use"
|
|
481
|
+
subtitle="Last updated January 2025"
|
|
482
|
+
onClose={handleClose}
|
|
483
|
+
/>
|
|
484
|
+
<DialogContent>
|
|
485
|
+
{[1, 2, 3, 4, 5, 6, 7, 8, 9, 10].map((section) => (
|
|
486
|
+
<p key={section}>
|
|
487
|
+
{section}. {PARAGRAPH}
|
|
488
|
+
</p>
|
|
489
|
+
))}
|
|
490
|
+
</DialogContent>
|
|
491
|
+
<DialogActions>
|
|
492
|
+
<Button sdsStyle="outline" sdsType="primary" onClick={handleClose}>
|
|
493
|
+
Decline
|
|
494
|
+
</Button>
|
|
495
|
+
<Button sdsStyle="solid" sdsType="primary" onClick={handleClose}>
|
|
496
|
+
Accept
|
|
497
|
+
</Button>
|
|
498
|
+
</DialogActions>
|
|
499
|
+
</Dialog>
|
|
500
|
+
</div>
|
|
501
|
+
);
|
|
502
|
+
}
|
|
503
|
+
|
|
504
|
+
export default App;
|
|
505
|
+
```
|
|
506
|
+
|
|
507
|
+
### Dialog with a Custom Title
|
|
508
|
+
|
|
509
|
+
Passing `children` to DialogTitle replaces the built-in layout, which is how you add artwork above the title. The close button is part of that layout, so it goes away too.
|
|
510
|
+
|
|
511
|
+
**Example: DialogWithCustomTitle**
|
|
512
|
+
|
|
513
|
+
```tsx
|
|
514
|
+
// Children replace DialogTitle's built-in layout, including the close button.
|
|
515
|
+
// DialogTitleTitle and DialogTitleSubtitle keep the SDS type styles, but they
|
|
516
|
+
// need their own `sdsSize` because only DialogTitle receives it from Dialog.
|
|
517
|
+
|
|
518
|
+
import { useState } from "react";
|
|
519
|
+
import {
|
|
520
|
+
Button,
|
|
521
|
+
Dialog,
|
|
522
|
+
DialogActions,
|
|
523
|
+
DialogContent,
|
|
524
|
+
DialogTitle,
|
|
525
|
+
DialogTitleSubtitle,
|
|
526
|
+
DialogTitleTitle,
|
|
527
|
+
Icon,
|
|
528
|
+
} from "@czi-sds/components";
|
|
529
|
+
|
|
530
|
+
function App() {
|
|
531
|
+
const [isOpen, setIsOpen] = useState(false);
|
|
532
|
+
|
|
533
|
+
function handleClose() {
|
|
534
|
+
setIsOpen(false);
|
|
535
|
+
}
|
|
536
|
+
|
|
537
|
+
return (
|
|
538
|
+
<div className="app" style={{ padding: 20 }}>
|
|
539
|
+
<Button
|
|
540
|
+
sdsStyle="solid"
|
|
541
|
+
sdsType="primary"
|
|
542
|
+
onClick={() => setIsOpen(true)}
|
|
543
|
+
>
|
|
544
|
+
Open Dialog
|
|
545
|
+
</Button>
|
|
546
|
+
|
|
547
|
+
<Dialog open={isOpen} onClose={handleClose} sdsSize="s">
|
|
548
|
+
<DialogTitle>
|
|
549
|
+
<div
|
|
550
|
+
style={{
|
|
551
|
+
alignItems: "center",
|
|
552
|
+
display: "flex",
|
|
553
|
+
flexDirection: "column",
|
|
554
|
+
gap: "8px",
|
|
555
|
+
textAlign: "center",
|
|
556
|
+
}}
|
|
557
|
+
>
|
|
558
|
+
<Icon
|
|
559
|
+
sdsIcon="CheckCircle"
|
|
560
|
+
sdsSize="xl"
|
|
561
|
+
color="green"
|
|
562
|
+
shade={400}
|
|
563
|
+
/>
|
|
564
|
+
<DialogTitleTitle sdsSize="s">Upload complete</DialogTitleTitle>
|
|
565
|
+
<DialogTitleSubtitle sdsSize="s">
|
|
566
|
+
24 files processed
|
|
567
|
+
</DialogTitleSubtitle>
|
|
568
|
+
</div>
|
|
569
|
+
</DialogTitle>
|
|
570
|
+
<DialogContent>
|
|
571
|
+
Your files are ready. Results will appear in the project as soon as
|
|
572
|
+
the analysis finishes.
|
|
573
|
+
</DialogContent>
|
|
574
|
+
<DialogActions>
|
|
575
|
+
<Button sdsStyle="solid" sdsType="primary" onClick={handleClose}>
|
|
576
|
+
Done
|
|
577
|
+
</Button>
|
|
578
|
+
</DialogActions>
|
|
579
|
+
</Dialog>
|
|
580
|
+
</div>
|
|
581
|
+
);
|
|
582
|
+
}
|
|
583
|
+
|
|
584
|
+
export default App;
|
|
585
|
+
```
|
|
586
|
+
|
|
587
|
+
## SDS vs MUI
|
|
588
|
+
|
|
589
|
+
The SDS Dialog is built on top of MUI's Dialog. The following props differ in whether and how they work:
|
|
590
|
+
|
|
591
|
+
- `fullScreen`: Has no effect in SDS. DialogPaper sets a fixed width per `sdsSize` that wins over the MUI full screen styles.
|
|
592
|
+
|
|
593
|
+
- `maxWidth` and `fullWidth`: Have no effect in SDS, for the same reason. Use `sdsSize` to pick a width.
|
|
594
|
+
|
|
595
|
+
- `PaperComponent`: Defaults to DialogPaper. A replacement receives the `sdsSize` prop, so it should accept `DialogPaperProps`.
|
|
596
|
+
|
|
597
|
+
- `onClose`: Keeps the MUI signature, but SDS swallows the call when `canClickOutsideClose` is `false` and the reason is `"backdropClick"` or `"escapeKeyDown"`.
|
|
598
|
+
|
|
599
|
+
- `classes`: SDS accepts its own shape here rather than the MUI slot classes. Only `root` and `paper` are applied; the `title` and `actions` keys are declared in the type but never used. Pass a class to DialogTitle or DialogActions directly instead.
|
|
600
|
+
|
|
601
|
+
- `DialogComponent`: Declared in `DialogExtraProps` but not wired up, so passing it does nothing.
|
|
602
|
+
|
|
603
|
+
## MUI Documentation
|
|
604
|
+
|
|
605
|
+
Documentation for the underlying MUI component can be found [here](https://mui.com/material-ui/react-dialog/#scrolling-long-content).
|
|
606
|
+
|
|
607
|
+
## Props
|
|
608
|
+
|
|
609
|
+
Any custom SDS props and MUI props required for implementation are found on the table below. See the MUI documentation for additional optional props.
|
|
610
|
+
|
|
611
|
+
### Dialog Props
|
|
612
|
+
|
|
613
|
+
Props table for the Dialog component.
|
|
614
|
+
|
|
615
|
+
| Name | Type | Default | Description |
|
|
616
|
+
| ---------------------- | ----------------------------------- | ------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
|
|
617
|
+
| `open` | `boolean` | - | Required. If `true`, the Dialog is shown. The Dialog is a controlled component, so you own this state. |
|
|
618
|
+
| `sdsSize` | `"xs"` \| `"s"` \| `"m"` \| `"l"` | `"m"` | Sets a fixed width and a minimum height: `"xs"` is 400 × 160px, `"s"` is 600 × 400px, `"m"` is 900 × 480px, and `"l"` is 1200 × 600px. It also drives the padding and the title type scale, and is forwarded to DialogPaper, DialogTitle, and DialogActions. |
|
|
619
|
+
| `canClickOutsideClose` | `boolean` | `true` | When `false`, `onClose` is not called for a backdrop click or the Esc key, which makes the Dialog persistent. Give those Dialogs an action button that closes them. |
|
|
620
|
+
| `onClose` | `function` | - | Called when the Dialog requests to be closed. **Signature:** `function(event: object, reason: string) => void`. It receives: - `event` The event source of the callback. - `reason` Can be: `"escapeKeyDown"`, `"backdropClick"` |
|
|
621
|
+
| `PaperComponent` | `ComponentType<DialogPaperProps>` | `DialogPaper` | The surface the Dialog is drawn on. A replacement receives `sdsSize` along with the usual Paper props. |
|
|
622
|
+
| `DialogComponent` | `ComponentType<DialogProps>` | `Dialog` | Replaces MUI's Dialog itself, rather than the surface inside it. Declared on the props type and not read by the component, so passing it has no effect today. |
|
|
623
|
+
| `classes` | `{ root?: string; paper?: string }` | `{}` | Class names for the Dialog root and the paper surface. The `title` and `actions` keys exist in the type but are not applied. |
|
|
624
|
+
|
|
625
|
+
### DialogTitle Props
|
|
626
|
+
|
|
627
|
+
Props table for the DialogTitle component.
|
|
628
|
+
|
|
629
|
+
| Name | Type | Default | Description |
|
|
630
|
+
| ---------- | ----------------------------------------------------------------------------------------------- | ----------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
631
|
+
| `title` | `string` | - | The title text of the Dialog. |
|
|
632
|
+
| `subtitle` | `string` | - | Secondary text rendered below the title. |
|
|
633
|
+
| `overline` | `string` | - | Small text rendered above the title. Use it for the step count in a multi-step workflow. |
|
|
634
|
+
| `onClose` | `() => void` | - | Setting this renders the close button in the top-right corner and calls the function when it is clicked. Omit it for a persistent Dialog. This signature takes no arguments, unlike `onClose` on Dialog. |
|
|
635
|
+
| `children` | `ReactNode` | - | Replaces the entire built-in layout, including the close button, so `title`, `subtitle`, `overline`, and `onClose` are ignored when children are present. Use DialogTitleOverline, DialogTitleTitle, and DialogTitleSubtitle to keep the SDS type styles. |
|
|
636
|
+
| `sdsSize` | `"xs"` \| `"s"` \| `"m"` \| `"l"` | from Dialog | Injected by Dialog. Set it only when you render DialogTitle outside of a Dialog. |
|
|
637
|
+
| `classes` | `{ root?: string; title?: string; subtitle?: string; overline?: string; closeButton?: string }` | `{}` | Class names for the individual parts of the title block. |
|
|
638
|
+
|
|
639
|
+
### DialogActions Props
|
|
640
|
+
|
|
641
|
+
Props table for the DialogActions component.
|
|
642
|
+
|
|
643
|
+
| Name | Type | Default | Description |
|
|
644
|
+
| ---------------- | --------------------------------- | ----------- | --------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
645
|
+
| `buttonPosition` | `"left" \| "right"` | `"right"` | Aligns the action buttons in the footer. Order the buttons so the primary action sits on the outside: last for `"right"`, first for `"left"`. |
|
|
646
|
+
| `sdsSize` | `"xs"` \| `"s"` \| `"m"` \| `"l"` | from Dialog | Injected by Dialog. It controls the gap above the button row. |
|
|
647
|
+
| `classes` | `{ root?: string }` | `{}` | Class name for the actions row. |
|
|
648
|
+
|
|
649
|
+
### DialogContent Props
|
|
650
|
+
|
|
651
|
+
DialogContent takes the MUI DialogContent props plus a `classes` object with a `root` key. It applies the SDS body type styles and removes the MUI padding; everything else is passed straight through.
|