Commit 3d938fc
### WHY are these changes introduced?
Resolves #7134.
[Storybook
URL](https://5d559397bae39100201eedc1-bongofonfc.chromatic.com/?path=/story/all-components-toast--default).
An earlier [prototype](#7096)
explored adding `className` support to the `Box` component and keeping
it as an internal component.
This prototype explores keeping `Box` external without the `className`
prop and replacing custom divs in `Toast` with the `Box` component.
Even if we don't update `Toast` yet, there are some commits in this PR
I'd like to keep that cleans up some of the types and prop descriptions
in the `Box` component.
### WHAT is this pull request doing?
- Cleans up types and updates prop descriptions in `Box`
- Adds `color` and `maxWidth` support to `Box`
- Updates `Toast` to use `Box` where custom `div` are being used
<details>
<summary>Toast original</summary>
<img
src="https://user-images.githubusercontent.com/26749317/192353275-5ca804db-0873-4e13-9061-59ee13425538.gif"
alt="Toast original">
</details>
<details>
<summary>Toast refactored with Box</summary>
<img
src="https://user-images.githubusercontent.com/26749317/192353264-6eff870c-ddfb-4583-8d57-6a93f15daf94.gif"
alt="Toast refactored with Box">
</details>
<!-- ℹ️ Delete the following for small / trivial changes -->
### How to 🎩
🖥 [Local development
instructions](https://github.com/Shopify/polaris/blob/main/README.md#local-development)
🗒 [General tophatting
guidelines](https://github.com/Shopify/polaris/blob/main/documentation/Tophatting.md)
📄 [Changelog
guidelines](https://github.com/Shopify/polaris/blob/main/.github/CONTRIBUTING.md#changelog)
<!--
Give as much information as needed to experiment with the component
in the playground.
-->
<details>
<summary>Copy-paste this code in
<code>playground/Playground.tsx</code>:</summary>
```jsx
import React, {useState, useCallback} from 'react';
import {Page, Frame, Toast, Button} from '../src';
export function Playground() {
const [active, setActive] = useState(false);
const toggleActive = useCallback(() => setActive((active) => !active), []);
const toastMarkup = active ? (
<Toast content="It's toasty" onDismiss={toggleActive} />
) : null;
return (
<Frame>
<Page title="Toast example using Box">
<Button onClick={toggleActive}>Show Toast (with 📦)</Button>
{toastMarkup}
</Page>
</Frame>
);
}
```
</details>
### 🎩 checklist
- [ ] Tested on
[mobile](https://github.com/Shopify/polaris/blob/main/documentation/Tophatting.md#cross-browser-testing)
- [ ] Tested on [multiple
browsers](https://help.shopify.com/en/manual/shopify-admin/supported-browsers)
- [ ] Tested for
[accessibility](https://github.com/Shopify/polaris/blob/main/documentation/Accessibility%20testing.md)
- [ ] Updated the component's `README.md` with documentation changes
- [ ] [Tophatted
documentation](https://github.com/Shopify/polaris/blob/main/documentation/Tophatting%20documentation.md)
changes in the style guide
Co-authored-by: Kyle Durand <[email protected]>
1 parent be070cc commit 3d938fc
2 files changed
+46
-38
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
10 | 10 | | |
11 | 11 | | |
12 | 12 | | |
| 13 | + | |
13 | 14 | | |
14 | 15 | | |
15 | 16 | | |
16 | 17 | | |
| 18 | + | |
17 | 19 | | |
18 | 20 | | |
19 | 21 | | |
| |||
28 | 30 | | |
29 | 31 | | |
30 | 32 | | |
| 33 | + | |
31 | 34 | | |
32 | 35 | | |
33 | 36 | | |
34 | 37 | | |
| 38 | + | |
35 | 39 | | |
36 | 40 | | |
37 | 41 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
5 | 5 | | |
6 | 6 | | |
7 | 7 | | |
8 | | - | |
9 | | - | |
| 8 | + | |
10 | 9 | | |
11 | 10 | | |
12 | 11 | | |
| |||
15 | 14 | | |
16 | 15 | | |
17 | 16 | | |
| 17 | + | |
18 | 18 | | |
| 19 | + | |
19 | 20 | | |
20 | | - | |
21 | | - | |
| 21 | + | |
22 | 22 | | |
23 | | - | |
24 | 23 | | |
25 | 24 | | |
26 | 25 | | |
27 | 26 | | |
28 | | - | |
29 | | - | |
30 | | - | |
| 27 | + | |
31 | 28 | | |
32 | 29 | | |
33 | 30 | | |
34 | | - | |
35 | 31 | | |
36 | 32 | | |
37 | 33 | | |
| |||
58 | 54 | | |
59 | 55 | | |
60 | 56 | | |
61 | | - | |
62 | | - | |
63 | | - | |
64 | | - | |
| 57 | + | |
65 | 58 | | |
66 | 59 | | |
67 | 60 | | |
| |||
73 | 66 | | |
74 | 67 | | |
75 | 68 | | |
| 69 | + | |
| 70 | + | |
76 | 71 | | |
77 | | - | |
78 | | - | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
79 | 75 | | |
80 | | - | |
| 76 | + | |
81 | 77 | | |
82 | | - | |
| 78 | + | |
83 | 79 | | |
84 | | - | |
| 80 | + | |
85 | 81 | | |
86 | | - | |
| 82 | + | |
87 | 83 | | |
88 | | - | |
| 84 | + | |
89 | 85 | | |
90 | | - | |
| 86 | + | |
91 | 87 | | |
92 | | - | |
| 88 | + | |
93 | 89 | | |
94 | | - | |
| 90 | + | |
95 | 91 | | |
96 | | - | |
| 92 | + | |
97 | 93 | | |
98 | | - | |
| 94 | + | |
99 | 95 | | |
100 | | - | |
| 96 | + | |
101 | 97 | | |
102 | | - | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
103 | 101 | | |
104 | | - | |
| 102 | + | |
105 | 103 | | |
106 | | - | |
| 104 | + | |
107 | 105 | | |
108 | | - | |
| 106 | + | |
109 | 107 | | |
110 | | - | |
| 108 | + | |
111 | 109 | | |
112 | | - | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
113 | 113 | | |
114 | | - | |
| 114 | + | |
115 | 115 | | |
116 | | - | |
| 116 | + | |
117 | 117 | | |
118 | | - | |
| 118 | + | |
119 | 119 | | |
120 | | - | |
| 120 | + | |
121 | 121 | | |
122 | | - | |
| 122 | + | |
123 | 123 | | |
124 | 124 | | |
125 | 125 | | |
| |||
139 | 139 | | |
140 | 140 | | |
141 | 141 | | |
| 142 | + | |
142 | 143 | | |
143 | 144 | | |
144 | 145 | | |
145 | 146 | | |
146 | 147 | | |
| 148 | + | |
147 | 149 | | |
148 | 150 | | |
149 | 151 | | |
| |||
221 | 223 | | |
222 | 224 | | |
223 | 225 | | |
| 226 | + | |
224 | 227 | | |
225 | 228 | | |
226 | 229 | | |
| |||
233 | 236 | | |
234 | 237 | | |
235 | 238 | | |
| 239 | + | |
236 | 240 | | |
237 | 241 | | |
238 | 242 | | |
| |||
256 | 260 | | |
257 | 261 | | |
258 | 262 | | |
259 | | - | |
260 | 263 | | |
| 264 | + | |
261 | 265 | | |
262 | 266 | | |
263 | 267 | | |
| |||
0 commit comments