Move status indicator code into a shared component

This commit is contained in:
Johannes Zellner
2025-03-24 16:58:29 +01:00
parent b9d9797734
commit 3a323551eb
7 changed files with 67 additions and 34 deletions

View File

@@ -0,0 +1,27 @@
<script setup>
defineProps({
busy: {
type: Boolean,
default: false,
},
state: {
validator(value) {
// The value must match one of these strings
return ['success', 'warning', 'danger', ''].includes(value);
}
},
});
function color(state) {
if (state === 'success') return '#27CE65';
else if (state === 'warning') return '#f0ad4e';
else if (state === 'danger') return '#d9534f';
else return '#7c7c7c';
}
</script>
<template>
<i class="fa" :class="{ 'fa-circle': !busy, 'fa-circle-notch fa-spin': busy, 'fa-fade': state === 'warning' }" :style="{ color: busy ? null : color(state) }"></i>
</template>