feat: add animation when quality issue increases
This commit is contained in:
@@ -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>
|
||||||
|
|||||||
Reference in New Issue
Block a user