|
1 | 1 | ### Overview |
2 | 2 |
|
3 | | -<!-- Get this short paragraph from design. --> |
| 3 | +Toasts are used to give action-based feedback messages and convey critical or informational account-related messages. Use Toasts when a user needs more detailed information for an action. |
4 | 4 |
|
5 | | -The X component inherits from the Material-UI [X component](https://material-ui.com/components/X/). Refer to the Material-UI [X docs](https://material-ui.com/api/X/) for more information. |
| 5 | +The Toast component inherits from the Material-UI [Snackbar component](https://material-ui.com/components/snackbars/). Refer to the Material-UI [Snackbar docs](https://material-ui.com/api/snackbar/) for more information. |
6 | 6 |
|
7 | 7 | ### Usage |
8 | 8 |
|
9 | | -<!-- Show all the variants/combos we use in Reaction Admin, without the code box > --> |
10 | | - |
11 | 9 | ```jsx |
12 | 10 | <Toast |
13 | | - anchorOrigin={{ |
14 | | - vertical: 'bottom', |
15 | | - horizontal: 'left', |
16 | | - }} |
17 | 11 | open |
18 | | - autoHideDuration={6000} |
19 | | - ContentProps={{ |
20 | | - 'aria-describedby': 'message-id', |
21 | | - }} |
| 12 | + autoHideDuration={300} |
22 | 13 | message={"Note archived"} |
23 | 14 | title={"Title"} |
24 | 15 | /> |
25 | 16 | ``` |
26 | 17 |
|
| 18 | +Toasts are most often used when the user has taken an action. Messages appear in context and communicate when that action is successful, unsuccessful, or that it otherwise needs attention and further context. |
| 19 | + |
| 20 | +Language should be polite, clear and concise. Optionally, a title can be added to a Toast to give clarity, or when there are 2 or more lines of information to display. |
| 21 | + |
| 22 | +Toasts should guide the user into taking corrective action if necessary. |
| 23 | + |
| 24 | +Users should be able to dismiss Toasts when appropriate. Information and success alerts can close automatically after 10 seconds. Error alerts should be persistent, and close only when action is resolved. |
| 25 | + |
27 | 26 | #### Types |
28 | 27 |
|
29 | 28 | ##### Information |
30 | 29 |
|
31 | | -<!-- Explain when to use this type of the component, and give a real life Reaction Admin example. If needed, add instruction for developers on how to set up the component. --> |
32 | | - |
33 | | -Use a X component to allow a user to XX, such as XYXY. |
| 30 | +- Used when there is information or tips that users can benefit from |
| 31 | +- Can close automatically after 10 seconds |
34 | 32 |
|
35 | 33 | ```jsx |
36 | 34 | import Button from "../Button"; |
@@ -73,14 +71,15 @@ function OpenToast(props) { |
73 | 71 | ); |
74 | 72 | } |
75 | 73 |
|
76 | | -<OpenToast message="Information toast" title="Info" variant="info" /> |
| 74 | +<OpenToast message={<span>Information toast</span>} title="Info" variant="info" /> |
77 | 75 | ``` |
78 | 76 |
|
79 | 77 | ##### Success |
80 | 78 |
|
81 | 79 | <!-- Explain when to use this type of the component, and give a real life Reaction Admin example. If needed, add instruction for developers on how to set up the component. --> |
82 | 80 |
|
83 | | -Use a X component to allow a user to XX, such as XYXY. |
| 81 | +- Used when an action has been completed successfully |
| 82 | +- Can close automatically after 10 seconds |
84 | 83 |
|
85 | 84 | ```jsx |
86 | 85 | import Button from "../Button"; |
@@ -122,14 +121,13 @@ function OpenToast(props) { |
122 | 121 | ); |
123 | 122 | } |
124 | 123 |
|
125 | | -<OpenToast message="Success toast" variant="success" /> |
| 124 | +<OpenToast message={<span>Success toast</span>} variant="success" /> |
126 | 125 | ``` |
127 | 126 |
|
128 | 127 | ##### Warning |
129 | 128 |
|
130 | | -<!-- Explain when to use this type of the component, and give a real life Reaction Admin example. If needed, add instruction for developers on how to set up the component. --> |
131 | | - |
132 | | -Use a X component to allow a user to XX, such as XYXY. |
| 129 | +- Used when an action or item needs attention |
| 130 | +- Should not close automatically, unless the action has been resolved |
133 | 131 |
|
134 | 132 | ```jsx |
135 | 133 | import Button from "../Button"; |
@@ -171,14 +169,13 @@ function OpenToast(props) { |
171 | 169 | ); |
172 | 170 | } |
173 | 171 |
|
174 | | -<OpenToast message="Warning toast" variant="warning" /> |
| 172 | +<OpenToast message={<span>Warning toast</span>} variant="warning" /> |
175 | 173 | ``` |
176 | 174 |
|
177 | 175 | ##### Error |
178 | 176 |
|
179 | | -<!-- Explain when to use this type of the component, and give a real life Reaction Admin example. If needed, add instruction for developers on how to set up the component. --> |
180 | | - |
181 | | -Use a X component to allow a user to XX, such as XYXY. |
| 177 | +- Used when the system has failed to complete an action, or the user has made an error |
| 178 | +- Should not close automatically, unless the action has been resolved |
182 | 179 |
|
183 | 180 | ```jsx |
184 | 181 | import Button from "../Button"; |
@@ -220,5 +217,5 @@ function OpenToast(props) { |
220 | 217 | ); |
221 | 218 | } |
222 | 219 |
|
223 | | -<OpenToast message="Error toast" variant="error" /> |
| 220 | +<OpenToast message={<span>Error toast</span>} variant="error" /> |
224 | 221 | ``` |
0 commit comments