this._overlay.classList.add("spinner");
this._overlay.setAttribute("role", "status");
- const icon = document.createElement("span");
- icon.className = "icon icon48 fa-spinner";
+ const icon = document.createElement("fa-icon");
+ icon.size = 48;
+ icon.setIcon("spinner", true);
this._overlay.appendChild(icon);
const title = document.createElement("span");
const root = this.getShadowRoot();
root.childNodes[0]?.remove();
- const [codepoint] = window.getFontAwesome6IconMetadata(this.name)!;
- root.append(codepoint);
+ if (this.name === "spinner") {
+ root.append(this.createSpinner());
+ } else {
+ const [codepoint] = window.getFontAwesome6IconMetadata(this.name)!;
+ root.append(codepoint);
+ }
+ }
+
+ private createSpinner(): HTMLElement {
+ // Based upon the work of Fabio Ottaviani
+ // https://codepen.io/supah/pen/BjYLdW
+ const container = document.createElement("div");
+ container.innerHTML = `
+ <svg class="spinner" viewBox="0 0 50 50">
+ <circle class="path" cx="25" cy="25" r="20" fill="none" stroke-width="5"></circle>
+ </svg>
+ `;
+
+ const style = document.createElement("style");
+ style.textContent = `
+ div,
+ svg {
+ height: var(--font-size);
+ width: var(--font-size);
+ }
+
+ .spinner {
+ animation: rotate 2s linear infinite;
+ }
+
+ .path {
+ animation: dash 1.5s ease-in-out infinite;
+ stroke: currentColor;
+ stroke-linecap: round;
+ }
+
+ @keyframes rotate {
+ 100% {
+ transform: rotate(360deg);
+ }
+ }
+
+ @keyframes dash {
+ 0% {
+ stroke-dasharray: 1, 150;
+ stroke-dashoffset: 0;
+ }
+ 50% {
+ stroke-dasharray: 90, 150;
+ stroke-dashoffset: -35;
+ }
+ 100% {
+ stroke-dasharray: 90, 150;
+ stroke-dashoffset: -124;
+ }
+ }
+ `;
+
+ container.append(style);
+
+ return container;
}
get solid(): boolean {
this._overlay = document.createElement("div");
this._overlay.classList.add("spinner");
this._overlay.setAttribute("role", "status");
- const icon = document.createElement("span");
- icon.className = "icon icon48 fa-spinner";
+ const icon = document.createElement("fa-icon");
+ icon.size = 48;
+ icon.setIcon("spinner", true);
this._overlay.appendChild(icon);
const title = document.createElement("span");
title.textContent = Language.get("wcf.global.loading");
var _a;
const root = this.getShadowRoot();
(_a = root.childNodes[0]) === null || _a === void 0 ? void 0 : _a.remove();
- const [codepoint] = window.getFontAwesome6IconMetadata(this.name);
- root.append(codepoint);
+ if (this.name === "spinner") {
+ root.append(this.createSpinner());
+ }
+ else {
+ const [codepoint] = window.getFontAwesome6IconMetadata(this.name);
+ root.append(codepoint);
+ }
+ }
+ createSpinner() {
+ // Based upon the work of Fabio Ottaviani
+ // https://codepen.io/supah/pen/BjYLdW
+ const container = document.createElement("div");
+ container.innerHTML = `
+ <svg class="spinner" viewBox="0 0 50 50">
+ <circle class="path" cx="25" cy="25" r="20" fill="none" stroke-width="5"></circle>
+ </svg>
+ `;
+ const style = document.createElement("style");
+ style.textContent = `
+ div,
+ svg {
+ height: var(--font-size);
+ width: var(--font-size);
+ }
+
+ .spinner {
+ animation: rotate 2s linear infinite;
+ }
+
+ .path {
+ animation: dash 1.5s ease-in-out infinite;
+ stroke: currentColor;
+ stroke-linecap: round;
+ }
+
+ @keyframes rotate {
+ 100% {
+ transform: rotate(360deg);
+ }
+ }
+
+ @keyframes dash {
+ 0% {
+ stroke-dasharray: 1, 150;
+ stroke-dashoffset: 0;
+ }
+ 50% {
+ stroke-dasharray: 90, 150;
+ stroke-dashoffset: -35;
+ }
+ 100% {
+ stroke-dasharray: 90, 150;
+ stroke-dashoffset: -124;
+ }
+ }
+ `;
+ container.append(style);
+ return container;
}
get solid() {
return this.hasAttribute("solid");