mizzkey/packages/frontend/src/components/MkNumberDiff.vue

48 lines
802 B
Vue
Raw Normal View History

<template>
<span class="ceaaebcd" :class="{ isPlus, isMinus, isZero }">
2021-10-22 08:33:56 +02:00
<slot name="before"></slot>{{ isPlus ? '+' : '' }}{{ number(value) }}<slot name="after"></slot>
</span>
</template>
<script lang="ts">
import { computed, defineComponent } from 'vue';
2021-11-11 18:02:25 +01:00
import number from '@/filters/number';
export default defineComponent({
props: {
value: {
type: Number,
2022-06-05 05:26:36 +02:00
required: true,
},
},
setup(props) {
const isPlus = computed(() => props.value > 0);
const isMinus = computed(() => props.value < 0);
const isZero = computed(() => props.value === 0);
return {
isPlus,
isMinus,
isZero,
number,
};
2022-06-05 05:26:36 +02:00
},
});
</script>
<style lang="scss">
.ceaaebcd {
&.isPlus {
color: var(--success);
}
&.isMinus {
color: var(--error);
}
&.isZero {
opacity: 0.5;
}
}
</style>