ion-skeleton-text.js 3.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. /*!
  2. * (C) Ionic http://ionicframework.com - MIT License
  3. */
  4. import { proxyCustomElement, HTMLElement, createEvent, h, Host } from '@stencil/core/internal/client';
  5. import { h as hostContext } from './theme.js';
  6. import { c as config } from './index4.js';
  7. import { b as getIonMode } from './ionic-global.js';
  8. const skeletonTextCss = ":host{--background:rgba(var(--background-rgb, var(--ion-text-color-rgb, 0, 0, 0)), 0.065);border-radius:var(--border-radius, inherit);display:block;width:100%;height:inherit;margin-top:4px;margin-bottom:4px;background:var(--background);line-height:10px;-webkit-user-select:none;-moz-user-select:none;-ms-user-select:none;user-select:none;pointer-events:none}span{display:inline-block}:host(.in-media){margin-left:0;margin-right:0;margin-top:0;margin-bottom:0;height:100%}:host(.skeleton-text-animated){position:relative;background:-webkit-gradient(linear, left top, right top, color-stop(8%, rgba(var(--background-rgb, var(--ion-text-color-rgb, 0, 0, 0)), 0.065)), color-stop(18%, rgba(var(--background-rgb, var(--ion-text-color-rgb, 0, 0, 0)), 0.135)), color-stop(33%, rgba(var(--background-rgb, var(--ion-text-color-rgb, 0, 0, 0)), 0.065)));background:linear-gradient(to right, rgba(var(--background-rgb, var(--ion-text-color-rgb, 0, 0, 0)), 0.065) 8%, rgba(var(--background-rgb, var(--ion-text-color-rgb, 0, 0, 0)), 0.135) 18%, rgba(var(--background-rgb, var(--ion-text-color-rgb, 0, 0, 0)), 0.065) 33%);background-size:800px 104px;-webkit-animation-duration:1s;animation-duration:1s;-webkit-animation-fill-mode:forwards;animation-fill-mode:forwards;-webkit-animation-iteration-count:infinite;animation-iteration-count:infinite;-webkit-animation-name:shimmer;animation-name:shimmer;-webkit-animation-timing-function:linear;animation-timing-function:linear}@-webkit-keyframes shimmer{0%{background-position:-400px 0}100%{background-position:400px 0}}@keyframes shimmer{0%{background-position:-400px 0}100%{background-position:400px 0}}";
  9. const IonSkeletonTextStyle0 = skeletonTextCss;
  10. const SkeletonText = /*@__PURE__*/ proxyCustomElement(class SkeletonText extends HTMLElement {
  11. constructor() {
  12. super();
  13. this.__registerHost();
  14. this.__attachShadow();
  15. this.ionStyle = createEvent(this, "ionStyle", 7);
  16. this.animated = false;
  17. }
  18. componentWillLoad() {
  19. this.emitStyle();
  20. }
  21. emitStyle() {
  22. // The emitted property is used by item in order
  23. // to add the item-skeleton-text class which applies
  24. // overflow: hidden to its label
  25. const style = {
  26. 'skeleton-text': true,
  27. };
  28. this.ionStyle.emit(style);
  29. }
  30. render() {
  31. const animated = this.animated && config.getBoolean('animated', true);
  32. const inMedia = hostContext('ion-avatar', this.el) || hostContext('ion-thumbnail', this.el);
  33. const mode = getIonMode(this);
  34. return (h(Host, { key: 'c193f9a8e8efab5139544f047bdae4b6d421aa86', class: {
  35. [mode]: true,
  36. 'skeleton-text-animated': animated,
  37. 'in-media': inMedia,
  38. } }, h("span", { key: 'e15db679bd3c359b4df5123efd2f92e5b380fde3' }, "\u00A0")));
  39. }
  40. get el() { return this; }
  41. static get style() { return IonSkeletonTextStyle0; }
  42. }, [1, "ion-skeleton-text", {
  43. "animated": [4]
  44. }]);
  45. function defineCustomElement$1() {
  46. if (typeof customElements === "undefined") {
  47. return;
  48. }
  49. const components = ["ion-skeleton-text"];
  50. components.forEach(tagName => { switch (tagName) {
  51. case "ion-skeleton-text":
  52. if (!customElements.get(tagName)) {
  53. customElements.define(tagName, SkeletonText);
  54. }
  55. break;
  56. } });
  57. }
  58. const IonSkeletonText = SkeletonText;
  59. const defineCustomElement = defineCustomElement$1;
  60. export { IonSkeletonText, defineCustomElement };