@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
60 lines (56 loc) • 2.87 kB
JavaScript
import { p as proxyCustomElement, H, h, c as Host } from './p-BMvVSi6Y.js';
import { i as inheritAriaAttributes } from './p-COxr4v9W.js';
const modusWcIconCss = "modus-wc-icon .modus-icons.modus-wc-icon--xs{font-size:1rem}modus-wc-icon .modus-icons.modus-wc-icon--sm{font-size:1.25rem}modus-wc-icon .modus-icons.modus-wc-icon--md{font-size:1.5rem}modus-wc-icon .modus-icons.modus-wc-icon--lg{font-size:2rem}modus-wc-icon .modus-icons.modus-wc-icon--xl{font-size:4rem}modus-wc-icon i::before,modus-wc-icon i::after{font-family:inherit !important}";
const ModusWcIcon = /*@__PURE__*/ proxyCustomElement(class ModusWcIcon extends H {
constructor() {
super();
this.__registerHost();
this.inheritedAttributes = {};
/** Custom CSS class to apply to the i element. */
this.customClass = '';
/** Indicates that the icon is decorative. When true, sets aria-hidden to hide the icon from screen readers. */
this.decorative = true;
/** The icon size, can be "sm", "md", "lg" (a custom size can be specified in CSS). This adjusts the font size for the icon. */
this.size = 'md';
}
componentWillLoad() {
if (!this.decorative && !this.el.ariaLabel) {
this.el.ariaLabel = `${this.name} icon`;
}
this.inheritedAttributes = inheritAriaAttributes(this.el);
}
getClasses() {
const classList = ['modus-wc-icon modus-icons'];
// The order CSS classes are added matters to CSS specificity
classList.push(`modus-wc-icon--${this.size}`);
if (this.customClass)
classList.push(this.customClass);
return classList.join(' ');
}
render() {
const ariaHidden = this.decorative ? 'true' : null;
const role = this.decorative ? undefined : 'img';
return (h(Host, { key: '81718a9ea5b64625ca3b89ddabe0be8f2f31df73', class: "modus-wc-flex modus-wc-items-center" }, h("i", Object.assign({ key: 'e384b6a3a1bc388cb16e7fea0b34a5e9c6670be7', "aria-hidden": ariaHidden, "aria-label": this.decorative ? null : this.el.ariaLabel, class: this.getClasses(), role: role, tabindex: -1 }, this.inheritedAttributes), this.name)));
}
get el() { return this; }
static get style() { return modusWcIconCss; }
}, [0, "modus-wc-icon", {
"customClass": [1, "custom-class"],
"decorative": [4],
"name": [1],
"size": [1]
}]);
function defineCustomElement() {
if (typeof customElements === "undefined") {
return;
}
const components = ["modus-wc-icon"];
components.forEach(tagName => { switch (tagName) {
case "modus-wc-icon":
if (!customElements.get(tagName)) {
customElements.define(tagName, ModusWcIcon);
}
break;
} });
}
export { ModusWcIcon as M, defineCustomElement as d };