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

107 lines
1.7 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:46:52 +02:00
<svg :class="[$style.spinner]" viewBox="0 0 50 50" xmlns="http://www.w3.org/2000/svg">
2022-07-28 04:27:29 +02:00
<circle :class="[$style.path]" cx="25" cy="25" r="20" fill="none" stroke-width="6px" style="fill:none;stroke:currentColor;stroke-width:6px;"></circle>
</svg>
</div>
</div>
</template>
<script lang="ts" setup>
import { } from 'vue';
const props = withDefaults(defineProps<{
inline?: boolean;
colored?: boolean;
mini?: boolean;
2023-02-19 04:48:25 +01:00
em?: boolean;
}>(), {
inline: false,
colored: true,
mini: false,
2023-02-19 04:48:25 +01:00
em: false,
});
</script>
<style lang="scss" module>
2022-07-27 20:19:57 +02:00
/* Credit to https://codepen.io/supah/pen/BjYLdW */
2020-02-10 12:44:59 +01:00
2022-07-27 21:27:09 +02:00
@keyframes spin {
0% {
transform: rotate(0deg);
}
100% {
transform: rotate(360deg);
}
}
@keyframes dash {
0% {
stroke-dasharray: 1, 150;
stroke-dashoffset: 0;
}
50% {
stroke-dasharray: 90, 150;
stroke-dashoffset: -35;
}
100% {
stroke-dasharray: 90, 150;
stroke-dashoffset: -124;
}
}
.root {
padding: 32px;
text-align: center;
2021-04-16 16:04:25 +02:00
cursor: wait;
2022-07-27 21:28:36 +02:00
--size: 40px;
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
}
2023-02-19 04:48:25 +01:00
&.em {
display: inline-block;
vertical-align: middle;
padding: 0;
--size: 1em;
}
}
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;
2022-07-27 20:46:52 +02:00
z-index: 999;
width: var(--size);
height: var(--size);
2022-07-27 21:27:09 +02:00
animation: spin 2s linear infinite;
2022-07-27 21:32:14 +02:00
}
2022-07-27 20:52:10 +02:00
2022-07-27 21:32:14 +02:00
.path {
stroke: var(--accent);
stroke-linecap: round;
2022-07-27 21:34:23 +02:00
animation: dash 1.2s ease-in-out infinite;
}
2021-04-16 16:04:25 +02:00
</style>