Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 | 22x 22x 22x 22x 22x 23x 23x 22x 69x 22x 66x 67x | <script setup lang="ts">
import { computed } from "vue";
import { scaleSize, toCssSize } from "../../../utils/size";
interface Props {
size?: string | number;
color?: string;
speed?: number;
}
const props = withDefaults(defineProps<Props>(), {
size: 40,
color: "currentColor",
speed: 1,
});
const dotSize = computed(() => scaleSize(props.size, "/", 4));
const boxSize = computed(() => toCssSize(props.size));
// three dots of size/4 plus two gaps of size/8 fill exactly one `size`
const gapSize = computed(() => scaleSize(props.size, "/", 8));
const duration = computed(() => {
return props.speed > 0 ? 1 / props.speed : 1;
});
const formattedDuration = computed(() => `${duration.value}s`);
const getAnimationDelay = (index: number) => {
return `${index * duration.value * 0.15}s`;
};
</script>
<template>
<div
class="vslk-spinner-dots"
:style="{ width: boxSize, height: boxSize, gap: gapSize, color: props.color }"
>
<span
v-for="n in 3"
:key="n"
:style="{
width: dotSize,
height: dotSize,
backgroundColor: props.color,
animationDuration: formattedDuration,
animationDelay: getAnimationDelay(n - 1),
}"
/>
</div>
</template>
<style scoped>
.vslk-spinner-dots {
display: flex;
align-items: center;
justify-content: center;
}
.vslk-spinner-dots span {
border-radius: 999px;
animation-name: vslk-bounce;
animation-timing-function: ease-in-out;
animation-iteration-count: infinite;
}
@keyframes vslk-bounce {
0%,
80%,
100% {
transform: scale(0.5);
opacity: 0.5;
}
40% {
transform: scale(1);
opacity: 1;
}
}
</style>
|