2021-09-29 12:40:26 +00:00
|
|
|
import { classMap } from 'lit/directives/class-map.js';
|
2023-01-13 20:43:55 +00:00
|
|
|
import { customElement, property } from 'lit/decorators.js';
|
|
|
|
import { html } from 'lit';
|
2022-08-17 15:37:37 +00:00
|
|
|
import ShoelaceElement from '../../internal/shoelace-element';
|
2021-07-10 00:45:44 +00:00
|
|
|
import styles from './skeleton.styles';
|
2022-07-19 12:27:39 +00:00
|
|
|
import type { CSSResultGroup } from 'lit';
|
2020-07-27 20:20:15 +00:00
|
|
|
|
|
|
|
/**
|
2023-01-12 15:26:25 +00:00
|
|
|
* @summary Skeletons are used to provide a visual representation of where content will eventually be drawn.
|
|
|
|
* @documentation https://shoelace.style/components/skeleton
|
2020-07-27 20:20:15 +00:00
|
|
|
* @status stable
|
2023-01-12 15:26:25 +00:00
|
|
|
* @since 2.0
|
2020-07-27 20:20:15 +00:00
|
|
|
*
|
2022-12-06 16:18:14 +00:00
|
|
|
* @csspart base - The component's base wrapper.
|
2021-06-25 20:25:46 +00:00
|
|
|
* @csspart indicator - The skeleton's indicator which is responsible for its color and animation.
|
2021-05-17 22:04:28 +00:00
|
|
|
*
|
2021-06-25 20:25:46 +00:00
|
|
|
* @cssproperty --border-radius - The skeleton's border radius.
|
|
|
|
* @cssproperty --color - The color of the skeleton.
|
|
|
|
* @cssproperty --sheen-color - The sheen color when the skeleton is in its loading state.
|
2020-07-27 20:20:15 +00:00
|
|
|
*/
|
2021-03-18 13:04:23 +00:00
|
|
|
@customElement('sl-skeleton')
|
2022-08-17 15:37:37 +00:00
|
|
|
export default class SlSkeleton extends ShoelaceElement {
|
2022-07-19 12:27:39 +00:00
|
|
|
static styles: CSSResultGroup = styles;
|
2020-07-27 20:20:15 +00:00
|
|
|
|
2020-07-28 12:41:45 +00:00
|
|
|
/** Determines which effect the skeleton will use. */
|
2021-08-18 21:30:51 +00:00
|
|
|
@property() effect: 'pulse' | 'sheen' | 'none' = 'none';
|
2020-07-27 20:20:15 +00:00
|
|
|
|
|
|
|
render() {
|
2021-02-26 14:09:13 +00:00
|
|
|
return html`
|
2020-07-27 20:20:15 +00:00
|
|
|
<div
|
|
|
|
part="base"
|
2021-02-26 14:09:13 +00:00
|
|
|
class=${classMap({
|
2020-07-27 20:20:15 +00:00
|
|
|
skeleton: true,
|
2020-07-28 12:41:45 +00:00
|
|
|
'skeleton--pulse': this.effect === 'pulse',
|
|
|
|
'skeleton--sheen': this.effect === 'sheen'
|
2021-02-26 14:09:13 +00:00
|
|
|
})}
|
2020-07-28 12:41:45 +00:00
|
|
|
>
|
2021-03-06 17:01:39 +00:00
|
|
|
<div part="indicator" class="skeleton__indicator"></div>
|
2020-07-28 12:41:45 +00:00
|
|
|
</div>
|
2021-02-26 14:09:13 +00:00
|
|
|
`;
|
2020-07-27 20:20:15 +00:00
|
|
|
}
|
|
|
|
}
|
2021-03-12 14:07:38 +00:00
|
|
|
|
2021-03-12 14:09:08 +00:00
|
|
|
declare global {
|
|
|
|
interface HTMLElementTagNameMap {
|
|
|
|
'sl-skeleton': SlSkeleton;
|
|
|
|
}
|
|
|
|
}
|