shoelace/src/components/skeleton/skeleton.ts

36 wiersze
923 B
TypeScript
Czysty Zwykły widok Historia

2021-02-26 14:09:13 +00:00
import { classMap, html, Shoemaker } from '@shoelace-style/shoemaker';
import styles from 'sass:./skeleton.scss';
2020-07-27 20:20:15 +00:00
/**
* @since 2.0
* @status stable
*
* @part base - The component's base wrapper.
2020-07-28 12:41:45 +00:00
* @part indicator - The skeleton's indicator which is responsible for its color and animation.
2020-07-27 20:20:15 +00:00
*/
2021-02-26 14:09:13 +00:00
export default class SlSkeleton extends Shoemaker {
static tag = 'sl-skeleton';
static props = ['effect'];
static styles = 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-02-26 14:09:13 +00:00
effect: 'pulse' | 'sheen' | 'none' = 'sheen';
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-10-23 02:45:41 +00:00
aria-busy="true"
2020-07-27 20:20:15 +00:00
aria-live="polite"
2020-07-28 12:41:45 +00:00
>
<div part="indicator" class="skeleton__indicator" />
</div>
2021-02-26 14:09:13 +00:00
`;
2020-07-27 20:20:15 +00:00
}
}