UNPKG

@vime/core

Version:

Customizable, extensible, accessible and framework agnostic media player.

100 lines (99 loc) 2.58 kB
import { Component, h, Prop, State, Watch } from '@stencil/core'; import { withComponentRegistry } from '../../core/player/withComponentRegistry'; import { withPlayerContext } from '../../core/player/withPlayerContext'; /** * A temporary placeholder that is used while content is loading. The implementation was inspired * by [Shoelace](https://github.com/shoelace-style/shoelace), thanks Cory! */ export class Skeleton { constructor() { this.hidden = false; /** * Determines which animation effect the skeleton will use. * */ this.effect = 'sheen'; /** @internal */ this.ready = false; withComponentRegistry(this); withPlayerContext(this, ['ready']); } onReadyChange() { if (!this.ready) { this.hidden = false; } else { setTimeout(() => { this.hidden = true; }, 500); } } render() { return (h("div", { class: { skeleton: true, hidden: this.hidden, sheen: this.effect === 'sheen', } }, h("div", { class: "indicator" }))); } static get is() { return "vm-skeleton"; } static get encapsulation() { return "shadow"; } static get originalStyleUrls() { return { "$": ["skeleton.css"] }; } static get styleUrls() { return { "$": ["skeleton.css"] }; } static get properties() { return { "effect": { "type": "string", "mutable": false, "complexType": { "original": "'sheen' | 'none'", "resolved": "\"none\" | \"sheen\"", "references": {} }, "required": false, "optional": false, "docs": { "tags": [], "text": "Determines which animation effect the skeleton will use." }, "attribute": "effect", "reflect": false, "defaultValue": "'sheen'" }, "ready": { "type": "boolean", "mutable": false, "complexType": { "original": "PlayerProps['ready']", "resolved": "boolean", "references": { "PlayerProps": { "location": "import", "path": "../../core/player/PlayerProps" } } }, "required": false, "optional": false, "docs": { "tags": [{ "text": undefined, "name": "internal" }], "text": "" }, "attribute": "ready", "reflect": false, "defaultValue": "false" } }; } static get states() { return { "hidden": {} }; } static get watchers() { return [{ "propName": "ready", "methodName": "onReadyChange" }]; } }