Skip to content

Commit 6f44139

Browse files
committed
refactor: add iframe resizer JS to scripts loaded inside the Pattern Lab iframe
1 parent e7cbb5f commit 6f44139

File tree

3 files changed

+21
-10
lines changed

3 files changed

+21
-10
lines changed

packages/uikit-workshop/package.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,7 @@
9090
"fg-loadcss": "^2.0.1",
9191
"fg-loadjs": "^1.0.0",
9292
"hogan.js": "^3.0.2",
93+
"iframe-resizer": "^3.6.2",
9394
"jquery": "^3.3.1",
9495
"js-cookie": "^2.2.0",
9596
"jshint": "^2.9.5",
@@ -100,6 +101,7 @@
100101
"prismjs": "^1.15.0",
101102
"pwa-helpers": "^0.8.3",
102103
"redux-thunk": "^2.3.0",
104+
"react-animate-height": "^2.0.4",
103105
"redux": "^4.0.0",
104106
"reselect": "^3.0.1",
105107
"scriptjs": "^2.5.8",

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

Lines changed: 18 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -15,16 +15,13 @@
1515
.pl-c-viewport {
1616
display: flex;
1717
flex-direction: column;
18-
flex-direction: column;
19-
height: auto;
2018
width: 100%;
2119
position: relative;
2220
top: $offset-top;
2321
bottom: 0;
2422
left: 0;
2523
right: 0;
2624
z-index: 0;
27-
overflow: hidden;
2825
flex-grow: 1;
2926
transition: height 0.3s ease;
3027

@@ -60,28 +57,34 @@
6057
* iframe and the manual resize handle
6158
*/
6259
.pl-c-viewport__iframe-wrapper {
63-
height: 100%;
60+
display: flex;
61+
flex-direction: column;
62+
max-width: 100vw;
6463
width: 100%; // bug fix for Safari and Firefox getting stuck calculating a width of 0px when the JS first kicks in
6564
position: relative;
6665
margin: 0 auto;
6766
flex: 1;
6867
-webkit-overflow-scrolling: touch;
69-
overflow-y: auto;
70-
overflow-x: hidden;
7168

7269
&.hay-mode {
7370
transition: all 40s linear;
7471
}
7572
width: 100%; // bug fix for Safari and Firefox getting stuck calculating a width of 0px when the JS first kicks in
73+
74+
.pl-c-body--theme-sidebar & {
75+
@media all and (min-width: $pl-bp-med) {
76+
max-width: calc(100vw - #{$pl-sidebar-width});
77+
}
78+
}
7679
}
7780

7881
/**
7982
* Viewport iframe
8083
* 1) this is the actual <iframe>
8184
*/
8285
.pl-c-viewport__iframe {
83-
position: absolute;
84-
height: 100%;
86+
min-height: calc(100vh - 35.5px);
87+
flex-grow: 1;
8588
width: 100%;
8689
border: 0;
8790
padding: 0;
@@ -93,9 +96,13 @@
9396
background-color: $pl-color-white;
9497
max-width: 100vw; // https://github.com/bolt-design-system/bolt/pull/868
9598

99+
&.is-ready {
100+
min-height: 0;
101+
}
102+
96103
.pl-c-body--theme-sidebar & {
97104
@media all and (min-width: $pl-bp-med) {
98-
max-width: calc(100vw - #{$pl-sidebar-width} + 14px);
105+
max-width: calc(100vw - #{$pl-sidebar-width});
99106
}
100107
}
101108

@@ -159,7 +166,8 @@
159166
display: flex;
160167
flex-grow: 1;
161168
flex-direction: column;
162-
max-width: calc(100vw);
169+
max-width: 100vw;
170+
position: relative; // used for absolute positioning if position sticky isn't supported
163171

164172
.pl-c-body--theme-sidebar & {
165173
@media all and (min-width: $pl-bp-med) {
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
import './utils/postmessage';
22
import './components/modal-styleguide';
33
import './components/pl-search/pl-search.iframe-helper'; // communicates with the main <pl-search> component via the PL iframe
4+
import 'iframe-resizer/js/iframeResizer.contentWindow.min.js'; // automatically syncs inner iFrame height with main Pattern Lab page

0 commit comments

Comments
 (0)