shoelace/src/components/skeleton/skeleton.ts

47 wiersze
1.3 KiB
TypeScript
Czysty Zwykły widok Historia

2021-07-10 00:45:44 +00:00
import { LitElement, html } from 'lit';
2021-05-27 21:00:43 +00:00
import { customElement, property } from 'lit/decorators.js';
2021-09-21 02:01:21 +00:00
import { classMap } from 'lit-html/directives/class-map.js';
2021-07-10 00:45:44 +00:00
import styles from './skeleton.styles';
2020-07-27 20:20:15 +00:00
/**
* @since 2.0
* @status stable
*
2021-06-25 20:25:46 +00:00
* @csspart base - The component's base wrapper.
* @csspart indicator - The skeleton's indicator which is responsible for its color and animation.
*
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')
2021-03-09 00:14:32 +00:00
export default class SlSkeleton extends LitElement {
2021-07-10 00:45:44 +00:00
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-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-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
>
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:09:08 +00:00
declare global {
interface HTMLElementTagNameMap {
'sl-skeleton': SlSkeleton;
}
}