45 lines
941 B
Svelte
45 lines
941 B
Svelte
<script lang="ts">
|
|
interface Props {
|
|
width?: string;
|
|
height?: string;
|
|
circle?: boolean;
|
|
}
|
|
|
|
let { width = '100%', height = '14px', circle = false }: Props = $props();
|
|
|
|
const resolvedWidth = $derived(circle && width === '100%' ? height : width);
|
|
</script>
|
|
|
|
<div
|
|
class="skeleton"
|
|
class:circle
|
|
style:width={resolvedWidth}
|
|
style:height
|
|
aria-hidden="true"
|
|
></div>
|
|
|
|
<style>
|
|
/* §四.9 骨架屏:--bg-3 圆角块,1.4s 呼吸透明度;减少动态时静态。 */
|
|
.skeleton {
|
|
background: var(--bg-3);
|
|
border-radius: var(--r-sm);
|
|
animation: var(--decorative-loop-name, motion-skeleton-skeleton-breath) 1.4s ease-in-out infinite;
|
|
}
|
|
.skeleton.circle {
|
|
border-radius: 50%;
|
|
}
|
|
@keyframes -global-motion-skeleton-skeleton-breath {
|
|
50% {
|
|
opacity: 0.5;
|
|
}
|
|
}
|
|
@media (prefers-reduced-motion: reduce) {
|
|
.skeleton {
|
|
animation: none;
|
|
}
|
|
}
|
|
:global(:root[data-reduce='1']) .skeleton {
|
|
animation: none;
|
|
}
|
|
</style>
|