@czi-sds/mcp 0.16.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 +68 -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 +112 -208
- package/package.json +9 -5
- 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,288 @@
|
|
|
1
|
+
# Notification
|
|
2
|
+
|
|
3
|
+
## Source Code
|
|
4
|
+
|
|
5
|
+
The component's source code in the SDS codebase can be found [here](https://github.com/chanzuckerberg/sci-components/blob/main/packages/components/src/core/Notification/index.tsx).
|
|
6
|
+
|
|
7
|
+
## Import
|
|
8
|
+
|
|
9
|
+
**React TypeScript**
|
|
10
|
+
|
|
11
|
+
```tsx
|
|
12
|
+
import { Notification } from "@czi-sds/components";
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
## Code examples
|
|
16
|
+
|
|
17
|
+
### Default Notification
|
|
18
|
+
|
|
19
|
+
This example has the minimum props needed for the Notification component. With no `onClose` and no `autoDismiss` it is persistent: it stays until the surrounding page stops rendering it.
|
|
20
|
+
|
|
21
|
+
**Example: DefaultNotification**
|
|
22
|
+
|
|
23
|
+
```tsx
|
|
24
|
+
// Most minimal Notification (just has the basic requirements)
|
|
25
|
+
|
|
26
|
+
import { Notification } from "@czi-sds/components";
|
|
27
|
+
|
|
28
|
+
function App() {
|
|
29
|
+
return (
|
|
30
|
+
<div className="app">
|
|
31
|
+
<Notification intent="info" slideDirection="left">
|
|
32
|
+
The Notification component has been rendered successfully!
|
|
33
|
+
</Notification>
|
|
34
|
+
</div>
|
|
35
|
+
);
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
export default App;
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
### Notification intents
|
|
42
|
+
|
|
43
|
+
This example shows the five intents, each with the icon the Notification picks by default.
|
|
44
|
+
|
|
45
|
+
**Example: NotificationIntents**
|
|
46
|
+
|
|
47
|
+
```tsx
|
|
48
|
+
// Every intent, each with the icon the Notification picks by default
|
|
49
|
+
|
|
50
|
+
import { Notification } from "@czi-sds/components";
|
|
51
|
+
|
|
52
|
+
function App() {
|
|
53
|
+
return (
|
|
54
|
+
<div className="app">
|
|
55
|
+
<Notification intent="info" slideDirection="left">
|
|
56
|
+
Info: lorem ipsum dolor sit amet, consectetur adipiscing elit.
|
|
57
|
+
</Notification>
|
|
58
|
+
<Notification intent="accent" slideDirection="left">
|
|
59
|
+
Accent: lorem ipsum dolor sit amet, consectetur adipiscing elit.
|
|
60
|
+
</Notification>
|
|
61
|
+
<Notification intent="positive" slideDirection="left">
|
|
62
|
+
Positive: lorem ipsum dolor sit amet, consectetur adipiscing elit.
|
|
63
|
+
</Notification>
|
|
64
|
+
<Notification intent="notice" slideDirection="left">
|
|
65
|
+
Notice: lorem ipsum dolor sit amet, consectetur adipiscing elit.
|
|
66
|
+
</Notification>
|
|
67
|
+
<Notification intent="negative" slideDirection="left">
|
|
68
|
+
Negative: lorem ipsum dolor sit amet, consectetur adipiscing elit.
|
|
69
|
+
</Notification>
|
|
70
|
+
</div>
|
|
71
|
+
);
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
export default App;
|
|
75
|
+
```
|
|
76
|
+
|
|
77
|
+
### Dismissible Notification
|
|
78
|
+
|
|
79
|
+
Passing `onClose` adds a close button in the top right corner, giving users a familiar way to remove the Notification from view. The Notification hides itself when that button is clicked, so `onClose` is for keeping your own state in sync; setting `dismissed` back to `false` is what brings it back.
|
|
80
|
+
|
|
81
|
+
**Example: DismissibleNotification**
|
|
82
|
+
|
|
83
|
+
```tsx
|
|
84
|
+
// Closable Notification
|
|
85
|
+
|
|
86
|
+
import { useState } from "react";
|
|
87
|
+
import { Button, Notification } from "@czi-sds/components";
|
|
88
|
+
|
|
89
|
+
function App() {
|
|
90
|
+
const [dismissed, setDismissed] = useState(false);
|
|
91
|
+
|
|
92
|
+
return (
|
|
93
|
+
<div className="app">
|
|
94
|
+
<Notification
|
|
95
|
+
intent="negative"
|
|
96
|
+
slideDirection="left"
|
|
97
|
+
dismissed={dismissed}
|
|
98
|
+
onClose={() => setDismissed(true)}
|
|
99
|
+
>
|
|
100
|
+
Something went wrong while saving your changes.
|
|
101
|
+
</Notification>
|
|
102
|
+
{dismissed && (
|
|
103
|
+
<Button onClick={() => setDismissed(false)} sdsType="primary">
|
|
104
|
+
Reset Notification
|
|
105
|
+
</Button>
|
|
106
|
+
)}
|
|
107
|
+
</div>
|
|
108
|
+
);
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
export default App;
|
|
112
|
+
```
|
|
113
|
+
|
|
114
|
+
### Notification with a button
|
|
115
|
+
|
|
116
|
+
A Notification can carry a single action button beneath its content, most often to dismiss it or to send the user somewhere related. The button appears as soon as `buttonOnClick` is given, sits on the right unless `buttonPosition` says otherwise, and leaves dismissing to the handler.
|
|
117
|
+
|
|
118
|
+
**Example: NotificationWithAButton**
|
|
119
|
+
|
|
120
|
+
```tsx
|
|
121
|
+
// Notification with an action button beneath its message
|
|
122
|
+
|
|
123
|
+
import { useState } from "react";
|
|
124
|
+
import { Button, Notification } from "@czi-sds/components";
|
|
125
|
+
|
|
126
|
+
function App() {
|
|
127
|
+
const [dismissed, setDismissed] = useState(false);
|
|
128
|
+
|
|
129
|
+
return (
|
|
130
|
+
<div className="app">
|
|
131
|
+
<Notification
|
|
132
|
+
intent="notice"
|
|
133
|
+
slideDirection="left"
|
|
134
|
+
dismissed={dismissed}
|
|
135
|
+
buttonText="Dismiss"
|
|
136
|
+
buttonPosition="right"
|
|
137
|
+
buttonOnClick={() => setDismissed(true)}
|
|
138
|
+
>
|
|
139
|
+
Your session expires in five minutes.
|
|
140
|
+
</Notification>
|
|
141
|
+
{dismissed && (
|
|
142
|
+
<Button onClick={() => setDismissed(false)} sdsType="primary">
|
|
143
|
+
Reset Notification
|
|
144
|
+
</Button>
|
|
145
|
+
)}
|
|
146
|
+
</div>
|
|
147
|
+
);
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
export default App;
|
|
151
|
+
```
|
|
152
|
+
|
|
153
|
+
### Notification with extra content
|
|
154
|
+
|
|
155
|
+
This example passes more than a single line as `children`. The first line reads as the title, and the element beneath it holds the rest of the message; any component can go there in place of the text.
|
|
156
|
+
|
|
157
|
+
**Example: NotificationWithExtraContent**
|
|
158
|
+
|
|
159
|
+
```tsx
|
|
160
|
+
// Notification whose children carry more than a single line of text
|
|
161
|
+
|
|
162
|
+
import { Notification } from "@czi-sds/components";
|
|
163
|
+
|
|
164
|
+
function App() {
|
|
165
|
+
return (
|
|
166
|
+
<div className="app">
|
|
167
|
+
<Notification intent="positive" slideDirection="left">
|
|
168
|
+
Your export is ready
|
|
169
|
+
<div>
|
|
170
|
+
The file will stay available for 24 hours. Anyone with access to the
|
|
171
|
+
project can download it from the downloads page.
|
|
172
|
+
</div>
|
|
173
|
+
</Notification>
|
|
174
|
+
</div>
|
|
175
|
+
);
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
export default App;
|
|
179
|
+
```
|
|
180
|
+
|
|
181
|
+
### Notification with a custom icon
|
|
182
|
+
|
|
183
|
+
This example replaces the icon that the `intent` would otherwise choose. The `icon` prop takes either an SDS icon name or an element.
|
|
184
|
+
|
|
185
|
+
**Example: NotificationWithACustomIcon**
|
|
186
|
+
|
|
187
|
+
```tsx
|
|
188
|
+
// Replacing the intent's default icon with any SDS icon
|
|
189
|
+
|
|
190
|
+
import { Notification } from "@czi-sds/components";
|
|
191
|
+
|
|
192
|
+
function App() {
|
|
193
|
+
return (
|
|
194
|
+
<div className="app">
|
|
195
|
+
<Notification intent="accent" slideDirection="left" icon="Book">
|
|
196
|
+
Pass an icon name to swap the icon the intent would otherwise pick.
|
|
197
|
+
</Notification>
|
|
198
|
+
</div>
|
|
199
|
+
);
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
export default App;
|
|
203
|
+
```
|
|
204
|
+
|
|
205
|
+
### Notification with auto dismiss
|
|
206
|
+
|
|
207
|
+
This example dismisses itself after four seconds. Pass `true` instead of a number to use the default delay of `8000` milliseconds.
|
|
208
|
+
|
|
209
|
+
**Example: NotificationWithAutoDismiss**
|
|
210
|
+
|
|
211
|
+
```tsx
|
|
212
|
+
// The Notification dismisses itself once the timeout elapses. Remounting it
|
|
213
|
+
// with a new key restarts the countdown.
|
|
214
|
+
|
|
215
|
+
import { useState } from "react";
|
|
216
|
+
import { Button, Notification } from "@czi-sds/components";
|
|
217
|
+
|
|
218
|
+
function App() {
|
|
219
|
+
const [runId, setRunId] = useState(0);
|
|
220
|
+
|
|
221
|
+
return (
|
|
222
|
+
<div className="app">
|
|
223
|
+
<Notification
|
|
224
|
+
key={runId}
|
|
225
|
+
intent="positive"
|
|
226
|
+
slideDirection="left"
|
|
227
|
+
autoDismiss={4000}
|
|
228
|
+
>
|
|
229
|
+
This Notification slides away on its own after four seconds.
|
|
230
|
+
</Notification>
|
|
231
|
+
<Button onClick={() => setRunId((prev) => prev + 1)} sdsType="primary">
|
|
232
|
+
Show again
|
|
233
|
+
</Button>
|
|
234
|
+
</div>
|
|
235
|
+
);
|
|
236
|
+
}
|
|
237
|
+
|
|
238
|
+
export default App;
|
|
239
|
+
```
|
|
240
|
+
|
|
241
|
+
## SDS vs MUI
|
|
242
|
+
|
|
243
|
+
The SDS Notification component is built upon the MUI Alert component (as is the SDS Callout component ), but there are some important differences:
|
|
244
|
+
|
|
245
|
+
- **Color:** SDS's Notification component has its own `intent` prop designed for setting both the color and default icon, and takes the values of `"accent"`, `"info"`, `"negative"`, `"notice"`, or `"positive"`. MUI's Alert instead uses the `severity` prop for this purpose (`severity` can also be used for SDS's Notification, and will take the same values as `intent`; this is not recommended)
|
|
246
|
+
|
|
247
|
+
- **Title and body:** MUI's Alert composes an AlertTitle with the text that follows it. SDS's Notification takes everything as children instead: the first line reads as the title, and any extra content goes in an element beneath it. An AlertTitle is accepted but does not change the style of the text it wraps.
|
|
248
|
+
|
|
249
|
+
- **Closing:** A close button appears in the top right as soon as `onClose` is given, which is what makes a Notification dismissible. The Notification hides itself when that button is clicked, and `dismissed` hides it from the outside. SDS uses MUI's Alert `action` prop for the close button, in case there is a need to further override the behavior.
|
|
250
|
+
|
|
251
|
+
- **Transitions:** SDS's Notification uses the Slide transition component, sliding in and out towards the side named by `slideDirection`.
|
|
252
|
+
|
|
253
|
+
- **Placement:** A Notification is meant to sit above the page rather than in its flow, usually in the top right corner, but it does not place itself. Position it with the surrounding layout, and reach for the Callout when the message belongs in the flow of the page instead.
|
|
254
|
+
|
|
255
|
+
- **Icons:** Like with MUI's Alert, SDS's Notification also shows an icon to the left of the message. It is chosen automatically from the `intent` (see the first bullet) and can be overridden with the `icon` prop, which takes either the name of an SDS icon or a custom SVG element:
|
|
256
|
+
|
|
257
|
+
**React TypeScript**
|
|
258
|
+
|
|
259
|
+
```tsx
|
|
260
|
+
icon="Book"
|
|
261
|
+
icon={<Icon sdsSize="s" sdsIcon="Book" />}
|
|
262
|
+
```
|
|
263
|
+
|
|
264
|
+
Additionally, setting `icon={false}` has no effect, and `iconMapping` does not work to change icons associated to `intent` or `severity`.
|
|
265
|
+
|
|
266
|
+
- **Variants:** The `variant` prop is not supported. Setting `variant="outlined"` adds the colored border but keeps the background color, rather than removing it the way MUI's Alert does.
|
|
267
|
+
|
|
268
|
+
## MUI Documentation
|
|
269
|
+
|
|
270
|
+
Documentation for the underlying MUI Alert component can be found [here](https://mui.com/material-ui/react-alert/).
|
|
271
|
+
|
|
272
|
+
## Props
|
|
273
|
+
|
|
274
|
+
Any custom SDS props and MUI props required for implementation are found on the table below. See the MUI documentation for additional optional props.
|
|
275
|
+
|
|
276
|
+
| Name | Type | Default | Description |
|
|
277
|
+
| ---------------- | -------------------------------------------------------------------- | --------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
278
|
+
| `intent` | `"accent"` \| `"info"` \| `"negative"` \| `"notice"` \| `"positive"` | - | **Required.** Sets both the color of the component and the icon it defaults to. |
|
|
279
|
+
| `slideDirection` | `"left" \| "right"` | `"left"` | **Required.** The side the Notification slides in from and back out towards. The component falls back to `"left"`, but the prop is not optional, so pass it explicitly. |
|
|
280
|
+
| `children` | `ReactNode` | - | The content of the Notification. The first line reads as the title; put anything further in an element of its own beneath it. |
|
|
281
|
+
| `onClose` | `(event: React.SyntheticEvent) => void` | - | Callback fired when the Notification is closed. Passing it is what adds the close button. The Notification hides itself regardless, so use this to sync your own state rather than to perform the hiding. |
|
|
282
|
+
| `dismissed` | `boolean` | - | Hides the Notification when set to `true`. Changing it back to `false` brings the Notification back, which is how a dismissed Notification is restored. |
|
|
283
|
+
| `autoDismiss` | `boolean \| number` | - | Dismisses the Notification on a timer. A number sets the delay in milliseconds, and `true` uses `8000`. Leave it unset to keep the Notification visible until it is dismissed another way. |
|
|
284
|
+
| `buttonText` | `string` | - | The label of the action button shown beneath the content. It only renders alongside `buttonOnClick`. |
|
|
285
|
+
| `buttonOnClick` | `(event: React.SyntheticEvent) => void` | - | Callback fired when the action button is clicked. Passing it is what renders the button, and the Notification does nothing else in response, so dismissing it is up to this handler. |
|
|
286
|
+
| `buttonPosition` | `"left" \| "right"` | `"right"` | Which side of the Notification the action button sits on. |
|
|
287
|
+
| `icon` | `SDSIcon \| React.ReactElement<CustomSVGProps>` | - | Icon displayed to the left of the content, given either as an SDS icon name or as an element. Defaults to the icon for the current `intent`: `"CheckCircle"` for `"positive"`, `"InfoCircle"` for `"info"`, and `"ExclamationMarkCircle"` for `"accent"`, `"notice"`, and `"negative"`. |
|
|
288
|
+
| `sdsIconProps` | `Partial<IconProps>` | - | Props forwarded to the Icon component when `icon` is given as a name. |
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
# Pagination
|
|
2
|
+
|
|
3
|
+
## Source Code
|
|
4
|
+
|
|
5
|
+
The component's source code in the SDS codebase can be found [here](https://github.com/chanzuckerberg/sci-components/blob/main/packages/components/src/core/Pagination/index.tsx).
|
|
6
|
+
|
|
7
|
+
## Import
|
|
8
|
+
|
|
9
|
+
**React TypeScript**
|
|
10
|
+
|
|
11
|
+
```tsx
|
|
12
|
+
import { Pagination } from "@czi-sds/components";
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
## Code examples
|
|
16
|
+
|
|
17
|
+
### **Default Pagination**
|
|
18
|
+
|
|
19
|
+
This example showcases a Pagination component with the minimum required props.
|
|
20
|
+
|
|
21
|
+
**Example: DefaultPagination**
|
|
22
|
+
|
|
23
|
+
```tsx
|
|
24
|
+
import { Pagination } from "@czi-sds/components";
|
|
25
|
+
import { useState } from "react";
|
|
26
|
+
|
|
27
|
+
function App() {
|
|
28
|
+
const [currentPage, setCurrentPage] = useState(1);
|
|
29
|
+
|
|
30
|
+
return (
|
|
31
|
+
<div className="app">
|
|
32
|
+
<Pagination
|
|
33
|
+
pageSize={5}
|
|
34
|
+
onPageChange={(page: number) => {
|
|
35
|
+
setCurrentPage(page);
|
|
36
|
+
}}
|
|
37
|
+
onNextPage={() => setCurrentPage(currentPage + 1)}
|
|
38
|
+
onPreviousPage={() => setCurrentPage(currentPage - 1)}
|
|
39
|
+
totalCount={250}
|
|
40
|
+
siblingCount={2}
|
|
41
|
+
currentPage={currentPage}
|
|
42
|
+
truncateDropdown
|
|
43
|
+
/>
|
|
44
|
+
</div>
|
|
45
|
+
);
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
export default App;
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
## Props
|
|
52
|
+
|
|
53
|
+
Any custom SDS props and MUI props required for implementation are found on the table below. See the MUI documentation for additional optional props.
|
|
54
|
+
|
|
55
|
+
| Name | Type | Default | Description |
|
|
56
|
+
| ------------------ | ------------------------ | --------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
|
|
57
|
+
| `onPageChange` | `(page: number) => void` | - | A callback function triggered when the page number is changed. |
|
|
58
|
+
| `onNextPage` | `() => void` | - | A callback function triggered when the "Next" page button is clicked. |
|
|
59
|
+
| `onPreviousPage` | `() => void` | - | A callback function triggered when the "Previous" page button is clicked. |
|
|
60
|
+
| `currentPage` | `number` | - | Required. The page to mark as current, counted from 1. Pagination keeps no page state of its own. |
|
|
61
|
+
| `pageSize` | `number` | - | Required. How many items fit on a page, which together with `totalCount` gives the number of pages. Must be at least 1; a smaller value throws. |
|
|
62
|
+
| `totalCount` | `number` | - | Required. Total number of items being paged through: the whole set, not the current page. |
|
|
63
|
+
| `siblingCount` | `number` | `1` | How many page numbers to keep on each side of the current page before the rest collapse into an ellipsis. |
|
|
64
|
+
| `sdsStyle` | `"round"` \| `"square"` | `"round"` | Whether the page and chevron targets are circles or rounded squares. |
|
|
65
|
+
| `truncateDropdown` | `boolean` | `true` | When `true` the ellipsis is a menu of the pages it stands for. When `false` it is a disabled placeholder, and those pages can only be reached by stepping through with the chevrons. |
|
|
66
|
+
|
|
67
|
+
Pagination is always controlled: it reports what was clicked and renders whatever `currentPage` you hand back. It renders nothing at all when `currentPage` is `0` or when there are fewer than two pages to show.
|