UNPKG

@scania/tegel

Version:
98 lines (97 loc) 3.68 kB
import { h, Host } from "@stencil/core"; import hasSlot from "../../utils/hasSlot"; /** * @slot prefix - Slot used to display an icon or other content before the tag text. */ export class TdsTag { constructor() { /** Sets the size of the tag */ this.size = 'lg'; /** Sets the variant mode of the tag */ this.variant = 'Neutral'; } render() { const hasPrefixSlot = hasSlot('prefix', this.host); const getTagClasses = () => ({ [`${this.size.toLowerCase()}`]: true, [this.variant.toLowerCase()]: true, }); return (h(Host, { key: '6e014440b1933df324129ccb7ee25a4e6e28f7f5', class: getTagClasses() }, h("div", { key: '14605f18833dc92370646302cf0fd10106ae8600', class: "tds-tag__content" }, hasPrefixSlot && h("slot", { key: 'f6f426e202bee36eb53fc35b132b216ab74d7b6f', name: "prefix" }), h("span", { key: '15c5d2b25241ef26fe71ba37d2f16e3b0d88a9ce' }, this.text)))); } static get is() { return "tds-tag"; } static get encapsulation() { return "scoped"; } static get originalStyleUrls() { return { "$": ["tag.scss"] }; } static get styleUrls() { return { "$": ["tag.css"] }; } static get properties() { return { "text": { "type": "string", "mutable": false, "complexType": { "original": "string", "resolved": "string", "references": {} }, "required": true, "optional": false, "docs": { "tags": [], "text": "The title text to display in the tag" }, "getter": false, "setter": false, "reflect": false, "attribute": "text" }, "size": { "type": "string", "mutable": false, "complexType": { "original": "'lg' | 'sm'", "resolved": "\"lg\" | \"sm\"", "references": {} }, "required": false, "optional": false, "docs": { "tags": [], "text": "Sets the size of the tag" }, "getter": false, "setter": false, "reflect": false, "attribute": "size", "defaultValue": "'lg'" }, "variant": { "type": "string", "mutable": false, "complexType": { "original": "| 'success'\n | 'warning'\n | 'new'\n | 'neutral'\n | 'information'\n | 'error'\n | 'Success'\n | 'Warning'\n | 'New'\n | 'Neutral'\n | 'Information'\n | 'Error'", "resolved": "\"Error\" | \"Information\" | \"Neutral\" | \"New\" | \"Success\" | \"Warning\" | \"error\" | \"information\" | \"neutral\" | \"new\" | \"success\" | \"warning\"", "references": {} }, "required": false, "optional": false, "docs": { "tags": [], "text": "Sets the variant mode of the tag" }, "getter": false, "setter": false, "reflect": false, "attribute": "variant", "defaultValue": "'Neutral'" } }; } static get elementRef() { return "host"; } }