hippofish/packages/client/src/components/global/loading.vue

105 lines
2.1 KiB
Vue
Raw Normal View History

<template>
<div :class="[$style.root, { [$style.inline]: inline, [$style.colored]: colored, [$style.mini]: mini }]">
2022-07-27 20:32:55 +02:00
<div :class="$style.container" aria-hidden="true">
2022-07-27 20:19:57 +02:00
<!-- <svg :class="[$style.spinner, $style.bg]" viewBox="0 0 168 168" xmlns="http://www.w3.org/2000/svg">
<g transform="matrix(1.125,0,0,1.125,12,12)">
2022-07-27 20:19:57 +02:00
<circle cx="168" cy="64" r="64" style="fill:none;stroke:currentColor;stroke-width:21.33px;"/>
</g>
</svg>
<svg :class="[$style.spinner, $style.fg]" viewBox="0 0 168 168" xmlns="http://www.w3.org/2000/svg">
<g transform="matrix(1.125,0,0,1.125,12,12)">
<path d="M128,64C128,28.654 99.346,0 64,0C99.346,0 128,28.654 128,64Z" style="fill:none;stroke:currentColor;stroke-width:21.33px;"/>
</g>
2022-07-27 20:19:57 +02:00
</svg> -->
<svg :class="[$style.spinner, $style.bg]" viewBox="0 0 50 50">
<circle class="path" cx="25" cy="25" r="20" fill="none" stroke-width="5"></circle>
</svg>
</div>
</div>
</template>
<script lang="ts" setup>
import { } from 'vue';
const props = withDefaults(defineProps<{
inline?: boolean;
colored?: boolean;
mini?: boolean;
}>(), {
inline: false,
colored: true,
mini: false,
});
</script>
<style lang="scss" module>
2022-07-27 20:19:57 +02:00
/* Credit to https://codepen.io/supah/pen/BjYLdW */
@keyframes rotate {
100% {
transform: rotate(360deg);
}
}
@keyframes dash {
2020-02-10 12:44:59 +01:00
0% {
2022-07-27 20:19:57 +02:00
stroke-dasharray: 1, 150;
stroke-dashoffset: 0;
}
50% {
stroke-dasharray: 90, 150;
stroke-dashoffset: -35;
2020-02-10 12:44:59 +01:00
}
100% {
2022-07-27 20:19:57 +02:00
stroke-dasharray: 90, 150;
stroke-dashoffset: -124;
2020-02-10 12:44:59 +01:00
}
}
.root {
padding: 32px;
text-align: center;
2021-04-16 16:04:25 +02:00
cursor: wait;
2022-07-27 20:19:57 +02:00
--size: 50px;
2021-04-16 16:04:25 +02:00
&.colored {
color: var(--accent);
}
2020-02-11 18:52:37 +01:00
&.inline {
display: inline;
padding: 0;
--size: 32px;
}
2020-02-11 18:52:37 +01:00
&.mini {
padding: 16px;
--size: 32px;
2020-02-11 18:52:37 +01:00
}
}
2020-02-11 18:52:37 +01:00
.container {
position: relative;
width: var(--size);
height: var(--size);
margin: 0 auto;
}
2020-02-10 12:44:59 +01:00
.spinner {
position: absolute;
top: 0;
left: 0;
width: var(--size);
height: var(--size);
stroke-linecap: round;
stroke-linejoin: round;
2021-04-16 16:04:25 +02:00
2022-07-27 20:19:57 +02:00
&.path {
stroke: var(--accent);
stroke-linecap: round;
animation: dash 1.5s ease-in-out infinite;
}
}
2021-04-16 16:04:25 +02:00
</style>