UNPKG

@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

155 lines (154 loc) 5.93 kB
import { h, Host } from "@stencil/core"; import { convertPropsToClasses } from "./modus-wc-typography.tailwind"; import { inheritAriaAttributes } from "../utils"; /** * A customizable typography component used to render text with different sizes, variants, and weights. */ export class ModusWCTypography { constructor() { this.inheritedAttributes = {}; /** Custom CSS class to apply to the typography element. */ this.customClass = ''; /** The size of the font. */ this.size = 'md'; /** The variant of the typography component. */ this.variant = 'p'; /** The weight of the text. */ this.weight = 'normal'; } componentWillLoad() { this.inheritedAttributes = inheritAriaAttributes(this.el); } getClasses() { const classList = ['modus-wc-typography']; const propClasses = convertPropsToClasses({ size: this.size, variant: this.variant, weight: this.weight, }); // 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() { const Element = this.variant; return (h(Host, { key: '16257a865edb9114db1b78e6d7fc4d5270d86097' }, h(Element, Object.assign({ key: '8acc8c880f58a343ff2e0fead7d977104ca8c2c4', class: this.getClasses() }, this.inheritedAttributes), h("slot", { key: 'f65699675ad22d3a4f1b85369c00bdf4c88ed4a8' })))); } static get is() { return "modus-wc-typography"; } static get originalStyleUrls() { return { "$": ["modus-wc-typography.scss"] }; } static get styleUrls() { return { "$": ["modus-wc-typography.css"] }; } static get properties() { return { "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 typography element." }, "getter": false, "setter": false, "reflect": false, "defaultValue": "''" }, "size": { "type": "string", "attribute": "size", "mutable": false, "complexType": { "original": "DaisySize", "resolved": "\"lg\" | \"md\" | \"sm\" | \"xs\" | undefined", "references": { "DaisySize": { "location": "import", "path": "../types", "id": "src/components/types.ts::DaisySize" } } }, "required": false, "optional": true, "docs": { "tags": [], "text": "The size of the font." }, "getter": false, "setter": false, "reflect": false, "defaultValue": "'md'" }, "variant": { "type": "string", "attribute": "variant", "mutable": false, "complexType": { "original": "TypographyVariant", "resolved": "\"body\" | \"h1\" | \"h2\" | \"h3\" | \"h4\" | \"h5\" | \"h6\" | \"p\"", "references": { "TypographyVariant": { "location": "local", "path": "/home/runner/work/modus-wc-2.0/modus-wc-2.0/src/components/modus-wc-typography/modus-wc-typography.tsx", "id": "src/components/modus-wc-typography/modus-wc-typography.tsx::TypographyVariant" } } }, "required": false, "optional": false, "docs": { "tags": [], "text": "The variant of the typography component." }, "getter": false, "setter": false, "reflect": false, "defaultValue": "'p'" }, "weight": { "type": "string", "attribute": "weight", "mutable": false, "complexType": { "original": "TypographyWeight", "resolved": "\"bold\" | \"light\" | \"normal\" | \"semibold\" | undefined", "references": { "TypographyWeight": { "location": "local", "path": "/home/runner/work/modus-wc-2.0/modus-wc-2.0/src/components/modus-wc-typography/modus-wc-typography.tsx", "id": "src/components/modus-wc-typography/modus-wc-typography.tsx::TypographyWeight" } } }, "required": false, "optional": true, "docs": { "tags": [], "text": "The weight of the text." }, "getter": false, "setter": false, "reflect": false, "defaultValue": "'normal'" } }; } static get elementRef() { return "el"; } }