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

138 lines (137 loc) 5.33 kB
import { h, Host } from "@stencil/core"; import { handleShadowDOMStyles } from "../base-component"; import { inheritAriaAttributes } from "../utils"; import { convertPropsToClasses } from "./modus-wc-panel.tailwind"; /** * A customizable panel component used to organize content in a structured layout. * * This component provides 'header', 'body', and 'footer' `<slot>` elements for inserting custom HTML. */ export class ModusWcPanel { constructor() { this.inheritedAttributes = {}; /** Custom CSS class to apply to the outer div. */ this.customClass = ''; /** Width of the panel in pixels. */ this.width = '350px'; /** Height of the panel in pixels. */ this.height = '700px'; /** Enable floating mode with elevated shadow. */ this.floating = false; } componentWillLoad() { handleShadowDOMStyles(this.el, true); this.inheritedAttributes = inheritAriaAttributes(this.el); } getClasses() { const classList = ['modus-wc-panel']; const propClasses = convertPropsToClasses({ floating: this.floating, }); // 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: '346b3f3311332d988c5cca8f723949f918e02629' }, h("div", Object.assign({ key: 'd4032f052570ecfd89112158708889673c308d40', class: this.getClasses(), style: { width: this.width, height: this.height } }, this.inheritedAttributes), h("div", { key: '0eea8053a7bbb15ded21417012d7fb0371efb72a', class: "modus-wc-panel-header" }, h("slot", { key: '0b0e4ffb23fa198b3d4f3b42e4a36f76267712fe', name: "header" })), h("div", { key: 'f9f3854f600b57f4a095706329fb3ea0a6a8e66b', class: "modus-wc-panel-body" }, h("slot", { key: '82872e1178777b26e071285a1e79a564eca00152', name: "body" })), h("div", { key: 'dc0402db9837329d25dc33fd2c17be6c5242bd0c', class: "modus-wc-panel-footer" }, h("slot", { key: '3b8399ba61bb5f2585ae60a961f864b20321bbbd', name: "footer" }))))); } static get is() { return "modus-wc-panel"; } static get originalStyleUrls() { return { "$": ["modus-wc-panel.scss"] }; } static get styleUrls() { return { "$": ["modus-wc-panel.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 outer div." }, "getter": false, "setter": false, "reflect": false, "defaultValue": "''" }, "width": { "type": "string", "attribute": "width", "mutable": false, "complexType": { "original": "string", "resolved": "string | undefined", "references": {} }, "required": false, "optional": true, "docs": { "tags": [], "text": "Width of the panel in pixels." }, "getter": false, "setter": false, "reflect": false, "defaultValue": "'350px'" }, "height": { "type": "string", "attribute": "height", "mutable": false, "complexType": { "original": "string", "resolved": "string | undefined", "references": {} }, "required": false, "optional": true, "docs": { "tags": [], "text": "Height of the panel in pixels." }, "getter": false, "setter": false, "reflect": false, "defaultValue": "'700px'" }, "floating": { "type": "boolean", "attribute": "floating", "mutable": false, "complexType": { "original": "boolean", "resolved": "boolean | undefined", "references": {} }, "required": false, "optional": true, "docs": { "tags": [], "text": "Enable floating mode with elevated shadow." }, "getter": false, "setter": false, "reflect": false, "defaultValue": "false" } }; } static get elementRef() { return "el"; } }