UNPKG

3.21 kBJavaScriptView Raw
1/*!
2 * (C) Ionic http://ionicframework.com - MIT License
3 */
4import { proxyCustomElement, HTMLElement, h, Host } from '@stencil/core/internal/client';
5import { c as config, b as getIonMode } from './ionic-global.js';
6import { h as hostContext } from './theme.js';
7
8const 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
10const SkeletonText = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement {
11 constructor() {
12 super();
13 this.__registerHost();
14 this.__attachShadow();
15 /**
16 * If `true`, the skeleton text will animate.
17 */
18 this.animated = false;
19 }
20 render() {
21 const animated = this.animated && config.getBoolean('animated', true);
22 const inMedia = hostContext('ion-avatar', this.el) || hostContext('ion-thumbnail', this.el);
23 const mode = getIonMode(this);
24 return (h(Host, { class: {
25 [mode]: true,
26 'skeleton-text-animated': animated,
27 'in-media': inMedia
28 } }, h("span", null, "\u00A0")));
29 }
30 get el() { return this; }
31 static get style() { return skeletonTextCss; }
32}, [1, "ion-skeleton-text", {
33 "animated": [4]
34 }]);
35function defineCustomElement$1() {
36 if (typeof customElements === "undefined") {
37 return;
38 }
39 const components = ["ion-skeleton-text"];
40 components.forEach(tagName => { switch (tagName) {
41 case "ion-skeleton-text":
42 if (!customElements.get(tagName)) {
43 customElements.define(tagName, SkeletonText);
44 }
45 break;
46 } });
47}
48
49const IonSkeletonText = SkeletonText;
50const defineCustomElement = defineCustomElement$1;
51
52export { IonSkeletonText, defineCustomElement };