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

33 lines
684 B
Vue
Raw Normal View History

<template>
<span class="ceaaebcd" :class="{ [$style.isPlus]: isPlus, [$style.isMinus]: isMinus, [$style.isZero]: isZero }">
2021-10-22 15:33:56 +09:00
<slot name="before"></slot>{{ isPlus ? '+' : '' }}{{ number(value) }}<slot name="after"></slot>
</span>
</template>
<script lang="ts" setup>
import { computed } from 'vue';
2021-11-12 02:02:25 +09:00
import number from '@/filters/number';
const props = defineProps<{
value: number;
}>();
const isPlus = computed(() => props.value > 0);
const isMinus = computed(() => props.value < 0);
const isZero = computed(() => props.value === 0);
</script>
<style lang="scss" module>
.isPlus {
color: var(--success);
}
.isMinus {
color: var(--error);
}
.isZero {
opacity: 0.5;
}
</style>