Skip to content

Commit d66014a

Browse files
committed
refactor: refactor and simplify modal UI + squash cross browser layout bugs
1 parent af2b0c9 commit d66014a

File tree

2 files changed

+43
-6
lines changed

2 files changed

+43
-6
lines changed

packages/uikit-workshop/src/html/partials/modal.html

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,18 @@
33
<div class="pl-c-modal__toolbar">
44
<div class="pl-c-modal__resizer pl-js-modal-resizer"></div>
55
<div class="pl-c-modal__toolbar-controls">
6+
<!-- @todo: revisit to see if slotted content might make sense here (ex. to have an extra toggle for switching the layout -->
7+
<pl-toggle-layout></pl-toggle-layout>
8+
69
<button class="pl-c-modal__close-btn pl-js-modal-close-btn" title="Hide pattern info">
710
<svg version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="12" height="12" viewBox="0 0 12 12" class="pl-c-modal__close-btn-icon">
811
<title>Close</title>
912
<path fill="currentColor" d="M11.8905,9.6405 L11.8905,9.6405 L8.25,6 L11.8905,2.3595 L11.8905,2.3595 C11.9295,2.3205 11.958,2.27475 11.976,2.226 C12.0255,2.0925 11.997,1.9365 11.8905,1.82925 L10.17075,0.1095 C10.0635,0.00225 9.9075,-0.02625 9.774,0.024 C9.72525,0.042 9.6795,0.0705 9.6405,0.1095 L9.6405,0.1095 L6,3.75 L2.3595,0.1095 L2.3595,0.1095 C2.3205,0.0705 2.27475,0.042 2.226,0.024 C2.0925,-0.0255 1.9365,0.00225 1.82925,0.1095 L0.1095,1.82925 C0.00225,1.9365 -0.02625,2.0925 0.024,2.226 C0.042,2.27475 0.0705,2.3205 0.1095,2.3595 L0.1095,2.3595 L3.75,6 L0.1095,9.6405 L0.1095,9.6405 C0.0705,9.6795 0.042,9.72525 0.024,9.774 C-0.0255,9.9075 0.00225,10.0635 0.1095,10.17075 L1.82925,11.8905 C1.9365,11.99775 2.0925,12.02625 2.226,11.976 C2.27475,11.958 2.3205,11.9295 2.3595,11.8905 L2.3595,11.8905 L6,8.25 L9.6405,11.8905 L9.6405,11.8905 C9.6795,11.9295 9.72525,11.958 9.774,11.976 C9.9075,12.0255 10.0635,11.99775 10.17075,11.8905 L11.8905,10.17075 C11.99775,10.0635 12.02625,9.9075 11.976,9.774 C11.958,9.72525 11.9295,9.6795 11.8905,9.6405 L11.8905,9.6405 Z"></path>
1013
</svg>
1114
</button>
12-
<pl-toggle-layout></pl-toggle-layout>
1315
</div>
1416
</div>
15-
<div class="pl-c-modal__content pl-js-modal-content"></div>
17+
<div class="pl-c-modal__content-wrapper">
18+
<div class="pl-c-modal__content pl-js-modal-content"></div>
19+
</div>
1620
</div>

packages/uikit-workshop/src/sass/scss/04-components/_modal.scss

Lines changed: 37 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,13 @@
22
#MODAL
33
\*------------------------------------*/
44

5+
$pl-resizer-height: 14px;
6+
57
pl-modal {
68
display: flex;
79
flex-direction: column;
810
position: relative;
11+
position: sticky;
912
z-index: 20;
1013
max-height: 100vh;
1114
box-shadow: 0 0 2px 0 $pl-color-gray-70;
@@ -23,10 +26,11 @@ pl-modal {
2326
font-family: $pl-font;
2427
background-color: $pl-color-gray-87;
2528
color: $pl-color-gray-20;
26-
position: relative;
29+
position: sticky;
2730
top: auto;
2831
bottom: 0;
2932
left: 0;
33+
right: 0;
3034
z-index: 5;
3135
width: 100%;
3236
height: 0;
@@ -36,6 +40,7 @@ pl-modal {
3640
will-change: height, transform;
3741
overflow: hidden;
3842
max-width: 100vw;
43+
box-shadow: 0 -1px 2px rgba($pl-color-gray-70, 0.1);
3944

4045
.pl-c-body--theme-sidebar & {
4146
@media all and (min-width: $pl-bp-med) {
@@ -48,7 +53,7 @@ pl-modal {
4853
*/
4954
&.pl-is-active {
5055
transform: translate3d(0, 0, 0);
51-
height: 50vh; // default height unless manually resized
56+
height: 40vh; // default height unless manually resized
5257
transition: transform 0.3s ease;
5358
pointer-events: auto;
5459
}
@@ -62,15 +67,33 @@ pl-modal {
6267
height: 100%;
6368
}
6469

70+
.pl-c-modal__content {
71+
flex-grow: 1;
72+
display: flex;
73+
width: 100%;
74+
overflow: hidden; // needed for IE 11 so scrollbars show up
75+
}
76+
6577
.pl-c-modal__toolbar {
6678
display: flex;
79+
flex-direction: column;
80+
flex-shrink: 0; // so that the resizer height doesn't change unexpectedly
81+
}
82+
83+
.pl-c-modal__content-wrapper {
84+
display: flex;
85+
flex-direction: column;
86+
flex-grow: 1;
87+
overflow: hidden; // needed for IE 11 so scrollbars show up
6788
}
6889

6990
.pl-c-modal__toolbar-controls {
7091
display: flex;
71-
flex-direction: column;
92+
flex-direction: row;
93+
align-self: flex-end;
7294
position: relative;
7395
z-index: 10;
96+
flex-shrink: 0;
7497
}
7598

7699
/**
@@ -79,6 +102,9 @@ pl-modal {
79102
*/
80103
.pl-c-modal__close-btn {
81104
@include linkStyle;
105+
margin: 0;
106+
-webkit-appearance: none;
107+
flex-shrink: 0; // needed for IE 11
82108

83109
@media all and (max-width: $pl-bp-med - 1) {
84110
border-radius: 20rem;
@@ -114,10 +140,14 @@ pl-modal {
114140

115141
.pl-c-modal__resizer {
116142
display: flex;
143+
position: absolute;
144+
top: 0;
145+
left: 0;
146+
right: 0;
117147
align-items: center;
118148
justify-content: center;
119149
left: 0;
120-
height: 14px;
150+
height: $pl-resizer-height;
121151
width: 100%;
122152
background-color: inherit;
123153
z-index: 2;
@@ -133,6 +163,7 @@ pl-modal {
133163
opacity: 0.5;
134164
background-color: currentColor;
135165
border-radius: 3px;
166+
display: block;
136167
}
137168

138169
&:hover:after {
@@ -155,6 +186,8 @@ pl-modal {
155186
color: currentColor;
156187
fill: currentColor;
157188
transition: fill $pl-animate-quick ease-out;
189+
flex-shrink: 0; // needed for IE 11
190+
align-self: center; // valign in IE 11
158191
}
159192

160193
.pl-c-code-copy-btn {

0 commit comments

Comments
 (0)