Skip to content

Commit ae346e7

Browse files
tomassychraliterat
authored andcommitted
BREAKING CHANGE(web): Composed Modal became Modal #DS-592
## Migration Guide Instead of combining both `Modal Modal--composed` classes, only `Modal` is now used. The original `Modal__content`, `Modal__dialog` and `Modal__header` classes no longer exist, and so does the original structure. - `Modal Modal--composed` → `Modal` - `Modal__content` → `ModalBody` - `Modal__dialog` → `ModalDialog` - `Modal__header` → `ModalHeader` - `Modal__footer` → `ModalFooter` Please refer back to these instructions or reach out to our team if you encounter any issues during migration.
1 parent 283ac62 commit ae346e7

File tree

4 files changed

+29
-300
lines changed

4 files changed

+29
-300
lines changed

packages/web/src/scss/components/Modal/README.md

Lines changed: 20 additions & 83 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
# Modal
22

3-
## Composed Modal (DEPRECATED)
4-
53
Modal is a composition of several subcomponents:
64

75
- [Modal](#modal-1)
@@ -10,27 +8,22 @@ Modal is a composition of several subcomponents:
108
- [ModalBody](#modalfooter)
119
- [ModalFooter](#modalfooter)
1210

13-
⚠️ **DEPRECATED:** The flag `Modal--composed` — which is currently necessary to
14-
distinguish the composed version of Modal from the simple one — is deprecated
15-
and will be removed in the next major version: the composed Modal will supersede the
16-
[Simple Modal](#simple-modal-deprecated) variant.
17-
18-
### Modal
11+
## Modal
1912

2013
Modal establishes the layer with backdrop. Under the hood it uses the
2114
[`<dialog>` element][mdn-dialog] which provides several accessibility
2215
advantages.
2316

2417
```html
25-
<dialog id="example_1" class="Modal Modal--composed" aria-labelledby="example_1_title">
18+
<dialog id="example_1" class="Modal" aria-labelledby="example_1_title">
2619
<!-- ModalDialog -->
2720
</dialog>
2821
```
2922

3023
👉 Please note the `aria-labelledby` attribute is linked to the title inside
3124
[ModalHeader](#modalheader) and provides an accessible name for the dialog.
3225

33-
#### Custom Preferred Height
26+
### Custom Preferred Height
3427

3528
By default, Modal expands to fit the height of its content, as long as it fits the viewport (see [more below](#custom-max-height)).
3629
You can override this behavior by setting a custom preferred height using a custom property:
@@ -43,15 +36,15 @@ This is useful for Modals with dynamic content, e.g. a list of items that can be
4336
```html
4437
<dialog
4538
id="example_1"
46-
class="Modal Modal--composed"
39+
class="Modal"
4740
aria-labelledby="example_1_title"
4841
style="--modal-preferred-height-mobile: 400px; --modal-preferred-height-tablet: 500px;"
4942
>
5043
<!-- ModalDialog -->
5144
</dialog>
5245
```
5346

54-
#### Custom Max Height
47+
### Custom Max Height
5548

5649
The default maximum height of Modal is:
5750

@@ -61,19 +54,14 @@ The default maximum height of Modal is:
6154
You can use the custom property `--modal-max-height-tablet` to override the max height on tablet screens and up:
6255

6356
```html
64-
<dialog
65-
id="example_1"
66-
class="Modal Modal--composed"
67-
aria-labelledby="example_1_title"
68-
style="--modal-max-height-tablet: 700px"
69-
>
57+
<dialog id="example_1" class="Modal" aria-labelledby="example_1_title" style="--modal-max-height-tablet: 700px">
7058
<!-- ModalDialog -->
7159
</dialog>
7260
```
7361

7462
👉 Please note the max height on mobile screens is currently not customizable. Let us know if you need this feature! 🙏
7563

76-
### ModalDialog
64+
## ModalDialog
7765

7866
ModalDialog is the actual dialog window, a place for the header, body, and
7967
footer of the dialog.
@@ -86,7 +74,7 @@ footer of the dialog.
8674
</article>
8775
```
8876

89-
#### Forms in Modal
77+
### Forms in Modal
9078

9179
Modal can also contain interactive content like forms. For such cases, you may
9280
find convenient to use the `<form>` element with the attribute
@@ -100,13 +88,13 @@ dialog.
10088
</form>
10189
```
10290

103-
#### Expand on Mobile Screens
91+
### Expand on Mobile Screens
10492

10593
We recommend to expand the dialog on mobile screens using the
10694
`ModalDialog--expandOnMobile` modifier class. If you omit the class, the dialog
10795
shrinks to fit the height of its content (if smaller than viewport).
10896

109-
### ModalHeader
97+
## ModalHeader
11098

11199
ModalHeader contains the title of the dialog and the close button.
112100

@@ -133,12 +121,12 @@ ModalHeader contains the title of the dialog and the close button.
133121
accessible name for the dialog, e.g. using the `aria-label` attribute:
134122

135123
```html
136-
<dialog id="example_1" class="Modal Modal--composed" aria-label="Accessible Modal Title">
124+
<dialog id="example_1" class="Modal" aria-label="Accessible Modal Title">
137125
<!---->
138126
</dialog>
139127
```
140128

141-
### ModalBody
129+
## ModalBody
142130

143131
ModalBody holds the actual content of the Modal.
144132

@@ -152,7 +140,7 @@ ModalBody holds the actual content of the Modal.
152140
</div>
153141
```
154142

155-
#### Feature Flag to Enable Extra Padding
143+
### Feature Flag to Enable Extra Padding
156144

157145
⚠️ This feature flag is only temporary and will be removed in version 1. The extra vertical padding will be made default.
158146

@@ -165,7 +153,7 @@ The preferred one is the `body` element because this way it will affect all Moda
165153
</body>
166154
```
167155

168-
### ModalFooter
156+
## ModalFooter
169157

170158
ModalFooter is the place for actions represented by the Button component.
171159
While there always must be a primary Button, secondary actions are optional.
@@ -187,7 +175,7 @@ tab over the interface.
187175
</div>
188176
```
189177

190-
#### Footer Description
178+
### Footer Description
191179

192180
Optionally, you can add a description into the footer:
193181

@@ -200,7 +188,7 @@ Optionally, you can add a description into the footer:
200188
</div>
201189
```
202190

203-
#### Footer Alignment
191+
### Footer Alignment
204192

205193
ModalFooter can be aligned to the right (default), center, or left.
206194
These values come from the [dictionary][dictionary-alignment].
@@ -210,7 +198,7 @@ Using a corresponding modifier class:
210198
- `ModalFooter--center`
211199
- `ModalFooter--left`
212200

213-
### Opening the Modal
201+
## Opening the Modal
214202

215203
Use our JavaScript plugin to open your Modal, e.g.:
216204

@@ -227,7 +215,7 @@ Use our JavaScript plugin to open your Modal, e.g.:
227215
</button>
228216
```
229217

230-
### Scrolling Long Content
218+
## Scrolling Long Content
231219

232220
When Modals become too long for the user's viewport or device, they scroll independent of the page itself. By default,
233221
ModalBody has `overflow-y: auto` applied to it, so it scrolls vertically.
@@ -252,7 +240,7 @@ scrolling, e.g.:
252240
</article>
253241
```
254242

255-
### Full Example
243+
## Full Example
256244

257245
When you put it all together:
258246

@@ -271,7 +259,7 @@ When you put it all together:
271259
<!-- Modal Trigger: end -->
272260

273261
<!-- Modal: start -->
274-
<dialog id="example_1" class="Modal Modal--composed" aria-labelledby="example_1_title">
262+
<dialog id="example_1" class="Modal" aria-labelledby="example_1_title">
275263
<!-- ModalDialog: start -->
276264
<article class="ModalDialog">
277265
<!-- ModalHeader: start -->
@@ -334,57 +322,6 @@ When you put it all together:
334322
<!-- Modal: end -->
335323
```
336324

337-
## Simple Modal (DEPRECATED)
338-
339-
A simple version of Modal.
340-
341-
⚠️ **DEPRECATED:** Simple Modal will be removed in the next major version in favour
342-
of the composed Modal above.
343-
344-
Example usage:
345-
346-
```html
347-
<button
348-
type="button"
349-
class="Button Button--primary Button--medium"
350-
data-toggle="modal"
351-
data-target="#modal-example-1"
352-
aria-controls="modal-example-1"
353-
aria-expanded="false"
354-
>
355-
Open Modal
356-
</button>
357-
358-
<dialog id="modal-example-1" class="Modal">
359-
<div class="Modal__content">
360-
<div class="Modal__dialog">
361-
<div class="Modal__header">
362-
<button
363-
type="button"
364-
class="Button Button--tertiary Button--medium Button--square"
365-
data-dismiss="modal"
366-
data-target="#modal-example-1"
367-
aria-controls="modal-example-1"
368-
aria-expanded="false"
369-
>
370-
<svg class="Icon" width="24" height="24" aria-hidden="true">
371-
<use xlink:href="/icons/svg/sprite.svg#close" />
372-
</svg>
373-
<span class="accessibility-hidden">Close</span>
374-
</button>
375-
</div>
376-
<div class="Modal__body">
377-
<p>
378-
Lorem ipsum dolor sit amet, consectetur adipisicing elit. Aliquam at excepturi laudantium magnam mollitia
379-
perferendis reprehenderit, voluptate. Cum delectus dicta ducimus eligendi excepturi natus perferendis
380-
provident unde. Eveniet, iste, molestiae?
381-
</p>
382-
</div>
383-
</div>
384-
</div>
385-
</dialog>
386-
```
387-
388325
## Toggle Attributes
389326

390327
Both trigger and close buttons use `data` attributes to open and close the Modal.

packages/web/src/scss/components/Modal/_Modal.scss

Lines changed: 1 addition & 75 deletions
Original file line numberDiff line numberDiff line change
@@ -8,71 +8,7 @@
88
@use '../../tools/breakpoint';
99
@use 'theme';
1010

11-
// @deprecated Will be removed in the next major version.
1211
.Modal {
13-
position: fixed;
14-
top: 0;
15-
z-index: 1;
16-
width: 100%;
17-
max-width: none;
18-
height: 100%;
19-
max-height: none;
20-
padding: 0;
21-
margin: 0;
22-
overflow-x: hidden;
23-
overflow-y: auto;
24-
border: 0;
25-
background: transparent;
26-
overscroll-behavior-y: contain;
27-
28-
&::backdrop {
29-
background-color: theme.$backdrop-background-color;
30-
visibility: visible;
31-
opacity: 1;
32-
}
33-
}
34-
35-
// @deprecated Will be removed in the next major version.
36-
.Modal__content {
37-
display: flex;
38-
align-items: center;
39-
width: auto;
40-
max-width: 100%;
41-
min-height: calc(100% - #{theme.$padding * 2});
42-
margin: theme.$padding;
43-
pointer-events: none;
44-
45-
@include breakpoint.up(map.get(theme.$breakpoints, tablet)) {
46-
max-width: theme.$dialog-width-tablet;
47-
min-height: calc(100% - #{theme.$padding-tablet * 2});
48-
margin: theme.$padding-tablet auto;
49-
}
50-
51-
@include breakpoint.up(map.get(theme.$breakpoints, desktop)) {
52-
max-width: theme.$dialog-width-desktop;
53-
}
54-
}
55-
56-
// @deprecated Will be removed in the next major version.
57-
.Modal__dialog {
58-
position: relative;
59-
display: flex;
60-
flex-direction: column;
61-
width: 100%;
62-
padding: theme.$content-padding;
63-
border-radius: theme.$content-border-radius;
64-
background-color: theme.$content-background-color;
65-
box-shadow: theme.$content-shadow;
66-
pointer-events: auto;
67-
68-
@include breakpoint.up(map.get(theme.$breakpoints, tablet)) {
69-
padding: theme.$content-padding-tablet;
70-
}
71-
}
72-
73-
// @deprecated Will be removed in the next major version.
74-
// Migration: Rename to `Modal`.
75-
.Modal--composed {
7612
--modal-scale: #{theme.$transition-scale-ratio};
7713
--modal-translate-x: -50%;
7814
--modal-translate-y: #{theme.$transition-shift-distance};
@@ -119,9 +55,7 @@
11955
}
12056
}
12157

122-
// @deprecated Will be removed in the next major version.
123-
// Migration: Rename to `Modal`.
124-
.Modal--composed[open] {
58+
.Modal[open] {
12559
--modal-scale: 1;
12660
--modal-translate-y: 0;
12761

@@ -140,11 +74,3 @@
14074
--modal-translate-y: 50%;
14175
}
14276
}
143-
144-
// @deprecated Will be removed in the next major version.
145-
.Modal__header {
146-
display: flex;
147-
align-items: center;
148-
justify-content: flex-end;
149-
margin-bottom: theme.$header-spacing;
150-
}

packages/web/src/scss/components/Modal/_theme.scss

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -44,16 +44,3 @@ $footer-padding-top-tablet: tokens.$space-600;
4444
$footer-padding-bottom-tablet: tokens.$space-800;
4545
$footer-actions-column-gap: tokens.$space-700;
4646
$footer-actions-row-gap: tokens.$space-600;
47-
48-
// @deprecated Will be removed in the next major version.
49-
// Migration: Delete all variables below.
50-
51-
$padding-tablet: tokens.$space-1100;
52-
53-
$content-padding: tokens.$space-700;
54-
$content-padding-tablet: tokens.$space-800;
55-
$content-border-radius: tokens.$radius-200;
56-
$content-background-color: tokens.$background-basic;
57-
$content-shadow: tokens.$shadow-300;
58-
59-
$header-spacing: tokens.$space-600;

0 commit comments

Comments
 (0)