Skip to content

Commit 39190fd

Browse files
authored
Merge pull request #3232 from AlchemyCMS/backport/7.4-stable/pr-3226
[7.4-stable] Hide body while custom elements load
2 parents 20d033d + e84f59d commit 39190fd

File tree

6 files changed

+26
-4
lines changed

6 files changed

+26
-4
lines changed

app/assets/builds/alchemy/admin.css

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

app/assets/builds/alchemy/admin.css.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

app/assets/stylesheets/alchemy/admin/base.scss

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,10 @@ html {
88
background-color: var(--color-blue_medium) !important;
99
z-index: 400001;
1010
}
11+
12+
&.loading-custom-elements body {
13+
opacity: 0;
14+
}
1115
}
1216

1317
*,
@@ -42,6 +46,8 @@ body {
4246
background-color: $body-background-color;
4347
height: 100%;
4448
cursor: default;
49+
opacity: 1;
50+
transition: opacity $transition-duration;
4551

4652
// Fix for strange element window offset
4753
&.pages.edit {

app/assets/stylesheets/alchemy/admin/navigation.scss

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,7 @@
131131

132132
img,
133133
svg,
134-
.icon {
134+
alchemy-icon {
135135
display: inline-flex;
136136
width: var(--icon-size-xxl);
137137
height: var(--icon-size-xxl);

app/javascript/alchemy_admin/components/index.js

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,3 +24,19 @@ import "alchemy_admin/components/select"
2424
import "alchemy_admin/components/spinner"
2525
import "alchemy_admin/components/tags_autocomplete"
2626
import "alchemy_admin/components/tinymce"
27+
28+
await Promise.race([
29+
// Load all global custom elements
30+
Promise.allSettled([
31+
customElements.whenDefined("alchemy-button"),
32+
customElements.whenDefined("alchemy-icon"),
33+
customElements.whenDefined("alchemy-growl"),
34+
customElements.whenDefined("alchemy-message"),
35+
customElements.whenDefined("alchemy-spinner")
36+
]),
37+
// Resolve after two seconds
38+
new Promise((resolve) => setTimeout(resolve, 1250))
39+
])
40+
41+
// Remove the class, showing the page content
42+
document.documentElement.classList.remove("loading-custom-elements")

app/views/layouts/alchemy/admin.html.erb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<!DOCTYPE html>
2-
<html lang="<%= ::I18n.locale %>" class="no-js">
2+
<html lang="<%= ::I18n.locale %>" class="no-js loading-custom-elements">
33
<head>
44
<meta charset="utf-8">
55
<meta name="viewport" content="width=device-width, initial-scale=1">

0 commit comments

Comments
 (0)