123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256 |
- /*!
- * All material copyright ESRI, All Rights Reserved, unless otherwise specified.
- * See https://github.com/Esri/calcite-components/blob/master/LICENSE.md for details.
- * v1.0.0-beta.97
- */
- import { Fragment, h } from "@stencil/core";
- import { SLOTS } from "./resources";
- import { getSlotted } from "../../utils/dom";
- import { connectConditionalSlotComponent, disconnectConditionalSlotComponent } from "../../utils/conditionalSlot";
- import { updateHostInteraction } from "../../utils/interactive";
- /**
- * @slot content-start - A slot for adding non-actionable elements before the component's content.
- * @slot content-end - A slot for adding non-actionable elements after the component's content.
- */
- export class Tile {
- constructor() {
- //--------------------------------------------------------------------------
- //
- // Properties
- //
- //--------------------------------------------------------------------------
- /**
- * When `true`, the component is active.
- */
- this.active = false;
- /**
- * When `true`, interaction is prevented and the component is displayed with lower opacity.
- */
- this.disabled = false;
- /**
- * The component's embed mode.
- *
- * When `true`, renders without a border and padding for use by other components.
- */
- this.embed = false;
- /**
- * The focused state of the component.
- *
- * @internal
- */
- this.focused = false;
- /** When `true`, the component is not displayed and is not focusable. */
- this.hidden = false;
- }
- // --------------------------------------------------------------------------
- //
- // Lifecycle
- //
- // --------------------------------------------------------------------------
- connectedCallback() {
- connectConditionalSlotComponent(this);
- }
- disconnectedCallback() {
- disconnectConditionalSlotComponent(this);
- }
- componentDidRender() {
- updateHostInteraction(this);
- }
- // --------------------------------------------------------------------------
- //
- // Render Methods
- //
- // --------------------------------------------------------------------------
- renderTile() {
- const { icon, el, heading, description } = this;
- const isLargeVisual = heading && icon && !description;
- const iconStyle = isLargeVisual
- ? {
- height: "64px",
- width: "64px"
- }
- : undefined;
- return (h("div", { class: { container: true, "large-visual": isLargeVisual } }, icon && (h("div", { class: "icon" }, h("calcite-icon", { icon: icon, scale: "l", style: iconStyle }))), h("div", { class: "content-container" }, getSlotted(el, SLOTS.contentStart) ? (h("div", { class: "content-slot-container" }, h("slot", { name: SLOTS.contentStart }))) : null, h("div", { class: "content" }, heading && h("div", { class: "heading" }, heading), description && h("div", { class: "description" }, description)), getSlotted(el, SLOTS.contentEnd) ? (h("div", { class: "content-slot-container" }, h("slot", { name: SLOTS.contentEnd }))) : null)));
- }
- render() {
- return (h(Fragment, null, this.href ? (h("calcite-link", { disabled: this.disabled, href: this.href }, this.renderTile())) : (this.renderTile())));
- }
- static get is() { return "calcite-tile"; }
- static get encapsulation() { return "shadow"; }
- static get originalStyleUrls() {
- return {
- "$": ["tile.scss"]
- };
- }
- static get styleUrls() {
- return {
- "$": ["tile.css"]
- };
- }
- static get properties() {
- return {
- "active": {
- "type": "boolean",
- "mutable": false,
- "complexType": {
- "original": "boolean",
- "resolved": "boolean",
- "references": {}
- },
- "required": false,
- "optional": false,
- "docs": {
- "tags": [],
- "text": "When `true`, the component is active."
- },
- "attribute": "active",
- "reflect": true,
- "defaultValue": "false"
- },
- "description": {
- "type": "string",
- "mutable": false,
- "complexType": {
- "original": "string",
- "resolved": "string",
- "references": {}
- },
- "required": false,
- "optional": true,
- "docs": {
- "tags": [],
- "text": "A description for the component, which displays below the heading."
- },
- "attribute": "description",
- "reflect": true
- },
- "disabled": {
- "type": "boolean",
- "mutable": false,
- "complexType": {
- "original": "boolean",
- "resolved": "boolean",
- "references": {}
- },
- "required": false,
- "optional": false,
- "docs": {
- "tags": [],
- "text": "When `true`, interaction is prevented and the component is displayed with lower opacity."
- },
- "attribute": "disabled",
- "reflect": true,
- "defaultValue": "false"
- },
- "embed": {
- "type": "boolean",
- "mutable": false,
- "complexType": {
- "original": "boolean",
- "resolved": "boolean",
- "references": {}
- },
- "required": false,
- "optional": false,
- "docs": {
- "tags": [],
- "text": "The component's embed mode.\n\nWhen `true`, renders without a border and padding for use by other components."
- },
- "attribute": "embed",
- "reflect": true,
- "defaultValue": "false"
- },
- "focused": {
- "type": "boolean",
- "mutable": false,
- "complexType": {
- "original": "boolean",
- "resolved": "boolean",
- "references": {}
- },
- "required": false,
- "optional": false,
- "docs": {
- "tags": [{
- "name": "internal",
- "text": undefined
- }],
- "text": "The focused state of the component."
- },
- "attribute": "focused",
- "reflect": true,
- "defaultValue": "false"
- },
- "heading": {
- "type": "string",
- "mutable": false,
- "complexType": {
- "original": "string",
- "resolved": "string",
- "references": {}
- },
- "required": false,
- "optional": true,
- "docs": {
- "tags": [],
- "text": "The component header text, which displays between the icon and description."
- },
- "attribute": "heading",
- "reflect": true
- },
- "hidden": {
- "type": "boolean",
- "mutable": false,
- "complexType": {
- "original": "boolean",
- "resolved": "boolean",
- "references": {}
- },
- "required": false,
- "optional": false,
- "docs": {
- "tags": [],
- "text": "When `true`, the component is not displayed and is not focusable."
- },
- "attribute": "hidden",
- "reflect": true,
- "defaultValue": "false"
- },
- "href": {
- "type": "string",
- "mutable": false,
- "complexType": {
- "original": "string",
- "resolved": "string",
- "references": {}
- },
- "required": false,
- "optional": true,
- "docs": {
- "tags": [],
- "text": "When embed is `\"false\"`, the URL for the component."
- },
- "attribute": "href",
- "reflect": true
- },
- "icon": {
- "type": "string",
- "mutable": false,
- "complexType": {
- "original": "string",
- "resolved": "string",
- "references": {}
- },
- "required": false,
- "optional": true,
- "docs": {
- "tags": [],
- "text": "Specifies an icon to display."
- },
- "attribute": "icon",
- "reflect": true
- }
- };
- }
- static get elementRef() { return "el"; }
- }
|