Skip to content

Commit 096fa8c

Browse files
committed
US206196 vertically/horizontally centered modal with flexbox.
1 parent 6175598 commit 096fa8c

File tree

2 files changed

+32
-37
lines changed

2 files changed

+32
-37
lines changed

elements/pfe-modal/src/pfe-modal.html

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,14 @@
11
<slot name="pfe-modal--trigger"></slot>
2-
<section class="pfe-modal__wrapper" tabindex="0" role="dialog" hidden>
3-
<div class="pfe-modal__container">
4-
<slot name="pfe-modal--header"></slot>
5-
<slot></slot>
6-
<button class="pfe-modal__close" aria-label="Close dialog">
7-
<svg version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="32" height="32" viewBox="-11 11 22 23">
8-
<path d="M30 16.669v-1.331c0-0.363-0.131-0.675-0.394-0.938s-0.575-0.394-0.938-0.394h-10.669v-10.65c0-0.362-0.131-0.675-0.394-0.938s-0.575-0.394-0.938-0.394h-1.331c-0.363 0-0.675 0.131-0.938 0.394s-0.394 0.575-0.394 0.938v10.644h-10.675c-0.362 0-0.675 0.131-0.938 0.394s-0.394 0.575-0.394 0.938v1.331c0 0.363 0.131 0.675 0.394 0.938s0.575 0.394 0.938 0.394h10.669v10.644c0 0.363 0.131 0.675 0.394 0.938 0.262 0.262 0.575 0.394 0.938 0.394h1.331c0.363 0 0.675-0.131 0.938-0.394s0.394-0.575 0.394-0.938v-10.637h10.669c0.363 0 0.675-0.131 0.938-0.394 0.269-0.262 0.4-0.575 0.4-0.938z" transform="rotate(45)"/>
9-
</svg>
10-
</button>
2+
<section class="pfe-modal__overlay" hidden>
3+
<div class="pfe-modal__wrapper" tabindex="0" role="dialog" hidden>
4+
<div class="pfe-modal__container">
5+
<slot name="pfe-modal--header"></slot>
6+
<slot></slot>
7+
<button class="pfe-modal__close" aria-label="Close dialog">
8+
<svg version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="32" height="32" viewBox="-11 11 22 23">
9+
<path d="M30 16.669v-1.331c0-0.363-0.131-0.675-0.394-0.938s-0.575-0.394-0.938-0.394h-10.669v-10.65c0-0.362-0.131-0.675-0.394-0.938s-0.575-0.394-0.938-0.394h-1.331c-0.363 0-0.675 0.131-0.938 0.394s-0.394 0.575-0.394 0.938v10.644h-10.675c-0.362 0-0.675 0.131-0.938 0.394s-0.394 0.575-0.394 0.938v1.331c0 0.363 0.131 0.675 0.394 0.938s0.575 0.394 0.938 0.394h10.669v10.644c0 0.363 0.131 0.675 0.394 0.938 0.262 0.262 0.575 0.394 0.938 0.394h1.331c0.363 0 0.675-0.131 0.938-0.394s0.394-0.575 0.394-0.938v-10.637h10.669c0.363 0 0.675-0.131 0.938-0.394 0.269-0.262 0.4-0.575 0.4-0.938z" transform="rotate(45)"/>
10+
</svg>
11+
</button>
12+
</div>
1113
</div>
1214
</section>
13-
<div class="pfe-modal__overlay" hidden></div>

elements/pfe-modal/src/pfe-modal.scss

Lines changed: 21 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -22,33 +22,43 @@ $pfe-modal--breakpoint--medium: 640px;
2222
}
2323

2424
.pfe-modal {
25+
&__overlay {
26+
display: flex;
27+
position: fixed;
28+
height: 100%;
29+
width: 100%;
30+
top: 0;
31+
left: 0;
32+
flex-direction: column;
33+
align-items: center;
34+
justify-content: center;
35+
z-index: 2;
36+
background-color: pfe-local($cssvar: BackgroundColor, $region: overlay);
37+
cursor: pointer;
38+
39+
&[hidden] {
40+
display: none;
41+
}
42+
}
2543
&__wrapper {
26-
position: absolute;
2744
z-index: 2;
28-
top: 10%;
29-
left: 0;
30-
right: 0;
3145
max-width: pfe-local(MaxWidth--mobile);
3246
min-width: pfe-local(MinWidth);
3347
min-height: pfe-local(MinHeight);
3448
margin: 0 auto;
3549
box-shadow: pfe-var(box-shadow--lg);
3650
background-color: pfe-color(surface--lightest);
3751
border-radius: #{pfe-var(ui--border-radius)};
38-
overflow-y: scroll;
39-
scrollbar-width: none; /* Firefox */
40-
-ms-overflow-style: none; /* IE 10+ */
41-
42-
&::-webkit-scrollbar {
43-
display: none;
44-
}
52+
overflow-y: auto;
53+
overscroll-behavior: contain;
4554

4655
@media screen and (min-width: $pfe-modal--breakpoint--medium) {
4756
max-width: pfe-local(MaxWidth);
4857
max-height: pfe-local(MaxHeight);
4958
}
5059
}
5160
&__container {
61+
position: relative;
5262
padding: var(--pfe-modal--Padding--mobile);
5363
max-width: calc(100% - #{pfe-var(ui--element--size)});
5464

@@ -99,20 +109,4 @@ $pfe-modal--breakpoint--medium: 640px;
99109
width: pfe-local(CloseButtonSize);
100110
}
101111
}
102-
103-
&__overlay {
104-
display: block;
105-
background-color: pfe-local($cssvar: BackgroundColor, $region: overlay);
106-
position: fixed;
107-
top: 0;
108-
left: 0;
109-
width: 100%; // Fallback
110-
width: 100vw;
111-
height: 100%; // Fallback
112-
height: 100vh;
113-
z-index: 1;
114-
&[hidden] {
115-
display: none;
116-
}
117-
}
118112
}

0 commit comments

Comments
 (0)