UNPKG

ldrs

Version:

Tiny HTML and SVG loaders as web components

3 lines (2 loc) 3.49 kB
import e from"../lib/LdrsBaseElement.js";var t=":host{--uib-dot-size:calc(var(--uib-size)*0.23);align-items:center;display:inline-flex;flex-shrink:0;height:var(--uib-dot-size);justify-content:center;width:var(--uib-size)}:host([hidden]){display:none}.container{align-items:center;display:flex;height:var(--uib-dot-size);justify-content:space-between;position:relative;width:var(--uib-size)}.svg{filter:url(#uib-jelly-ooze);overflow:visible}.dot{cy:50%;cx:0;r:calc(var(--uib-dot-size)/2);fill:var(--uib-color);animation:stream var(--uib-speed) linear infinite both;display:block;height:var(--uib-dot-size);transform-box:fill-box;transform-origin:center;transition:fill .3s ease;width:var(--uib-dot-size)}.dot:nth-child(2){animation-delay:calc(var(--uib-speed)*-.2)}.dot:nth-child(3){animation-delay:calc(var(--uib-speed)*-.4)}.dot:nth-child(4){animation-delay:calc(var(--uib-speed)*-.6)}.dot:nth-child(5){animation-delay:calc(var(--uib-speed)*-.8)}@keyframes stream{0%,to{transform:translateX(0) scale(0)}50%{transform:translateX(calc(var(--uib-size)*.5)) scale(1)}99.999%{transform:translateX(calc(var(--uib-size))) scale(0)}}";class i extends e{_attributes=["size","color","speed"];size;color;speed;static get observedAttributes(){return["size","color","speed"]}constructor(){super(),this.storePropsToUpgrade(this._attributes),this.reflect(this._attributes)}connectedCallback(){this.upgradeStoredProps(),this.applyDefaultProps({size:60,color:"black",speed:2.5});const e=.23*parseInt(this.size);this.template.innerHTML=`\n <div class="container">\n <svg \n class="svg" \n x="0px" \n y="0px"\n viewBox="0 0 ${this.size} ${e}"\n height="${e}"\n width="${this.size}"\n preserveAspectRatio='xMidYMid meet'\n >\n <circle class="dot" />\n <circle class="dot" />\n <circle class="dot" />\n <circle class="dot" />\n <circle class="dot" />\n <defs>\n <filter id="uib-jelly-ooze">\n <feGaussianBlur\n in="SourceGraphic"\n stdDeviation=${parseInt(this.size)/20}\n result="blur"\n />\n <feColorMatrix\n in="blur"\n mode="matrix"\n values="1 0 0 0 0 0 1 0 0 0 0 0 1 0 0 0 0 0 18 -7"\n result="ooze"\n />\n <feBlend in="SourceGraphic" in2="ooze" />\n </filter>\n </defs>\n </svg>\n </div>\n\n <style>\n :host{\n --uib-size: ${this.size}px;\n --uib-color: ${this.color};\n --uib-speed: ${this.speed}s;\n }\n ${t}\n </style>\n `,this.shadow.replaceChildren(this.template.content.cloneNode(!0))}attributeChangedCallback(){const e=this.shadow.querySelector("style"),i=this.shadow.querySelector("svg");if(i){const e=i.querySelector("feGaussianBlur"),t=parseInt(this.size),s=.23*t;e.setAttribute("stdDeviation",String(t/20)),i.setAttribute("height",String(s)),i.setAttribute("width",this.size),i.setAttribute("viewBox",`0 0 ${this.size} ${s}`)}e&&(e.innerHTML=`\n :host{\n --uib-size: ${this.size}px;\n --uib-color: ${this.color};\n --uib-speed: ${this.speed}s;\n }\n ${t}\n `)}}var s={register:(e="l-mirage")=>{customElements.get(e)||customElements.define(e,class extends i{})},element:i};export{s as default}; //# sourceMappingURL=mirage.js.map