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

189 lines (188 loc) 7.07 kB
import { h, Host } from "@stencil/core"; import { convertPropsToClasses } from "./modus-wc-divider.tailwind"; import { handleShadowDOMStyles } from "../base-component"; import { inheritAriaAttributes } from "../utils"; /** * A customizable divider component used to separate content horizontally or vertically */ export class ModusWcDivider { constructor() { this.inheritedAttributes = {}; /** The color of the divider line. */ this.color = 'tertiary'; /** The content to display in the divider. */ this.content = ''; /** Custom CSS class to apply to the divider element. */ this.customClass = ''; /** The orientation of the divider. This is in reference to how content will be rendered around the divider. */ this.orientation = 'vertical'; /** The position of the divider. */ this.position = 'center'; /** Whether the divider is responsive or not. */ this.responsive = true; } componentWillLoad() { handleShadowDOMStyles(this.el); this.inheritedAttributes = inheritAriaAttributes(this.el); } getClasses() { const classList = ['modus-wc-divider']; const propClasses = convertPropsToClasses({ color: this.color, orientation: this.orientation, position: this.position, responsive: this.responsive, }); // 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: '474cecf457882c0a5b2841cb66d6b5513e561257' }, h("div", Object.assign({ key: '23f987f4fc75b44987908e4611e6b72b16a0f008', class: this.getClasses(), tabindex: -1 }, this.inheritedAttributes), this.content))); } static get is() { return "modus-wc-divider"; } static get originalStyleUrls() { return { "$": ["modus-wc-divider.scss"] }; } static get styleUrls() { return { "$": ["modus-wc-divider.css"] }; } static get properties() { return { "color": { "type": "string", "attribute": "color", "mutable": false, "complexType": { "original": "| 'primary'\n | 'secondary'\n | 'tertiary'\n | 'high-contrast'\n | 'success'\n | 'warning'\n | 'danger'", "resolved": "\"danger\" | \"high-contrast\" | \"primary\" | \"secondary\" | \"success\" | \"tertiary\" | \"warning\" | undefined", "references": {} }, "required": false, "optional": true, "docs": { "tags": [], "text": "The color of the divider line." }, "getter": false, "setter": false, "reflect": false, "defaultValue": "'tertiary'" }, "content": { "type": "string", "attribute": "content", "mutable": false, "complexType": { "original": "string", "resolved": "string | undefined", "references": {} }, "required": false, "optional": true, "docs": { "tags": [], "text": "The content to display in the divider." }, "getter": false, "setter": false, "reflect": false, "defaultValue": "''" }, "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 divider element." }, "getter": false, "setter": false, "reflect": false, "defaultValue": "''" }, "orientation": { "type": "string", "attribute": "orientation", "mutable": false, "complexType": { "original": "Orientation", "resolved": "\"horizontal\" | \"vertical\" | undefined", "references": { "Orientation": { "location": "import", "path": "../types", "id": "src/components/types.ts::Orientation" } } }, "required": false, "optional": true, "docs": { "tags": [], "text": "The orientation of the divider. This is in reference to how content will be rendered around the divider." }, "getter": false, "setter": false, "reflect": false, "defaultValue": "'vertical'" }, "position": { "type": "string", "attribute": "position", "mutable": false, "complexType": { "original": "'center' | 'end' | 'start'", "resolved": "\"center\" | \"end\" | \"start\" | undefined", "references": {} }, "required": false, "optional": true, "docs": { "tags": [], "text": "The position of the divider." }, "getter": false, "setter": false, "reflect": false, "defaultValue": "'center'" }, "responsive": { "type": "boolean", "attribute": "responsive", "mutable": false, "complexType": { "original": "boolean", "resolved": "boolean | undefined", "references": {} }, "required": false, "optional": true, "docs": { "tags": [], "text": "Whether the divider is responsive or not." }, "getter": false, "setter": false, "reflect": false, "defaultValue": "true" } }; } static get elementRef() { return "el"; } }