@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
164 lines (154 loc) • 8.75 kB
JavaScript
import { r as registerInstance, h, H as Host, g as getElement } from './index-dzXW86AR.js';
import { i as inheritAriaAttributes } from './utils-B8RUyqeq.js';
const convertPropsToClasses$1 = ({ shape, size, }) => {
let classes = '';
if (shape) {
switch (shape) {
case 'circle':
classes = `${classes} modus-wc-rounded-full`;
break;
case 'square':
classes = `${classes} modus-wc-rounded-lg`;
break;
}
}
if (size) {
switch (size) {
case 'xs':
classes = `${classes} modus-wc-w-8`;
break;
case 'sm':
classes = `${classes} modus-wc-w-12`;
break;
case 'md':
classes = `${classes} modus-wc-w-16`;
break;
case 'lg':
classes = `${classes} modus-wc-w-20`;
break;
}
}
return classes.trim();
};
const modusWcAvatarCss = "";
const ModusWcAvatar = class {
constructor(hostRef) {
registerInstance(this, hostRef);
this.inheritedAttributes = {};
/** Custom CSS class to apply to the inner div. */
this.customClass = '';
/** The location of the image. */
this.imgSrc = '';
// TODO - add placeholder support (need UX logic)
/** The shape of the avatar. */
this.shape = 'circle';
/** The size of the avatar. */
this.size = 'md';
}
componentWillLoad() {
if (!this.alt || !this.el.ariaLabel) {
this.el.ariaLabel = this.el.ariaLabel || `Avatar ${this.alt || 'image'}`;
this.alt = this.alt || 'Avatar image';
}
this.inheritedAttributes = inheritAriaAttributes(this.el);
}
getClasses() {
const classList = [];
const propClasses = convertPropsToClasses$1({
shape: this.shape,
size: this.size,
});
// 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: '74b2dc1cfcb9d73281d7ad3fea109a113254e52a' }, h("div", Object.assign({ key: '2429d8991e4b8467e432210331481f23ce19cb9f', class: "modus-wc-avatar", tabindex: -1 }, this.inheritedAttributes), h("div", { key: 'dc7a02e2a442a1d0dd50f946be8f45657ee1f7aa', class: this.getClasses() }, h("img", { key: 'b18286cf860566cc2176af6df9f8e38ccb488d91', src: this.imgSrc, alt: this.alt })))));
}
get el() { return getElement(this); }
};
ModusWcAvatar.style = modusWcAvatarCss;
const convertPropsToClasses = ({ bordered, fullImage, layout, padding, }) => {
let classes = '';
if (bordered) {
classes = `${classes} modus-wc-card-bordered`;
}
if (fullImage) {
classes = `${classes} modus-wc-image-full`;
}
if (layout === 'horizontal') {
classes = `${classes} modus-wc-card-side`;
}
if (padding === 'compact') {
classes = `${classes} modus-wc-card-compact`;
}
return classes.trim();
};
const modusWcCardCss = "modus-wc-card .modus-wc-card{background-color:var(--modus-wc-color-base-100);color:var(--modus-wc-color-base-content)}[data-theme=modus-classic-light] modus-wc-card .modus-wc-card,[data-theme=modus-classic-dark] modus-wc-card .modus-wc-card{--rounded-box:0.5rem;box-shadow:0 0 2px 0 rgba(54, 53, 69, 0.3)}[data-theme=modus-classic-light] modus-wc-card .modus-wc-card:hover,[data-theme=modus-classic-dark] modus-wc-card .modus-wc-card:hover{box-shadow:0 0 8px 0 rgba(54, 53, 69, 0.3)}[data-theme=modus-classic-light] modus-wc-card .modus-wc-card .modus-wc-card-subtitle,[data-theme=modus-classic-dark] modus-wc-card .modus-wc-card .modus-wc-card-subtitle{font-weight:var(--modus-wc-font-weight-bold)}[data-theme=modus-classic-light] modus-wc-card .modus-wc-card{background-color:var(--modus-wc-color-white);color:var(--modus-wc-color-trimble-gray)}[data-theme=modus-classic-light] modus-wc-card .modus-wc-card .modus-wc-card-title{--fallback-bc:var(--modus-wc-color-trimble-gray)}[data-theme=modus-classic-light] modus-wc-card .modus-wc-card .modus-wc-card-subtitle{color:var(--modus-wc-color-gray-8)}[data-theme=modus-classic-dark] modus-wc-card .modus-wc-card{background-color:var(--modus-wc-color-gray-9);color:var(--modus-wc-color-trimble-white)}[data-theme=modus-classic-dark] modus-wc-card .modus-wc-card .modus-wc-card-title{--fallback-bc:var(--modus-wc-color-white)}[data-theme=modus-classic-dark] modus-wc-card .modus-wc-card .modus-wc-card-subtitle{color:var(--modus-wc-color-gray-1)}";
const ModusWcCard = class {
constructor(hostRef) {
registerInstance(this, hostRef);
this.inheritedAttributes = {};
/** Makes any \<figure> in the 'header' slot cover the background */
this.backgroundFigure = false;
/** Adds a hard border to the card */
this.bordered = false;
/** Custom CSS class to apply */
this.customClass = '';
/** Determines how the card is laid out */
this.layout = 'vertical';
/** Determines if the interior padding is compact or not */
this.padding = 'normal';
}
componentWillLoad() {
this.inheritedAttributes = inheritAriaAttributes(this.el);
}
getClasses() {
const classList = ['modus-wc-card modus-wc-rounded-card'];
const propClasses = convertPropsToClasses({
bordered: this.bordered,
fullImage: this.backgroundFigure,
layout: this.layout,
padding: this.padding,
});
// 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: 'ca2b66643d841254021b36a02cc009e0287547f9' }, h("article", Object.assign({ key: 'e5cfc8a5cc1d81f0f2924a596c88bb72186b66ad', class: this.getClasses(), tabindex: -1 }, this.inheritedAttributes), h("slot", { key: 'bb24bca92c338faa1d7768d11707f88620f8e9dd', name: "header" }), h("div", { key: '153d844a35591665a67b31e0f9938aa87b855fd0', class: "modus-wc-card-body" }, h("div", { key: '1a32e26e9b06c67ccf2fc067455365d3a8a59f4c', class: "modus-wc-card-title" }, h("slot", { key: 'df11f9713f650008850fe4af85f22b5d0f2da14e', name: "title" })), h("div", { key: 'e9d8c639387b70fab75e482e7a84e8e3078141b9', class: "modus-wc-card-subtitle" }, h("slot", { key: '56bb3d18aad738ed11249c7c3a12fd6aeedee389', name: "subtitle" })), h("slot", { key: '5a0a22778a3c36f4d28eb4d560e35e937e39377e' }), " ", h("div", { key: '671978aedd0cee74ed04c726e2ca4d71b77ea837', class: "modus-wc-card-actions" }, h("slot", { key: '6792bcebe07fbe000521b70ec3dd731976f4c99c', name: "actions" }))), h("slot", { key: 'cfb58923ff84b64540ed6d02e21855844d0fb42e', name: "footer" }))));
}
get el() { return getElement(this); }
};
ModusWcCard.style = modusWcCardCss;
const modusWcToolbarCss = "";
const ModusWcToolbar = class {
constructor(hostRef) {
registerInstance(this, hostRef);
this.inheritedAttributes = {};
/** Custom CSS class to apply to the outer div. */
this.customClass = '';
}
componentWillLoad() {
this.inheritedAttributes = inheritAriaAttributes(this.el);
}
getClasses() {
const classList = ['modus-wc-navbar'];
// The order CSS classes are added matters to CSS specificity
if (this.customClass)
classList.push(this.customClass);
return classList.join(' ');
}
render() {
return (h(Host, { key: '569cac670489a353e6108ee75a54a1ff4f6628c4' }, h("div", Object.assign({ key: '7f8d00e6422d372f567a496282e5202bd6feb0cb', class: this.getClasses() }, this.inheritedAttributes), h("div", { key: '5746cbffd677ec9ddf4233ee24dba79b9177b0ab', class: "modus-wc-navbar-start" }, h("slot", { key: '83e0d6acbf0af02f043f519b7b1204fa4fd236aa', name: "start" })), h("div", { key: '71f0e3bc55eff2b33f3aaf49897866b925ff9e78', class: "modus-wc-navbar-center" }, h("slot", { key: '5ac1f5cee7940fa20cf892fa3f50fff465006fc1', name: "center" })), h("div", { key: 'a4ad7761e3d149e36ab19d17fa791f95b2e530d7', class: "modus-wc-navbar-end" }, h("slot", { key: '744bda599a290f5e3d8fc282918c90ff57f20277', name: "end" })))));
}
get el() { return getElement(this); }
};
ModusWcToolbar.style = modusWcToolbarCss;
export { ModusWcAvatar as modus_wc_avatar, ModusWcCard as modus_wc_card, ModusWcToolbar as modus_wc_toolbar };