Skip to content

Commit 3c63545

Browse files
committed
feat: add support for loader when pulling in code snippets in the Drawer
1 parent 453ae24 commit 3c63545

File tree

3 files changed

+57
-17
lines changed

3 files changed

+57
-17
lines changed

packages/uikit-workshop/src/sass/pattern-lab--iframe-loader.scss

Lines changed: 17 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,6 @@
11
@import 'scss/01-abstracts/variables';
22
@import 'scss/01-abstracts/mixins';
33

4-
@keyframes animateIn {
5-
from {
6-
transform: translate3d(-50%, -100%, 0px);
7-
opacity: 0;
8-
}
9-
to {
10-
opacity: 1;
11-
transform: translate3d(-50%, calc(3rem - 50%), 0px);
12-
}
13-
}
14-
154
@keyframes rotate {
165
0% {
176
transform: rotate(0deg);
@@ -21,21 +10,34 @@
2110
}
2211
}
2312

13+
.pl-c-loader-wrapper {
14+
position: absolute;
15+
top: 0;
16+
left: 0;
17+
right: 0;
18+
bottom: 0;
19+
}
20+
21+
.pl-c-loader-wrapper:not(:last-child){
22+
opacity: 0;
23+
pointer-events: none;
24+
transition: opacity 0.2s ease, transform 0.2s ease;
25+
}
26+
2427
.pl-c-loader {
2528
z-index: 1000;
2629
position: absolute;
27-
top: 0;
30+
top: 50%;
2831
left: 50%;
2932
margin: auto;
3033
max-width: $pl-space * 25;
3134
width: calc(90vw - #{$pl-doublespace});
3235
border-radius: $pl-border-radius;
3336
background: rgba($pl-color-black, 0.9);
34-
transform: translate3d(-50%, -100%, 0px);
37+
transform: translate3d(-50%, -50%, 0px);
3538
transition: opacity 0.3s ease, transform 0.3s ease;
3639
pointer-events: none;
37-
opacity: 0;
38-
animation: animateIn ease 0.3s forwards;
40+
opacity: 1;
3941
}
4042

4143
.pl-c-loader__content {

packages/uikit-workshop/src/scripts/components/modal-viewer.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -167,7 +167,9 @@ export const modalViewer = {
167167

168168
// Clear out any existing children before appending the new panel content
169169
if (contentContainer.firstChild !== null) {
170-
contentContainer.removeChild(contentContainer.firstChild);
170+
while(contentContainer.firstChild !== null){
171+
contentContainer.removeChild(contentContainer.firstChild);
172+
}
171173
}
172174

173175
contentContainer.appendChild(templateRendered);

packages/uikit-workshop/src/scripts/components/pl-drawer/pl-drawer.js

Lines changed: 37 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,10 @@ class Drawer extends LitElement {
3636
attribute: true,
3737
type: Boolean,
3838
},
39+
themeMode: {
40+
attribute: true,
41+
type: String,
42+
},
3943
};
4044
}
4145

@@ -117,7 +121,35 @@ class Drawer extends LitElement {
117121
</pl-button>
118122
</div>
119123
</div>
120-
<div class="pl-c-drawer__content pl-js-drawer-content"></div>
124+
<div class="pl-c-drawer__content pl-js-drawer-content">
125+
<div class="pl-c-loader-wrapper pl-c-body--theme-${this.themeMode}">
126+
<div class="pl-c-loader">
127+
<div class="pl-c-loader__content">
128+
<div class="pl-c-loader__message">Loading Code Panel</div>
129+
<div class="pl-c-loader__spinner">
130+
<svg class="pl-c-loader-svg" viewBox="0 0 268 255">
131+
<circle
132+
class="pl-c-loader-svg__outer-circle"
133+
cx="134.2"
134+
cy="127.6"
135+
r="115.1"
136+
/>
137+
<circle
138+
class="pl-c-loader-svg__inner-circle"
139+
cx="134.2"
140+
cy="127.6"
141+
r="66.3"
142+
/>
143+
<path
144+
class="pl-c-loader-svg__electron"
145+
d="M253,56.3c0,15.6-12.6,28.2-28.2,28.2s-28.2-12.6-28.2-28.2s12.6-28.2,28.2-28.2C240.3,28.1,253,40.7,253,56.3z"
146+
/>
147+
</svg>
148+
</div>
149+
</div>
150+
</div>
151+
</div>
152+
</div>
121153
</div>
122154
</div>
123155
</div>
@@ -143,6 +175,10 @@ class Drawer extends LitElement {
143175
}
144176

145177
_stateChanged(state) {
178+
if (this.themeMode !== state.app.themeMode) {
179+
this.themeMode = state.app.themeMode || 'dark';
180+
}
181+
146182
if (this.drawerOpened !== state.app.drawerOpened) {
147183
this.drawerOpened = state.app.drawerOpened;
148184
}

0 commit comments

Comments
 (0)