Move status indicator code into a shared component
This commit is contained in:
27
dashboard/src/components/StateLED.vue
Normal file
27
dashboard/src/components/StateLED.vue
Normal 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>
|
||||
Reference in New Issue
Block a user