scrim.js 2.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  1. /*!
  2. * All material copyright ESRI, All Rights Reserved, unless otherwise specified.
  3. * See https://github.com/Esri/calcite-components/blob/master/LICENSE.md for details.
  4. * v1.0.0-beta.97
  5. */
  6. import { h } from "@stencil/core";
  7. import { CSS, TEXT } from "./resources";
  8. /**
  9. * @slot - A slot for adding custom content, primarily loading information.
  10. */
  11. export class Scrim {
  12. constructor() {
  13. // --------------------------------------------------------------------------
  14. //
  15. // Properties
  16. //
  17. // --------------------------------------------------------------------------
  18. /**
  19. * Accessible name when the component is loading.
  20. *
  21. * @default "Loading"
  22. */
  23. this.intlLoading = TEXT.loading;
  24. /**
  25. * When `true`, a busy indicator is displayed.
  26. */
  27. this.loading = false;
  28. }
  29. // --------------------------------------------------------------------------
  30. //
  31. // Render Method
  32. //
  33. // --------------------------------------------------------------------------
  34. render() {
  35. const { el, loading, intlLoading } = this;
  36. const hasContent = el.innerHTML.trim().length > 0;
  37. const loaderNode = loading ? h("calcite-loader", { active: true, label: intlLoading }) : null;
  38. const contentNode = hasContent ? (h("div", { class: CSS.content }, h("slot", null))) : null;
  39. return (h("div", { class: CSS.scrim }, loaderNode, contentNode));
  40. }
  41. static get is() { return "calcite-scrim"; }
  42. static get encapsulation() { return "shadow"; }
  43. static get originalStyleUrls() {
  44. return {
  45. "$": ["scrim.scss"]
  46. };
  47. }
  48. static get styleUrls() {
  49. return {
  50. "$": ["scrim.css"]
  51. };
  52. }
  53. static get properties() {
  54. return {
  55. "intlLoading": {
  56. "type": "string",
  57. "mutable": false,
  58. "complexType": {
  59. "original": "string",
  60. "resolved": "string",
  61. "references": {}
  62. },
  63. "required": false,
  64. "optional": true,
  65. "docs": {
  66. "tags": [{
  67. "name": "default",
  68. "text": "\"Loading\""
  69. }],
  70. "text": "Accessible name when the component is loading."
  71. },
  72. "attribute": "intl-loading",
  73. "reflect": false,
  74. "defaultValue": "TEXT.loading"
  75. },
  76. "loading": {
  77. "type": "boolean",
  78. "mutable": false,
  79. "complexType": {
  80. "original": "boolean",
  81. "resolved": "boolean",
  82. "references": {}
  83. },
  84. "required": false,
  85. "optional": false,
  86. "docs": {
  87. "tags": [],
  88. "text": "When `true`, a busy indicator is displayed."
  89. },
  90. "attribute": "loading",
  91. "reflect": true,
  92. "defaultValue": "false"
  93. }
  94. };
  95. }
  96. static get elementRef() { return "el"; }
  97. }