feat: add animation when quality issue increases

This commit is contained in:
Julien Calixte
2025-01-04 18:24:59 +01:00
parent 3b7975d9cf
commit f1d359003d

View File

@@ -1,20 +1,49 @@
<script setup lang="ts"> <script setup lang="ts">
defineProps<{ import { computed, ref, watchEffect } from 'vue'
const props = defineProps<{
qualityIssue: number qualityIssue: number
}>() }>()
const qualityIssue = computed(() => props.qualityIssue)
const isFlashing = ref(false)
const flashingDuration = 300
const flashingTransitionDuration = `${flashingDuration / 1000 + 0.1}s`
watchEffect(() => {
if (qualityIssue.value > 0) {
isFlashing.value = true
setTimeout(() => {
isFlashing.value = false
}, flashingDuration)
}
})
</script> </script>
<template> <template>
<div class="quality-issue red-bin numeric">{{ qualityIssue }}</div> <div
class="quality-issue red-bin numeric"
:class="{ 'is-flashing': isFlashing }"
>
{{ qualityIssue }}
</div>
</template> </template>
<style scoped lang="scss"> <style scoped lang="scss">
.quality-issue { .quality-issue {
&.red-bin {
--warning-color: #ca0e0e; --warning-color: #ca0e0e;
transition: v-bind(flashingTransitionDuration) ease-out;
transition-property: background-color, color;
&.red-bin {
border: 2px solid var(--warning-color); border: 2px solid var(--warning-color);
padding: 0 0.5rem 0.1rem; padding: 0 0.5rem 0.1rem;
color: var(--warning-color); color: var(--warning-color);
} }
&.is-flashing {
background-color: var(--warning-color);
color: var(--color);
}
} }
</style> </style>