@czi-sds/mcp 0.2.2 → 0.4.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/data/component-props/Accordion.json +14 -15
- package/data/component-props/Alert.json +2 -44
- package/data/component-props/Autocomplete.json +14 -32
- package/data/component-props/Banner.json +11 -12
- package/data/component-props/Button.json +17 -82
- package/data/component-props/ButtonDropdown.json +26 -0
- package/data/component-props/ButtonIcon.json +4 -60
- package/data/component-props/ButtonToggle.json +2 -66
- package/data/component-props/Callout.json +11 -65
- package/data/component-props/CellBasic.json +28 -56
- package/data/component-props/CellComponent.json +4 -32
- package/data/component-props/CellHeader.json +13 -49
- package/data/component-props/ComplexFilter.json +24 -4
- package/data/component-props/ContentCard.json +66 -2
- package/data/component-props/Dialog.json +26 -0
- package/data/component-props/Dropdown.json +29 -67
- package/data/component-props/DropdownMenu.json +16 -56
- package/data/component-props/HeatmapChart.json +6 -87
- package/data/component-props/Icon.json +3 -8
- package/data/component-props/InputCheckbox.json +5 -53
- package/data/component-props/InputDropdown.json +11 -33
- package/data/component-props/InputRadio.json +5 -53
- package/data/component-props/InputSearch.json +6 -70
- package/data/component-props/InputSlider.json +21 -35
- package/data/component-props/InputText.json +7 -63
- package/data/component-props/InputToggle.json +5 -54
- package/data/component-props/Link.json +18 -0
- package/data/component-props/LoadingIndicator.json +1 -2
- package/data/component-props/MenuItem.json +11 -41
- package/data/component-props/MenuSelect.json +4 -67
- package/data/component-props/NavigationFooter.json +0 -8
- package/data/component-props/NavigationHeader.json +14 -65
- package/data/component-props/NavigationJumpTo.json +0 -40
- package/data/component-props/Notification.json +14 -58
- package/data/component-props/Pagination.json +8 -33
- package/data/component-props/Panel.json +4 -54
- package/data/component-props/SegmentedControl.json +0 -55
- package/data/component-props/TableRow.json +10 -38
- package/data/component-props/Tabs.json +18 -0
- package/data/component-props/Tag.json +10 -56
- package/data/component-props/TagFilter.json +0 -47
- package/data/component-props/Tooltip.json +12 -61
- package/data/component-props/TooltipCondensed.json +18 -0
- package/data/component-props/TooltipTable.json +0 -4
- package/data/zeroheight-cache.json +5195 -0
- package/data/zeroheight-exports/Accordion.md +717 -0
- package/data/zeroheight-exports/Banner.md +599 -0
- package/data/zeroheight-exports/Borders.md +117 -0
- package/data/zeroheight-exports/Buttons.md +2305 -0
- package/data/zeroheight-exports/Callout.md +778 -0
- package/data/zeroheight-exports/Colors.md +632 -0
- package/data/zeroheight-exports/Content-Card.md +161 -0
- package/data/zeroheight-exports/Contributing-to-SDS.md +98 -0
- package/data/zeroheight-exports/Control-Inputs.md +2121 -0
- package/data/zeroheight-exports/Corners.md +111 -0
- package/data/zeroheight-exports/Cover-page.md +3 -0
- package/data/zeroheight-exports/Dialog.md +1191 -0
- package/data/zeroheight-exports/Downloads.md +120 -0
- package/data/zeroheight-exports/Drop-Shadows.md +79 -0
- package/data/zeroheight-exports/Dropdown-Input.md +1180 -0
- package/data/zeroheight-exports/Dropdown-Menu.md +3883 -0
- package/data/zeroheight-exports/Element-Status-Tracker.md +267 -0
- package/data/zeroheight-exports/Field-Inputs.md +984 -0
- package/data/zeroheight-exports/Filters.md +888 -0
- package/data/zeroheight-exports/Getting-Started.md +1159 -0
- package/data/zeroheight-exports/Hero.md +262 -0
- package/data/zeroheight-exports/Icons.md +431 -0
- package/data/zeroheight-exports/Intent.md +46 -0
- package/data/zeroheight-exports/Introduction-to-Bases.md +35 -0
- package/data/zeroheight-exports/Introduction-to-Cells.md +35 -0
- package/data/zeroheight-exports/Introduction-to-DNA.md +35 -0
- package/data/zeroheight-exports/Introduction-to-Genes.md +35 -0
- package/data/zeroheight-exports/Introduction.md +115 -0
- package/data/zeroheight-exports/Link.md +386 -0
- package/data/zeroheight-exports/Lists.md +632 -0
- package/data/zeroheight-exports/Loading-Indicator.md +37 -0
- package/data/zeroheight-exports/Navigation.md +874 -0
- package/data/zeroheight-exports/Notification.md +888 -0
- package/data/zeroheight-exports/Panel.md +978 -0
- package/data/zeroheight-exports/README.md +124 -0
- package/data/zeroheight-exports/Responsive-Design.md +278 -0
- package/data/zeroheight-exports/Search-Input.md +53 -0
- package/data/zeroheight-exports/Search.md +592 -0
- package/data/zeroheight-exports/Segmented-Control.md +584 -0
- package/data/zeroheight-exports/Spacing.md +297 -0
- package/data/zeroheight-exports/Table.md +4944 -0
- package/data/zeroheight-exports/Tabs.md +801 -0
- package/data/zeroheight-exports/Tags.md +1055 -0
- package/data/zeroheight-exports/Text-Link.md +184 -0
- package/data/zeroheight-exports/Theming.md +332 -0
- package/data/zeroheight-exports/Tooltips.md +1580 -0
- package/data/zeroheight-exports/Typography.md +768 -0
- package/dist/stdio.js +193 -93
- package/package.json +4 -4
- package/data/component-props/Chip.json +0 -73
- package/data/component-props/List.json +0 -43
- package/data/component-props/Menu.json +0 -48
- package/data/component-props/Table.json +0 -26
- package/data/component-props-storybook/Accordion-storybook.json +0 -45
- package/data/component-props-storybook/Alert-storybook.json +0 -30
- package/data/component-props-storybook/Autocomplete-storybook.json +0 -67
- package/data/component-props-storybook/Banner-storybook.json +0 -78
- package/data/component-props-storybook/Button-storybook.json +0 -115
- package/data/component-props-storybook/ButtonDropdown-storybook.json +0 -73
- package/data/component-props-storybook/ButtonIcon-storybook.json +0 -60
- package/data/component-props-storybook/ButtonToggle-storybook.json +0 -68
- package/data/component-props-storybook/Callout-storybook.json +0 -90
- package/data/component-props-storybook/CellBasic-storybook.json +0 -138
- package/data/component-props-storybook/CellComponent-storybook.json +0 -48
- package/data/component-props-storybook/CellHeader-storybook.json +0 -71
- package/data/component-props-storybook/Chip-storybook.json +0 -26
- package/data/component-props-storybook/ComplexFilter-storybook.json +0 -60
- package/data/component-props-storybook/ContentCard-storybook.json +0 -175
- package/data/component-props-storybook/Dialog-storybook.json +0 -56
- package/data/component-props-storybook/Dropdown-storybook.json +0 -93
- package/data/component-props-storybook/DropdownMenu-storybook.json +0 -73
- package/data/component-props-storybook/HeatmapChart-storybook.json +0 -55
- package/data/component-props-storybook/Icon-storybook.json +0 -75
- package/data/component-props-storybook/InputCheckbox-storybook.json +0 -57
- package/data/component-props-storybook/InputDropdown-storybook.json +0 -80
- package/data/component-props-storybook/InputRadio-storybook.json +0 -56
- package/data/component-props-storybook/InputSearch-storybook.json +0 -55
- package/data/component-props-storybook/InputSlider-storybook.json +0 -55
- package/data/component-props-storybook/InputText-storybook.json +0 -59
- package/data/component-props-storybook/InputToggle-storybook.json +0 -42
- package/data/component-props-storybook/Link-storybook.json +0 -50
- package/data/component-props-storybook/List-storybook.json +0 -26
- package/data/component-props-storybook/LoadingIndicator-storybook.json +0 -34
- package/data/component-props-storybook/Menu-storybook.json +0 -26
- package/data/component-props-storybook/MenuItem-storybook.json +0 -74
- package/data/component-props-storybook/MenuSelect-storybook.json +0 -38
- package/data/component-props-storybook/NavigationFooter-storybook.json +0 -67
- package/data/component-props-storybook/NavigationHeader-storybook.json +0 -115
- package/data/component-props-storybook/NavigationJumpTo-storybook.json +0 -41
- package/data/component-props-storybook/Notification-storybook.json +0 -89
- package/data/component-props-storybook/Pagination-storybook.json +0 -50
- package/data/component-props-storybook/Panel-storybook.json +0 -52
- package/data/component-props-storybook/SegmentedControl-storybook.json +0 -30
- package/data/component-props-storybook/Table-storybook.json +0 -26
- package/data/component-props-storybook/TableHeader-storybook.json +0 -26
- package/data/component-props-storybook/TableRow-storybook.json +0 -62
- package/data/component-props-storybook/Tabs-storybook.json +0 -45
- package/data/component-props-storybook/Tag-storybook.json +0 -78
- package/data/component-props-storybook/TagFilter-storybook.json +0 -30
- package/data/component-props-storybook/Tooltip-storybook.json +0 -85
- package/data/component-props-storybook/TooltipCondensed-storybook.json +0 -38
- package/data/component-props-storybook/TooltipTable-storybook.json +0 -47
|
@@ -0,0 +1,888 @@
|
|
|
1
|
+
# Notifications
|
|
2
|
+
|
|
3
|
+
Notifications appear outside of the flow of the page to highlight information to the user whether in response to an action they have completed or to bring their attention to important details.
|
|
4
|
+
|
|
5
|
+
## Overview
|
|
6
|
+
|
|
7
|
+
## Notification Variants
|
|
8
|
+
|
|
9
|
+
| Notifications come in two different variants for designers to use depending on the type of information they need to display and whether they want the user to have the ability to manually dismiss them or not. All Notification variants can be set to automatically dismiss after a designated period of time (8 seconds by default). Notifications appear outside of the flow of the page on top of other elements as opposed to Callouts which appear within the page's flow. Follow the usage criteria accompanying each variant as a guide for selecting the correct Notification for any given use case. | | **Jump to variant:** Persistent Dismissible Intent Variations |
|
|
10
|
+
| --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | --- | ------------------------------------------------------------- |
|
|
11
|
+
|
|
12
|
+
---
|
|
13
|
+
|
|
14
|
+
## Notification
|
|
15
|
+
|
|
16
|
+
| | In Figma | | | Meets Accessibility | | | In CZ GEN EPI Codebase |
|
|
17
|
+
| --- | -------- | --- | --- | ------------------- | --- | --- | ---------------------- |
|
|
18
|
+
|
|
19
|
+
### Persistent Notification
|
|
20
|
+
|
|
21
|
+
Use when communicating information that is intended to remain persistent on the screen and is not manually dismissible by the user. It can be set to automatically dismiss after a designated period of time using the `autoDismiss` prop; when set to `true`, the automatic dismissal will occur after 8 milliseconds by default, but can be set to a custom length of time by entering a millisecond value into the prop.
|
|
22
|
+
|
|
23
|
+
A Minimal Button or Text Link can be added to the Notification if additional action from the user is possible or necessary. Most commonly, a Minimal Button with the label "Dismiss" is included to allow users to close out of the Notification. Text Links take users to pages related to the content on the Notification; for example when a user begins building a new tree, a Notification appears alerting them this work has begun that includes a Text Link that navigates them to the tree page for them to view their newly created tree.
|
|
24
|
+
|
|
25
|
+
Relevant components such as Tables (documentation coming soon) or Charts (documentation coming soon), or additional text can be included in the content module block as necessary.
|
|
26
|
+
|
|
27
|
+
Click on each state below to enter inspect view and get details on its code attributes and any global styles it uses.
|
|
28
|
+
|
|
29
|
+
---
|
|
30
|
+
|
|
31
|
+
---
|
|
32
|
+
|
|
33
|
+
---
|
|
34
|
+
|
|
35
|
+
### Dismissible Notification
|
|
36
|
+
|
|
37
|
+
Use when communicating information that is manually dismissible by the user and does not need to remain persistent on the screen. It can be set to automatically dismiss after a designated period of time using the `autoDismiss` prop; when set to `true`, the automatic dismissal will occur after 8 milliseconds by default, but can be set to a custom length of time by entering a millisecond value into the prop.
|
|
38
|
+
|
|
39
|
+
A Minimal Button can be added to the Notification if additional action from the user is possible or necessary. Relevant components such as Tables (documentation coming soon) or Charts (documentation coming soon), or additional text can be included in the content module block as necessary.
|
|
40
|
+
|
|
41
|
+
Click on each state below to enter inspect view and get details on its code attributes and any global styles it uses.
|
|
42
|
+
|
|
43
|
+
|
|
44
|
+
|
|
45
|
+
---
|
|
46
|
+
|
|
47
|
+
---
|
|
48
|
+
|
|
49
|
+
---
|
|
50
|
+
|
|
51
|
+
---
|
|
52
|
+
|
|
53
|
+
### Notification Spacing
|
|
54
|
+
|
|
55
|
+
These rules establish how much margin should exist between and around elements. Because Notifications are positioned in the top-right corner of the UI on top of other elements, the top and right spacing rules below indicate the distance between the component and the edges of the browser window.
|
|
56
|
+
|
|
57
|
+
---
|
|
58
|
+
|
|
59
|
+
### Intent Variations
|
|
60
|
+
|
|
61
|
+
There are four different intents that all Notification variants can communicate—Info, Error, Success, and Warning—indicated with the use of color and iconography and selected using the `intent` prop.
|
|
62
|
+
|
|
63
|
+
Each intent is demonstrated below using the Persistent Notification for reference. Regardless of variant, the colors and icons used are the same:
|
|
64
|
+
|
|
65
|
+
| **Error** | **Info** |
|
|
66
|
+
| --------- | -------- |
|
|
67
|
+
|
|
68
|
+
| **Success** | **Warning** |
|
|
69
|
+
| ----------- | ----------- |
|
|
70
|
+
|
|
71
|
+
## Code
|
|
72
|
+
|
|
73
|
+
## Notification Component
|
|
74
|
+
|
|
75
|
+
| Below you will find an interactive Storybook iframe for Notifications. Tabs within each iframe provide a different set of tools: The Controls tab allows you to see and adjust all available props. The Actions tab shows you data displayed by event handler arguments. | | **Jump to component:** Notification |
|
|
76
|
+
| ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | --- | ----------------------------------- |
|
|
77
|
+
|
|
78
|
+
---
|
|
79
|
+
|
|
80
|
+
> This component appears as it is in the default SDS codebase. Once imported into the CZ GEN EPI codebase, use a theme file to enable the CZ GEN EPI visual appearance customization.
|
|
81
|
+
|
|
82
|
+
### Notification
|
|
83
|
+
|
|
84
|
+
Storybook
|
|
85
|
+
|
|
86
|
+
|
|
87
|
+
|
|
88
|
+
---
|
|
89
|
+
|
|
90
|
+
Notifications appear outside of the flow of the page to highlight information to the user whether in response to an action they have completed or to bring their attention to important details.
|
|
91
|
+
|
|
92
|
+
## Overview
|
|
93
|
+
|
|
94
|
+
## Notification Variants
|
|
95
|
+
|
|
96
|
+
| Notifications come in two different variants for designers to use depending on the type of information they need to display and whether they want the user to have the ability to manually dismiss them or not. All Notification variants can be set to automatically dismiss after a designated period of time (8 seconds by default). Notifications appear outside of the flow of the page on top of other elements as opposed to Callouts which appear within the page's flow. Follow the usage criteria accompanying each variant as a guide for selecting the correct Notification for any given use case. | | **Jump to variant:** Persistent Dismissible Intent Variations |
|
|
97
|
+
| --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | --- | ------------------------------------------------------------- |
|
|
98
|
+
|
|
99
|
+
---
|
|
100
|
+
|
|
101
|
+
## Notification
|
|
102
|
+
|
|
103
|
+
| | In Figma | | | Meets Accessibility | | | In CZ ID Codebase |
|
|
104
|
+
| --- | -------- | --- | --- | ------------------- | --- | --- | ----------------- |
|
|
105
|
+
|
|
106
|
+
### Persistent Notification
|
|
107
|
+
|
|
108
|
+
Use when communicating information that is intended to remain persistent on the screen and is not manually dismissible by the user. It can be set to automatically dismiss after a designated period of time using the `autoDismiss` prop; when set to `true`, the automatic dismissal will occur after 8 milliseconds by default, but can be set to a custom length of time by entering a millisecond value into the prop.
|
|
109
|
+
|
|
110
|
+
A Minimal Button can be added to the Notification if additional action from the user is possible or necessary. Relevant components such as Tables (documentation coming soon) or Charts (documentation coming soon), or additional text can be included in the content module block as necessary.
|
|
111
|
+
|
|
112
|
+
Click on each state below to enter inspect view and get details on its code attributes and any global styles it uses.
|
|
113
|
+
|
|
114
|
+
---
|
|
115
|
+
|
|
116
|
+
---
|
|
117
|
+
|
|
118
|
+
---
|
|
119
|
+
|
|
120
|
+
|
|
121
|
+
|
|
122
|
+
### Dismissible Notification
|
|
123
|
+
|
|
124
|
+
Use when communicating information that is manually dismissible by the user and does not need to remain persistent on the screen. It can be set to automatically dismiss after a designated period of time using the `autoDismiss` prop; when set to `true`, the automatic dismissal will occur after 8 milliseconds by default, but can be set to a custom length of time by entering a millisecond value into the prop.
|
|
125
|
+
|
|
126
|
+
A Minimal Button can be added to the Notification if additional action from the user is possible or necessary. Relevant components such as Tables (documentation coming soon) or Charts (documentation coming soon), or additional text can be included in the content module block as necessary.
|
|
127
|
+
|
|
128
|
+
Click on each state below to enter inspect view and get details on its code attributes and any global styles it uses.
|
|
129
|
+
|
|
130
|
+
|
|
131
|
+
|
|
132
|
+
---
|
|
133
|
+
|
|
134
|
+
---
|
|
135
|
+
|
|
136
|
+
---
|
|
137
|
+
|
|
138
|
+
---
|
|
139
|
+
|
|
140
|
+
### Notification Spacing
|
|
141
|
+
|
|
142
|
+
These rules establish how much margin should exist between and around elements. Because Notifications are positioned in the top-right corner of the UI on top of other elements, the top and right spacing rules below indicate the distance between the component and the edges of the browser window.
|
|
143
|
+
|
|
144
|
+
---
|
|
145
|
+
|
|
146
|
+
### Intent Variations
|
|
147
|
+
|
|
148
|
+
There are four different intents that all Notification variants can communicate—Info, Error, Success, and Warning—indicated with the use of color and iconography and selected using the `intent` prop.
|
|
149
|
+
|
|
150
|
+
Each intent is demonstrated below using the Persistent Notification for reference. Regardless of variant, the colors and icons used are the same:
|
|
151
|
+
|
|
152
|
+
| **Error** | **Info** |
|
|
153
|
+
| --------- | -------- |
|
|
154
|
+
|
|
155
|
+
| **Success** | **Warning** |
|
|
156
|
+
| ----------- | ----------- |
|
|
157
|
+
|
|
158
|
+
## Code
|
|
159
|
+
|
|
160
|
+
## Notification Component
|
|
161
|
+
|
|
162
|
+
| Below you will find an interactive Storybook iframe for Notifications. Tabs within each iframe provide a different set of tools: The Controls tab allows you to see and adjust all available props. The Actions tab shows you data displayed by event handler arguments. | | **Jump to component:** Notification |
|
|
163
|
+
| ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | --- | ----------------------------------- |
|
|
164
|
+
|
|
165
|
+
---
|
|
166
|
+
|
|
167
|
+
### Notification
|
|
168
|
+
|
|
169
|
+
Storybook
|
|
170
|
+
|
|
171
|
+
|
|
172
|
+
|
|
173
|
+
---
|
|
174
|
+
|
|
175
|
+
Notifications appear outside of the flow of the page to highlight information to the user whether in response to an action they have completed or to bring their attention to important details.
|
|
176
|
+
|
|
177
|
+
## Guidelines
|
|
178
|
+
|
|
179
|
+
## Overview
|
|
180
|
+
|
|
181
|
+
| | In Figma | | | Meets Accessibility | | | In Code |
|
|
182
|
+
| --- | -------- | --- | --- | ------------------- | --- | --- | ------- |
|
|
183
|
+
|
|
184
|
+
### Notification Variants
|
|
185
|
+
|
|
186
|
+
Notifications come in two different variants distinguished by whether users to have the ability to manually dismiss them or not. All Notification variants can be set to automatically dismiss after a designated period of time (8 seconds by default).
|
|
187
|
+
|
|
188
|
+
Notifications appear outside of the flow of the page on top of other elements as opposed to Callouts which appear within the page's flow.
|
|
189
|
+
|
|
190
|
+
---
|
|
191
|
+
|
|
192
|
+
### Live Instance
|
|
193
|
+
|
|
194
|
+
Interact with the live instance below and adjust the available props to better conceptualize how it will appear in product:
|
|
195
|
+
|
|
196
|
+
Default
|
|
197
|
+
|
|
198
|
+
---
|
|
199
|
+
|
|
200
|
+
### Notification – Persistent
|
|
201
|
+
|
|
202
|
+
Use when communicating information that is intended to remain persistent on the screen and is not manually dismissible by the user.
|
|
203
|
+
|
|
204
|
+
A Minimal Button can be added to the Notification if additional action from the user is possible or necessary; the Button is positioned to the right by default, but can optionally be positioned to the left. Relevant components or additional text can be included in the content module block as necessary.
|
|
205
|
+
|
|
206
|
+
| Default | Default + Button | Default + Content Module | Default + Content Module + Button |
|
|
207
|
+
| ------- | ---------------- | ------------------------ | --------------------------------- |
|
|
208
|
+
|
|
209
|
+
---
|
|
210
|
+
|
|
211
|
+
### Notification – Dismissible
|
|
212
|
+
|
|
213
|
+
Use when communicating information that is manually dismissible by the user and does not need to remain persistent on the screen.
|
|
214
|
+
|
|
215
|
+
A Minimal Button can be added to the Notification if additional action from the user is possible or necessary; the Button is positioned to the right by default, but can optionally be positioned to the left. Relevant components or additional text can be included in the content module block as necessary.
|
|
216
|
+
|
|
217
|
+
| Default | Default + Button | Default + Content Module | Default + Content Module + Button |
|
|
218
|
+
| ------- | ---------------- | ------------------------ | --------------------------------- |
|
|
219
|
+
|
|
220
|
+
---
|
|
221
|
+
|
|
222
|
+
### Notification Spacing
|
|
223
|
+
|
|
224
|
+
These rules establish how much margin should exist between and around elements.
|
|
225
|
+
|
|
226
|
+
---
|
|
227
|
+
|
|
228
|
+
### Intent Variations
|
|
229
|
+
|
|
230
|
+
There are four different intents that all Notifications can communicate—Info, Negative, Notice, and Positive—indicated with the use of color and iconography.
|
|
231
|
+
|
|
232
|
+
Each intent is demonstrated below using the Persistent variant for reference. Regardless of variant, the colors and icons used are the same:
|
|
233
|
+
|
|
234
|
+
| Info | Negative | Notice | Positive |
|
|
235
|
+
| ---- | -------- | ------ | -------- |
|
|
236
|
+
|
|
237
|
+
## Code
|
|
238
|
+
|
|
239
|
+
> **Note:** The code examples below must install dependencies before displaying and may take extra time to load
|
|
240
|
+
|
|
241
|
+
## Notification
|
|
242
|
+
|
|
243
|
+
### SDS Source Code
|
|
244
|
+
|
|
245
|
+
The component's source code in the SDS codebase can be found here.
|
|
246
|
+
|
|
247
|
+
### SDS vs MUI
|
|
248
|
+
|
|
249
|
+
The SDS `Notification` component is built upon the MUI `Alert` component (as is the SDS `Callout` component), but has some notable differences:
|
|
250
|
+
|
|
251
|
+
- **Color:** SDS's `Notification` component has its own `intent` prop designed for setting both the color and default icon, and takes the values of `"info"`, `"error"`, `"success"`, or `"warning"`. MUI's `Alert` instead uses the `severity` prop for this purpose (although `severity` can also be used for SDS's `Notification`, and will take the same values as `intent`, this is not recommended)
|
|
252
|
+
- **Title:** In MUI's `Alert` component, an `AlertTitle` component (that holds the title text) is added within the `Alert` component. However, SDS's `Notification` doesn't need the `AlertTitle` component, although it can take one; doing so won't change the style of the text it wraps. Instead of setting the `Notification`'s title with `AlertTitle`, wrap the title text directly within the `Notification` component, and append any additional (non-title) text using the `extraContent` variable
|
|
253
|
+
- **Transition:** The SDS `Notification` component is set up by default to use the `Slide` component, with `"left"` as its default value; alternatively, it accepts `"right"` as a value
|
|
254
|
+
- **Icon:** Like with MUI's `Alert`, SDS's `Notification` also shows an icon to the left of the title text; this can be changed manually (it also changes automatically based on the `intent` setting; see first bullet). The format for setting the `icon` prop for SDS's `Notification` is slightly different than for MUI in that it invokes the `Icon` component:
|
|
255
|
+
|
|
256
|
+
`icon={<Icon sdsSize="l" sdsIcon="download"` `sdsType="static"` `/>`
|
|
257
|
+
|
|
258
|
+
Additionally, the `iconMapping` prop does not work to change icons associated to `intent` or `severity` for SDS's `Notification`.
|
|
259
|
+
|
|
260
|
+
- **Variant\*\***:\*\* SDS does not support the `variant` prop. However, MUI's `Alert` does, and offers two options: `outlined`, which removes the background color but adds a colored border to the alert, and `filled`, which changes the background color to a more saturated color of the same hue. If the `variant` prop is used in SDS's `Notification` , only `variant="outline"` will have an affect (it will add the colored border, but will also maintain the original background color, whereas MUI's `Alert` removes the background color with this setting)
|
|
261
|
+
|
|
262
|
+
### MUI Documentation
|
|
263
|
+
|
|
264
|
+
Documentation for the underlying MUI `Alert` component can be found here.
|
|
265
|
+
|
|
266
|
+
### Props
|
|
267
|
+
|
|
268
|
+
Any custom SDS props and MUI props required for implementation are found on the table below. See the MUI documentation for additional optional props.
|
|
269
|
+
|
|
270
|
+
| Name | Type | Default | Description |
|
|
271
|
+
| ---------------- | ----------------------------------------------- | ---------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------ | -------------------------------------------------- |
|
|
272
|
+
| `autoDismiss` | `bool | number` | `8000 ms` | Determines the auto-dismiss behavior of the component. If set to `true`, the notification will automatically dismiss after `8000 ms`. If set to a number, it specifies the exact duration in milliseconds for auto-dismiss. If set to `false`, the notification will not auto-dismiss. |
|
|
273
|
+
| `buttonOnClick` | `(event: React.SyntheticEvent) => void` | `-` | A callback function to be executed when the button within the notification is clicked. |
|
|
274
|
+
| `buttonText` | `string` | `-` | The text displayed on the button within the notification. |
|
|
275
|
+
| `dismissed` | `bool` | `-` | Controls the dismissed state of the notification. When set to true, the notification will be hidden. You can use this prop to programmatically dismiss the notification. |
|
|
276
|
+
| `onClose` | `function(event: React.SyntheticEvent) => void` | `-` | Callback fired when the component requests to be closed. When provided and no action prop is set, a close icon button is displayed that triggers the callback when clicked. |
|
|
277
|
+
| `slideDirection` | `"left" | "right"` | `"left"` | Specifies the direction from which the notification will slide into view when it appears. |
|
|
278
|
+
| `intent` | `"info"` ` | "negative"` ` | "positive"` ` | "notice"` | `"positive"` | Defines the intent or purpose of the notification. |
|
|
279
|
+
| `icon` | `ReactNode | Partial<SdsIconProps>` | `-` | icon displayed to the left of the `Notification` title. |
|
|
280
|
+
| `sdsIconProps` | `Partial<SdsIconProps>` | `-` | The props for the icon if an SDS icon is used. |
|
|
281
|
+
|
|
282
|
+
### Code examples
|
|
283
|
+
|
|
284
|
+
#### Default Notification
|
|
285
|
+
|
|
286
|
+
This example demonstrates the most basic usage of the `Notification` component with default props.
|
|
287
|
+
|
|
288
|
+
**/styles.css**
|
|
289
|
+
|
|
290
|
+
```css
|
|
291
|
+
body {
|
|
292
|
+
font-size: 13px;
|
|
293
|
+
font-weight: 400;
|
|
294
|
+
letter-spacing: 0.08px;
|
|
295
|
+
line-height: 20px;
|
|
296
|
+
text-transform: none;
|
|
297
|
+
font-family: "Inter", sans-serif;
|
|
298
|
+
}
|
|
299
|
+
|
|
300
|
+
h1 {
|
|
301
|
+
font-size: 1.5rem;
|
|
302
|
+
}
|
|
303
|
+
|
|
304
|
+
.app {
|
|
305
|
+
padding: 20px;
|
|
306
|
+
}
|
|
307
|
+
```
|
|
308
|
+
|
|
309
|
+
**tsconfig.json**
|
|
310
|
+
|
|
311
|
+
```json
|
|
312
|
+
{
|
|
313
|
+
"include": ["./**/*"],
|
|
314
|
+
"compilerOptions": {
|
|
315
|
+
"strict": true,
|
|
316
|
+
"esModuleInterop": true,
|
|
317
|
+
"lib": ["dom", "es2015"],
|
|
318
|
+
"jsx": "react-jsx"
|
|
319
|
+
}
|
|
320
|
+
}
|
|
321
|
+
```
|
|
322
|
+
|
|
323
|
+
**/App.tsx**
|
|
324
|
+
|
|
325
|
+
```tsx
|
|
326
|
+
// Most minimal Notification (just has the basic requirements)
|
|
327
|
+
|
|
328
|
+
import { Notification } from "@czi-sds/components";
|
|
329
|
+
import "./styles.css";
|
|
330
|
+
|
|
331
|
+
function App() {
|
|
332
|
+
return (
|
|
333
|
+
<div className="app">
|
|
334
|
+
<Notification>
|
|
335
|
+
The Notification component has been rendered successfully!
|
|
336
|
+
</Notification>
|
|
337
|
+
</div>
|
|
338
|
+
);
|
|
339
|
+
}
|
|
340
|
+
|
|
341
|
+
export default App;
|
|
342
|
+
```
|
|
343
|
+
|
|
344
|
+
**/index.tsx**
|
|
345
|
+
|
|
346
|
+
```tsx
|
|
347
|
+
import React from "react";
|
|
348
|
+
import { createRoot } from "react-dom/client";
|
|
349
|
+
import { ThemeProvider as EmotionThemeProvider } from "@emotion/react";
|
|
350
|
+
import { StyledEngineProvider, ThemeProvider } from "@mui/material/styles";
|
|
351
|
+
import { Theme } from "@czi-sds/components";
|
|
352
|
+
import CssBaseline from "@mui/material/CssBaseline";
|
|
353
|
+
import useMediaQuery from "@mui/material/useMediaQuery";
|
|
354
|
+
|
|
355
|
+
import App from "./App";
|
|
356
|
+
|
|
357
|
+
const container = document.getElementById("root");
|
|
358
|
+
const root = createRoot(container!);
|
|
359
|
+
|
|
360
|
+
const RootApp = () => {
|
|
361
|
+
const prefersDarkMode = useMediaQuery("(prefers-color-scheme: dark)");
|
|
362
|
+
const theme = prefersDarkMode ? Theme("dark") : Theme("light");
|
|
363
|
+
|
|
364
|
+
return (
|
|
365
|
+
<StyledEngineProvider injectFirst>
|
|
366
|
+
<ThemeProvider theme={theme}>
|
|
367
|
+
<EmotionThemeProvider theme={theme}>
|
|
368
|
+
<CssBaseline />
|
|
369
|
+
<App />
|
|
370
|
+
</EmotionThemeProvider>
|
|
371
|
+
</ThemeProvider>
|
|
372
|
+
</StyledEngineProvider>
|
|
373
|
+
);
|
|
374
|
+
};
|
|
375
|
+
|
|
376
|
+
root.render(
|
|
377
|
+
<React.StrictMode>
|
|
378
|
+
<RootApp />
|
|
379
|
+
</React.StrictMode>
|
|
380
|
+
);
|
|
381
|
+
```
|
|
382
|
+
|
|
383
|
+
**/public/index.html**
|
|
384
|
+
|
|
385
|
+
```html
|
|
386
|
+
<!doctype html>
|
|
387
|
+
<html lang="en">
|
|
388
|
+
<head>
|
|
389
|
+
<meta charset="UTF-8" />
|
|
390
|
+
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
|
391
|
+
<title>Notification</title>
|
|
392
|
+
<link rel="preconnect" href="https://fonts.googleapis.com" />
|
|
393
|
+
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin />
|
|
394
|
+
<link
|
|
395
|
+
href="https://fonts.googleapis.com/css2?family=Inter:wght@400;600&display=swap"
|
|
396
|
+
rel="stylesheet"
|
|
397
|
+
/>
|
|
398
|
+
<link
|
|
399
|
+
href="https://fonts.googleapis.com/css2?family=IBM+Plex+Mono:wght@400;600&display=swap"
|
|
400
|
+
rel="stylesheet"
|
|
401
|
+
/>
|
|
402
|
+
</head>
|
|
403
|
+
<body>
|
|
404
|
+
<div id="root"></div>
|
|
405
|
+
</body>
|
|
406
|
+
</html>
|
|
407
|
+
```
|
|
408
|
+
|
|
409
|
+
**/package.json**
|
|
410
|
+
|
|
411
|
+
```json
|
|
412
|
+
{
|
|
413
|
+
"dependencies": {
|
|
414
|
+
"react": "^18.0.0",
|
|
415
|
+
"react-dom": "^18.0.0",
|
|
416
|
+
"react-scripts": "^4.0.0"
|
|
417
|
+
},
|
|
418
|
+
"devDependencies": {
|
|
419
|
+
"@types/react": "^18.0.0",
|
|
420
|
+
"@types/react-dom": "^18.0.0",
|
|
421
|
+
"typescript": "^4.0.0"
|
|
422
|
+
},
|
|
423
|
+
"main": "/index.tsx"
|
|
424
|
+
}
|
|
425
|
+
```
|
|
426
|
+
|
|
427
|
+
---
|
|
428
|
+
|
|
429
|
+
#### Notification component with additional text beyond the title
|
|
430
|
+
|
|
431
|
+
In this example, the `Notification` component is utilized to display more information than just a title. It illustrates how to include additional text content within the notification to provide users with more context or details about the notification's purpose.
|
|
432
|
+
|
|
433
|
+
**/styles.css**
|
|
434
|
+
|
|
435
|
+
```css
|
|
436
|
+
body {
|
|
437
|
+
font-size: 13px;
|
|
438
|
+
font-weight: 400;
|
|
439
|
+
letter-spacing: 0.08px;
|
|
440
|
+
line-height: 20px;
|
|
441
|
+
text-transform: none;
|
|
442
|
+
font-family: "Inter", sans-serif;
|
|
443
|
+
}
|
|
444
|
+
|
|
445
|
+
h1 {
|
|
446
|
+
font-size: 1.5rem;
|
|
447
|
+
}
|
|
448
|
+
|
|
449
|
+
.app {
|
|
450
|
+
padding: 20px;
|
|
451
|
+
}
|
|
452
|
+
```
|
|
453
|
+
|
|
454
|
+
**tsconfig.json**
|
|
455
|
+
|
|
456
|
+
```json
|
|
457
|
+
{
|
|
458
|
+
"include": ["./**/*"],
|
|
459
|
+
"compilerOptions": {
|
|
460
|
+
"strict": true,
|
|
461
|
+
"esModuleInterop": true,
|
|
462
|
+
"lib": ["dom", "es2015"],
|
|
463
|
+
"jsx": "react-jsx"
|
|
464
|
+
}
|
|
465
|
+
}
|
|
466
|
+
```
|
|
467
|
+
|
|
468
|
+
**/App.tsx**
|
|
469
|
+
|
|
470
|
+
```tsx
|
|
471
|
+
import { Notification } from "@czi-sds/components";
|
|
472
|
+
import "./styles.css";
|
|
473
|
+
|
|
474
|
+
function App() {
|
|
475
|
+
return (
|
|
476
|
+
<div className="app">
|
|
477
|
+
<Notification>
|
|
478
|
+
Notification Title
|
|
479
|
+
<div>
|
|
480
|
+
Lorem ipsum, dolor sit amet consectetur adipisicing elit. Amet eveniet
|
|
481
|
+
sapiente, officiis aut possimus suscipit assumenda non?
|
|
482
|
+
</div>
|
|
483
|
+
</Notification>
|
|
484
|
+
</div>
|
|
485
|
+
);
|
|
486
|
+
}
|
|
487
|
+
|
|
488
|
+
export default App;
|
|
489
|
+
```
|
|
490
|
+
|
|
491
|
+
**/index.tsx**
|
|
492
|
+
|
|
493
|
+
```tsx
|
|
494
|
+
import React from "react";
|
|
495
|
+
import { createRoot } from "react-dom/client";
|
|
496
|
+
import { ThemeProvider as EmotionThemeProvider } from "@emotion/react";
|
|
497
|
+
import { StyledEngineProvider, ThemeProvider } from "@mui/material/styles";
|
|
498
|
+
import { Theme } from "@czi-sds/components";
|
|
499
|
+
import CssBaseline from "@mui/material/CssBaseline";
|
|
500
|
+
import useMediaQuery from "@mui/material/useMediaQuery";
|
|
501
|
+
|
|
502
|
+
import App from "./App";
|
|
503
|
+
|
|
504
|
+
const container = document.getElementById("root");
|
|
505
|
+
const root = createRoot(container!);
|
|
506
|
+
|
|
507
|
+
const RootApp = () => {
|
|
508
|
+
const prefersDarkMode = useMediaQuery("(prefers-color-scheme: dark)");
|
|
509
|
+
const theme = prefersDarkMode ? Theme("dark") : Theme("light");
|
|
510
|
+
|
|
511
|
+
return (
|
|
512
|
+
<StyledEngineProvider injectFirst>
|
|
513
|
+
<ThemeProvider theme={theme}>
|
|
514
|
+
<EmotionThemeProvider theme={theme}>
|
|
515
|
+
<CssBaseline />
|
|
516
|
+
<App />
|
|
517
|
+
</EmotionThemeProvider>
|
|
518
|
+
</ThemeProvider>
|
|
519
|
+
</StyledEngineProvider>
|
|
520
|
+
);
|
|
521
|
+
};
|
|
522
|
+
|
|
523
|
+
root.render(
|
|
524
|
+
<React.StrictMode>
|
|
525
|
+
<RootApp />
|
|
526
|
+
</React.StrictMode>
|
|
527
|
+
);
|
|
528
|
+
```
|
|
529
|
+
|
|
530
|
+
**/public/index.html**
|
|
531
|
+
|
|
532
|
+
```html
|
|
533
|
+
<!doctype html>
|
|
534
|
+
<html lang="en">
|
|
535
|
+
<head>
|
|
536
|
+
<meta charset="UTF-8" />
|
|
537
|
+
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
|
538
|
+
<title>Notification</title>
|
|
539
|
+
<link rel="preconnect" href="https://fonts.googleapis.com" />
|
|
540
|
+
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin />
|
|
541
|
+
<link
|
|
542
|
+
href="https://fonts.googleapis.com/css2?family=Inter:wght@400;600&display=swap"
|
|
543
|
+
rel="stylesheet"
|
|
544
|
+
/>
|
|
545
|
+
<link
|
|
546
|
+
href="https://fonts.googleapis.com/css2?family=IBM+Plex+Mono:wght@400;600&display=swap"
|
|
547
|
+
rel="stylesheet"
|
|
548
|
+
/>
|
|
549
|
+
</head>
|
|
550
|
+
<body>
|
|
551
|
+
<div id="root"></div>
|
|
552
|
+
</body>
|
|
553
|
+
</html>
|
|
554
|
+
```
|
|
555
|
+
|
|
556
|
+
**/package.json**
|
|
557
|
+
|
|
558
|
+
```json
|
|
559
|
+
{
|
|
560
|
+
"dependencies": {
|
|
561
|
+
"react": "^18.0.0",
|
|
562
|
+
"react-dom": "^18.0.0",
|
|
563
|
+
"react-scripts": "^4.0.0"
|
|
564
|
+
},
|
|
565
|
+
"devDependencies": {
|
|
566
|
+
"@types/react": "^18.0.0",
|
|
567
|
+
"@types/react-dom": "^18.0.0",
|
|
568
|
+
"typescript": "^4.0.0"
|
|
569
|
+
},
|
|
570
|
+
"main": "/index.tsx"
|
|
571
|
+
}
|
|
572
|
+
```
|
|
573
|
+
|
|
574
|
+
---
|
|
575
|
+
|
|
576
|
+
#### Dismissible Notification
|
|
577
|
+
|
|
578
|
+
The dismissible `Notification` component grants users the convenience of dismissing it on their terms. It features a close `ButtonIcon` positioned in the upper-right corner, delivering a familiar interaction pattern for users to effortlessly remove the notification from view. Furthermore, the `onClose` prop empowers developers to define custom actions triggered when the notification is closed.
|
|
579
|
+
|
|
580
|
+
**/styles.css**
|
|
581
|
+
|
|
582
|
+
```css
|
|
583
|
+
body {
|
|
584
|
+
font-size: 13px;
|
|
585
|
+
font-weight: 400;
|
|
586
|
+
letter-spacing: 0.08px;
|
|
587
|
+
line-height: 20px;
|
|
588
|
+
text-transform: none;
|
|
589
|
+
font-family: "Inter", sans-serif;
|
|
590
|
+
}
|
|
591
|
+
|
|
592
|
+
h1 {
|
|
593
|
+
font-size: 1.5rem;
|
|
594
|
+
}
|
|
595
|
+
|
|
596
|
+
.app {
|
|
597
|
+
padding: 20px;
|
|
598
|
+
}
|
|
599
|
+
```
|
|
600
|
+
|
|
601
|
+
**tsconfig.json**
|
|
602
|
+
|
|
603
|
+
```json
|
|
604
|
+
{
|
|
605
|
+
"include": ["./**/*"],
|
|
606
|
+
"compilerOptions": {
|
|
607
|
+
"strict": true,
|
|
608
|
+
"esModuleInterop": true,
|
|
609
|
+
"lib": ["dom", "es2015"],
|
|
610
|
+
"jsx": "react-jsx"
|
|
611
|
+
}
|
|
612
|
+
}
|
|
613
|
+
```
|
|
614
|
+
|
|
615
|
+
**/App.tsx**
|
|
616
|
+
|
|
617
|
+
```tsx
|
|
618
|
+
import { Notification } from "@czi-sds/components";
|
|
619
|
+
import "./styles.css";
|
|
620
|
+
|
|
621
|
+
function App() {
|
|
622
|
+
return (
|
|
623
|
+
<div className="app">
|
|
624
|
+
<Notification
|
|
625
|
+
onClose={(event) => {
|
|
626
|
+
console.log("Notification closed!");
|
|
627
|
+
}}
|
|
628
|
+
>
|
|
629
|
+
Notification Title
|
|
630
|
+
<div>
|
|
631
|
+
Lorem ipsum, dolor sit amet consectetur adipisicing elit. Amet eveniet
|
|
632
|
+
sapiente, officiis aut possimus suscipit assumenda non?
|
|
633
|
+
</div>
|
|
634
|
+
</Notification>
|
|
635
|
+
</div>
|
|
636
|
+
);
|
|
637
|
+
}
|
|
638
|
+
|
|
639
|
+
export default App;
|
|
640
|
+
```
|
|
641
|
+
|
|
642
|
+
**/index.tsx**
|
|
643
|
+
|
|
644
|
+
```tsx
|
|
645
|
+
import React from "react";
|
|
646
|
+
import { createRoot } from "react-dom/client";
|
|
647
|
+
import { ThemeProvider as EmotionThemeProvider } from "@emotion/react";
|
|
648
|
+
import { StyledEngineProvider, ThemeProvider } from "@mui/material/styles";
|
|
649
|
+
import { Theme } from "@czi-sds/components";
|
|
650
|
+
import CssBaseline from "@mui/material/CssBaseline";
|
|
651
|
+
import useMediaQuery from "@mui/material/useMediaQuery";
|
|
652
|
+
|
|
653
|
+
import App from "./App";
|
|
654
|
+
|
|
655
|
+
const container = document.getElementById("root");
|
|
656
|
+
const root = createRoot(container!);
|
|
657
|
+
|
|
658
|
+
const RootApp = () => {
|
|
659
|
+
const prefersDarkMode = useMediaQuery("(prefers-color-scheme: dark)");
|
|
660
|
+
const theme = prefersDarkMode ? Theme("dark") : Theme("light");
|
|
661
|
+
|
|
662
|
+
return (
|
|
663
|
+
<StyledEngineProvider injectFirst>
|
|
664
|
+
<ThemeProvider theme={theme}>
|
|
665
|
+
<EmotionThemeProvider theme={theme}>
|
|
666
|
+
<CssBaseline />
|
|
667
|
+
<App />
|
|
668
|
+
</EmotionThemeProvider>
|
|
669
|
+
</ThemeProvider>
|
|
670
|
+
</StyledEngineProvider>
|
|
671
|
+
);
|
|
672
|
+
};
|
|
673
|
+
|
|
674
|
+
root.render(
|
|
675
|
+
<React.StrictMode>
|
|
676
|
+
<RootApp />
|
|
677
|
+
</React.StrictMode>
|
|
678
|
+
);
|
|
679
|
+
```
|
|
680
|
+
|
|
681
|
+
**/public/index.html**
|
|
682
|
+
|
|
683
|
+
```html
|
|
684
|
+
<!doctype html>
|
|
685
|
+
<html lang="en">
|
|
686
|
+
<head>
|
|
687
|
+
<meta charset="UTF-8" />
|
|
688
|
+
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
|
689
|
+
<title>Notification</title>
|
|
690
|
+
<link rel="preconnect" href="https://fonts.googleapis.com" />
|
|
691
|
+
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin />
|
|
692
|
+
<link
|
|
693
|
+
href="https://fonts.googleapis.com/css2?family=Inter:wght@400;600&display=swap"
|
|
694
|
+
rel="stylesheet"
|
|
695
|
+
/>
|
|
696
|
+
<link
|
|
697
|
+
href="https://fonts.googleapis.com/css2?family=IBM+Plex+Mono:wght@400;600&display=swap"
|
|
698
|
+
rel="stylesheet"
|
|
699
|
+
/>
|
|
700
|
+
</head>
|
|
701
|
+
<body>
|
|
702
|
+
<div id="root"></div>
|
|
703
|
+
</body>
|
|
704
|
+
</html>
|
|
705
|
+
```
|
|
706
|
+
|
|
707
|
+
**/package.json**
|
|
708
|
+
|
|
709
|
+
```json
|
|
710
|
+
{
|
|
711
|
+
"dependencies": {
|
|
712
|
+
"react": "^18.0.0",
|
|
713
|
+
"react-dom": "^18.0.0",
|
|
714
|
+
"react-scripts": "^4.0.0"
|
|
715
|
+
},
|
|
716
|
+
"devDependencies": {
|
|
717
|
+
"@types/react": "^18.0.0",
|
|
718
|
+
"@types/react-dom": "^18.0.0",
|
|
719
|
+
"typescript": "^4.0.0"
|
|
720
|
+
},
|
|
721
|
+
"main": "/index.tsx"
|
|
722
|
+
}
|
|
723
|
+
```
|
|
724
|
+
|
|
725
|
+
---
|
|
726
|
+
|
|
727
|
+
#### Notification with Embedded Button
|
|
728
|
+
|
|
729
|
+
A `Notification` component that has an integrated `Button` that closes the notification when clicked.
|
|
730
|
+
|
|
731
|
+
**/styles.css**
|
|
732
|
+
|
|
733
|
+
```css
|
|
734
|
+
body {
|
|
735
|
+
font-size: 13px;
|
|
736
|
+
font-weight: 400;
|
|
737
|
+
letter-spacing: 0.08px;
|
|
738
|
+
line-height: 20px;
|
|
739
|
+
text-transform: none;
|
|
740
|
+
font-family: "Inter", sans-serif;
|
|
741
|
+
}
|
|
742
|
+
|
|
743
|
+
h1 {
|
|
744
|
+
font-size: 1.5rem;
|
|
745
|
+
}
|
|
746
|
+
|
|
747
|
+
.app {
|
|
748
|
+
padding: 20px;
|
|
749
|
+
}
|
|
750
|
+
```
|
|
751
|
+
|
|
752
|
+
**tsconfig.json**
|
|
753
|
+
|
|
754
|
+
```json
|
|
755
|
+
{
|
|
756
|
+
"include": ["./**/*"],
|
|
757
|
+
"compilerOptions": {
|
|
758
|
+
"strict": true,
|
|
759
|
+
"esModuleInterop": true,
|
|
760
|
+
"lib": ["dom", "es2015"],
|
|
761
|
+
"jsx": "react-jsx"
|
|
762
|
+
}
|
|
763
|
+
}
|
|
764
|
+
```
|
|
765
|
+
|
|
766
|
+
**/App.tsx**
|
|
767
|
+
|
|
768
|
+
```tsx
|
|
769
|
+
import { useState } from "react";
|
|
770
|
+
import { Notification, Button } from "@czi-sds/components";
|
|
771
|
+
import "./styles.css";
|
|
772
|
+
|
|
773
|
+
function App() {
|
|
774
|
+
const [dismissed, setDismissed] = useState(false);
|
|
775
|
+
const handleClick = () => {
|
|
776
|
+
setDismissed((prev) => !prev);
|
|
777
|
+
};
|
|
778
|
+
return (
|
|
779
|
+
<div className="app">
|
|
780
|
+
{!dismissed ? (
|
|
781
|
+
<Notification
|
|
782
|
+
buttonText="Close"
|
|
783
|
+
buttonOnClick={(event) => setDismissed(true)}
|
|
784
|
+
dismissed={dismissed}
|
|
785
|
+
intent="notice"
|
|
786
|
+
>
|
|
787
|
+
Notification Title
|
|
788
|
+
<div>
|
|
789
|
+
Lorem ipsum, dolor sit amet consectetur adipisicing elit. Amet
|
|
790
|
+
eveniet sapiente, officiis aut possimus suscipit assumenda non?
|
|
791
|
+
</div>
|
|
792
|
+
</Notification>
|
|
793
|
+
) : (
|
|
794
|
+
<Button onClick={handleClick} sdsType="primary" sdsStyle="rounded">
|
|
795
|
+
Reset Notification
|
|
796
|
+
</Button>
|
|
797
|
+
)}
|
|
798
|
+
</div>
|
|
799
|
+
);
|
|
800
|
+
}
|
|
801
|
+
|
|
802
|
+
export default App;
|
|
803
|
+
```
|
|
804
|
+
|
|
805
|
+
**/index.tsx**
|
|
806
|
+
|
|
807
|
+
```tsx
|
|
808
|
+
import React from "react";
|
|
809
|
+
import { createRoot } from "react-dom/client";
|
|
810
|
+
import { ThemeProvider as EmotionThemeProvider } from "@emotion/react";
|
|
811
|
+
import { StyledEngineProvider, ThemeProvider } from "@mui/material/styles";
|
|
812
|
+
import { Theme } from "@czi-sds/components";
|
|
813
|
+
import CssBaseline from "@mui/material/CssBaseline";
|
|
814
|
+
import useMediaQuery from "@mui/material/useMediaQuery";
|
|
815
|
+
|
|
816
|
+
import App from "./App";
|
|
817
|
+
|
|
818
|
+
const container = document.getElementById("root");
|
|
819
|
+
const root = createRoot(container!);
|
|
820
|
+
|
|
821
|
+
const RootApp = () => {
|
|
822
|
+
const prefersDarkMode = useMediaQuery("(prefers-color-scheme: dark)");
|
|
823
|
+
const theme = prefersDarkMode ? Theme("dark") : Theme("light");
|
|
824
|
+
|
|
825
|
+
return (
|
|
826
|
+
<StyledEngineProvider injectFirst>
|
|
827
|
+
<ThemeProvider theme={theme}>
|
|
828
|
+
<EmotionThemeProvider theme={theme}>
|
|
829
|
+
<CssBaseline />
|
|
830
|
+
<App />
|
|
831
|
+
</EmotionThemeProvider>
|
|
832
|
+
</ThemeProvider>
|
|
833
|
+
</StyledEngineProvider>
|
|
834
|
+
);
|
|
835
|
+
};
|
|
836
|
+
|
|
837
|
+
root.render(
|
|
838
|
+
<React.StrictMode>
|
|
839
|
+
<RootApp />
|
|
840
|
+
</React.StrictMode>
|
|
841
|
+
);
|
|
842
|
+
```
|
|
843
|
+
|
|
844
|
+
**/public/index.html**
|
|
845
|
+
|
|
846
|
+
```html
|
|
847
|
+
<!doctype html>
|
|
848
|
+
<html lang="en">
|
|
849
|
+
<head>
|
|
850
|
+
<meta charset="UTF-8" />
|
|
851
|
+
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
|
852
|
+
<title>Notification</title>
|
|
853
|
+
<link rel="preconnect" href="https://fonts.googleapis.com" />
|
|
854
|
+
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin />
|
|
855
|
+
<link
|
|
856
|
+
href="https://fonts.googleapis.com/css2?family=Inter:wght@400;600&display=swap"
|
|
857
|
+
rel="stylesheet"
|
|
858
|
+
/>
|
|
859
|
+
<link
|
|
860
|
+
href="https://fonts.googleapis.com/css2?family=IBM+Plex+Mono:wght@400;600&display=swap"
|
|
861
|
+
rel="stylesheet"
|
|
862
|
+
/>
|
|
863
|
+
</head>
|
|
864
|
+
<body>
|
|
865
|
+
<div id="root"></div>
|
|
866
|
+
</body>
|
|
867
|
+
</html>
|
|
868
|
+
```
|
|
869
|
+
|
|
870
|
+
**/package.json**
|
|
871
|
+
|
|
872
|
+
```json
|
|
873
|
+
{
|
|
874
|
+
"dependencies": {
|
|
875
|
+
"react": "^18.0.0",
|
|
876
|
+
"react-dom": "^18.0.0",
|
|
877
|
+
"react-scripts": "^4.0.0"
|
|
878
|
+
},
|
|
879
|
+
"devDependencies": {
|
|
880
|
+
"@types/react": "^18.0.0",
|
|
881
|
+
"@types/react-dom": "^18.0.0",
|
|
882
|
+
"typescript": "^4.0.0"
|
|
883
|
+
},
|
|
884
|
+
"main": "/index.tsx"
|
|
885
|
+
}
|
|
886
|
+
```
|
|
887
|
+
|
|
888
|
+
---
|