@trimble-oss/moduswebcomponents
Version:
Modus Web Components is a modern, accessible UI library built with Stencil JS that provides reusable web components following Trimble's Modus design system. This updated version focuses on improved flexibility, enhanced theming options, comprehensive cust
157 lines (156 loc) • 5.84 kB
JavaScript
import { h, Host } from "@stencil/core";
import { convertPropsToClasses } from "./modus-wc-loader.tailwind";
import { inheritAriaAttributes } from "../utils";
/**
* A customizable loader component used to indicate the loading of content
*/
export class ModusWcLoader {
constructor() {
this.inheritedAttributes = {};
/** The color of the loader. */
this.color = 'primary';
/** Custom CSS class to apply to the loader element. */
this.customClass = '';
/** The size of the loader. */
this.size = 'md';
/** The variant of the loader. */
this.variant = 'spinner';
}
componentWillLoad() {
if (!this.el.ariaLabel) {
this.el.ariaLabel = 'Loading';
}
this.inheritedAttributes = inheritAriaAttributes(this.el);
}
getClasses() {
const classList = ['modus-wc-loader'];
const propClasses = convertPropsToClasses({
color: this.color,
size: this.size,
variant: this.variant,
});
// The order CSS classes are added matters to CSS specificity
if (propClasses)
classList.push(propClasses);
if (this.customClass)
classList.push(this.customClass);
return classList.join(' ');
}
render() {
return (h(Host, { key: '9898998291457f2018f390f99c9f43a38db06ea1' }, h("span", Object.assign({ key: '44e07aabbe5debe6a3f08d141f0a6bf2db01b86e', class: this.getClasses(), role: "status", tabindex: -1 }, this.inheritedAttributes))));
}
static get is() { return "modus-wc-loader"; }
static get originalStyleUrls() {
return {
"$": ["modus-wc-loader.scss"]
};
}
static get styleUrls() {
return {
"$": ["modus-wc-loader.css"]
};
}
static get properties() {
return {
"color": {
"type": "string",
"attribute": "color",
"mutable": false,
"complexType": {
"original": "LoaderColor",
"resolved": "\"accent\" | \"error\" | \"info\" | \"neutral\" | \"primary\" | \"secondary\" | \"success\" | \"warning\"",
"references": {
"LoaderColor": {
"location": "local",
"path": "/home/runner/work/modus-wc-2.0/modus-wc-2.0/src/components/modus-wc-loader/modus-wc-loader.tsx",
"id": "src/components/modus-wc-loader/modus-wc-loader.tsx::LoaderColor"
}
}
},
"required": false,
"optional": false,
"docs": {
"tags": [],
"text": "The color of the loader."
},
"getter": false,
"setter": false,
"reflect": false,
"defaultValue": "'primary'"
},
"customClass": {
"type": "string",
"attribute": "custom-class",
"mutable": false,
"complexType": {
"original": "string",
"resolved": "string | undefined",
"references": {}
},
"required": false,
"optional": true,
"docs": {
"tags": [],
"text": "Custom CSS class to apply to the loader element."
},
"getter": false,
"setter": false,
"reflect": false,
"defaultValue": "''"
},
"size": {
"type": "string",
"attribute": "size",
"mutable": false,
"complexType": {
"original": "DaisySize",
"resolved": "\"lg\" | \"md\" | \"sm\" | \"xs\"",
"references": {
"DaisySize": {
"location": "import",
"path": "../types",
"id": "src/components/types.ts::DaisySize"
}
}
},
"required": false,
"optional": false,
"docs": {
"tags": [],
"text": "The size of the loader."
},
"getter": false,
"setter": false,
"reflect": false,
"defaultValue": "'md'"
},
"variant": {
"type": "string",
"attribute": "variant",
"mutable": false,
"complexType": {
"original": "LoaderVariant",
"resolved": "\"ball\" | \"bars\" | \"dots\" | \"infinity\" | \"ring\" | \"spinner\"",
"references": {
"LoaderVariant": {
"location": "local",
"path": "/home/runner/work/modus-wc-2.0/modus-wc-2.0/src/components/modus-wc-loader/modus-wc-loader.tsx",
"id": "src/components/modus-wc-loader/modus-wc-loader.tsx::LoaderVariant"
}
}
},
"required": false,
"optional": false,
"docs": {
"tags": [],
"text": "The variant of the loader."
},
"getter": false,
"setter": false,
"reflect": false,
"defaultValue": "'spinner'"
}
};
}
static get elementRef() { return "el"; }
}