-
-
Notifications
You must be signed in to change notification settings - Fork 3.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[5.1] Core loader custom element rework (#42903)
- Loading branch information
Showing
4 changed files
with
61 additions
and
179 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
98 changes: 43 additions & 55 deletions
98
build/media_source/system/js/joomla-core-loader.w-c.es6.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,65 +1,53 @@ | ||
((customElements) => { | ||
'strict'; | ||
|
||
/** | ||
* Creates a custom element with the default spinner of the Joomla logo | ||
*/ | ||
class JoomlaCoreLoader extends HTMLElement { | ||
constructor() { | ||
super(); | ||
|
||
const template = document.createElement('template'); | ||
template.innerHTML = `<style>{{CSS_CONTENTS_PLACEHOLDER}}</style> | ||
<div> | ||
<span class="yellow"></span> | ||
<span class="red"></span> | ||
<span class="blue"></span> | ||
<span class="green"></span> | ||
<p>™</p> | ||
</div>`; | ||
|
||
// Patch the shadow DOM | ||
if (window.ShadyCSS) { | ||
window.ShadyCSS.prepareTemplate(template, 'joomla-core-loader'); | ||
} | ||
/** | ||
* Creates a custom element with the default spinner of the Joomla logo | ||
*/ | ||
class JoomlaCoreLoader extends HTMLElement { | ||
connectedCallback() { | ||
this.style.backgroundColor = this.color; | ||
|
||
if (this.inline === 'false') { | ||
this.classList.add('fullscreen'); | ||
} | ||
|
||
this.attachShadow({ mode: 'open' }); | ||
this.shadowRoot.appendChild(template.content.cloneNode(true)); | ||
const template = document.createElement('template'); | ||
template.innerHTML = ` | ||
<style>{{CSS_CONTENTS_PLACEHOLDER}}</style> | ||
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 150 150" width="${this.size}" height="${this.size}"> | ||
<style>@keyframes joomla-spinner{0%,28%,to{opacity:.30}20%{opacity:1}}.joomla-spinner{animation:joomla-spinner 1.6s infinite cubic-bezier(0,.15,1,.75)} | ||
</style> | ||
<path d="m27 75.5-2.9-2.9c-8.9-8.9-11.7-21.7-8.3-33C6.9 37.6.2 29.6.2 20.1c0-11.1 9-20 20-20 10 0 18.2 7.3 19.8 16.8 10.8-2.5 22.6.4 31.1 8.8l1.2 1.2-14.9 14.7-1.1-1.2c-4.8-4.8-12.6-4.8-17.4 0-4.8 4.8-4.8 12.6 0 17.4l2.9 2.9 14.8 14.8 15.6 15.6-14.8 14.8-15.6-15.7L27 75.5z" class="joomla-spinner" style="animation-delay:-1.2s" fill="#7ac143" /> | ||
<path d="m43.5 58.9 15.6-15.6 14.8-14.8 2.9-2.9c8.9-8.9 21.6-11.7 32.8-8.4C111 7.5 119.4 0 129.5 0c11.1 0 20 9 20 20 0 10.2-7.6 18.6-17.4 19.9 3.2 11.2.4 23.8-8.4 32.7l-1.2 1.2L107.7 59l1.1-1.1c4.8-4.8 4.8-12.6 0-17.4-4.8-4.8-12.5-4.8-17.4 0l-2.9 2.9-14.6 14.7-15.6 15.6-14.8-14.8z" class="joomla-spinner" style="animation-delay:-.8s" fill="#f9a541" /> | ||
<path d="M110.1 133.5c-11.4 3.5-24.2.7-33.2-8.3l-1.1-1.1 14.8-14.8 1.1 1.1c4.8 4.8 12.6 4.8 17.4 0 4.8-4.8 4.8-12.5 0-17.4l-2.9-2.9-14.9-14.6-15.6-15.7L90.5 45l15.6 15.6 14.8 14.8 2.9 2.9c8.5 8.5 11.4 20.5 8.8 31.3 9.7 1.4 17.2 9.7 17.2 19.8 0 11.1-9 20-20 20-9.8.2-17.9-6.7-19.7-15.9z" class="joomla-spinner" style="animation-delay:-.4s" fill="#f44321" /> | ||
<path d="m104.3 92-15.6 15.6-14.8 14.8-2.9 2.9c-8.5 8.5-20.6 11.4-31.5 8.7-2 8.9-10 15.5-19.5 15.5-11.1 0-20-9-20-20 0-9.5 6.6-17.4 15.4-19.5-2.8-11 .1-23.1 8.7-31.7l1.1-1.1L40 92l-1.1 1.1c-4.8 4.8-4.8 12.6 0 17.4 4.8 4.8 12.6 4.8 17.4 0l2.9-2.9L74 92.8l15.6-15.6L104.3 92z" class="joomla-spinner" fill="#5091cd" /> | ||
</svg>`; | ||
|
||
this.attachShadow({ mode: 'open' }); | ||
this.shadowRoot.appendChild(template.content.cloneNode(true)); | ||
} | ||
|
||
// Patch the shadow DOM | ||
if (window.ShadyCSS) { | ||
window.ShadyCSS.styleElement(this); | ||
} | ||
} | ||
static get observedAttributes() { | ||
return ['color']; | ||
} | ||
|
||
connectedCallback() { | ||
this.style.backgroundColor = this.color; | ||
this.style.opacity = 0.8; | ||
this.shadowRoot.querySelector('div').classList.add('box'); | ||
} | ||
get inline() { return this.getAttribute('inline') || false; } | ||
|
||
static get observedAttributes() { | ||
return ['color']; | ||
} | ||
get size() { return this.getAttribute('size') || '345'; } | ||
|
||
get color() { return this.getAttribute('color') || '#fff'; } | ||
get color() { return this.getAttribute('color') || '#fff'; } | ||
|
||
set color(value) { this.setAttribute('color', value); } | ||
set color(value) { this.setAttribute('color', value); } | ||
|
||
attributeChangedCallback(attr, oldValue, newValue) { | ||
switch (attr) { | ||
case 'color': | ||
if (newValue && newValue !== oldValue) { | ||
this.style.backgroundColor = this.color; | ||
} | ||
break; | ||
default: | ||
// Do nothing | ||
} | ||
attributeChangedCallback(attr, oldValue, newValue) { | ||
switch (attr) { | ||
case 'color': | ||
if (newValue && newValue !== oldValue) { | ||
this.style.backgroundColor = this.color; | ||
} | ||
break; | ||
default: | ||
// Do nothing | ||
} | ||
} | ||
} | ||
|
||
if (!customElements.get('joomla-core-loader')) { | ||
customElements.define('joomla-core-loader', JoomlaCoreLoader); | ||
} | ||
})(customElements); | ||
window.customElements.define('joomla-core-loader', JoomlaCoreLoader); |
121 changes: 12 additions & 109 deletions
121
build/media_source/system/scss/joomla-core-loader.scss
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,124 +1,27 @@ | ||
$theme-colours: (); | ||
$theme-colours: map-merge(( | ||
"yellow" : #f9a541, | ||
"red" : #f44321, | ||
"blue" : #5091cd, | ||
"green" : #7ac143, | ||
), $theme-colours); | ||
|
||
:host { | ||
position: fixed; | ||
top: 0; | ||
left: 0; | ||
z-index: 10000; | ||
display: flex; | ||
align-items: center; | ||
width: 100%; | ||
height: 100%; | ||
justify-content: center; | ||
overflow: hidden; | ||
opacity: .8; | ||
} | ||
|
||
.box { | ||
position: relative; | ||
width: 345px; | ||
height: 345px; | ||
margin: 0 auto; | ||
|
||
p { | ||
float: right; | ||
margin: 95px 0 0; | ||
font: normal 1.25em/1em sans-serif; | ||
color: #999; | ||
} | ||
|
||
> span { | ||
animation: jspinner 2s infinite ease-in-out; | ||
} | ||
|
||
.red { | ||
animation-delay: -1.5s; | ||
} | ||
.blue { | ||
animation-delay: -1s; | ||
} | ||
.green { | ||
animation-delay: -.5s; | ||
} | ||
} | ||
|
||
@each $colour in $theme-colours { | ||
$key: nth($colour, 1); | ||
$value: nth($colour, 2); | ||
|
||
.#{$key} { | ||
position: absolute; | ||
top: 0; | ||
left: 0; | ||
width: 90px; | ||
height: 90px; | ||
content: ""; | ||
background: $value; | ||
border-radius: 90px; | ||
|
||
&::before, | ||
&::after { | ||
position: absolute; | ||
top: 0; | ||
left: 0; | ||
box-sizing: content-box; | ||
width: 50px; | ||
content: ""; | ||
background: transparent; | ||
border: 50px solid $value; | ||
} | ||
|
||
&::before { | ||
height: 35px; | ||
margin: 60px 0 0 -30px; | ||
border-width: 50px 50px 0; | ||
border-radius: 75px 75px 0 0; | ||
} | ||
|
||
&::after { | ||
height: 105px; | ||
margin: 140px 0 0 -30px; | ||
border-width: 0 0 0 50px; | ||
} | ||
} | ||
} | ||
|
||
.yellow { | ||
margin: 0 0 0 255px; | ||
transform: rotate(45deg); | ||
} | ||
|
||
.red { | ||
margin: 255px 0 0 255px; | ||
transform: rotate(135deg); | ||
} | ||
|
||
.blue { | ||
margin: 255px 0 0; | ||
transform: rotate(225deg); | ||
} | ||
|
||
.green { | ||
transform: rotate(315deg); | ||
} | ||
:host(.fullscreen) { | ||
position: fixed; | ||
top: 0; | ||
left: 0; | ||
width: 100%; | ||
height: 100%; | ||
|
||
@keyframes jspinner { | ||
0%, 40%, 100% { | ||
opacity: .3; | ||
} | ||
20% { | ||
opacity: 1; | ||
svg { | ||
width: 345px; | ||
height: 345px; | ||
} | ||
} | ||
|
||
|
||
@media (prefers-reduced-motion: reduce) { | ||
.box > span { | ||
animation: none; | ||
.joomla-spinner { | ||
animation: none !important; | ||
} | ||
} |