2021-10-21 22:36:48 +02:00
|
|
|
<template>
|
2023-04-08 02:01:42 +02:00
|
|
|
<span class="ceaaebcd" :class="{ isPlus, isMinus, isZero }">
|
|
|
|
<slot name="before"></slot>{{ isPlus ? "+" : "" }}{{ number(value)
|
|
|
|
}}<slot name="after"></slot>
|
|
|
|
</span>
|
2021-10-21 22:36:48 +02:00
|
|
|
</template>
|
|
|
|
|
|
|
|
<script lang="ts">
|
2023-04-08 02:01:42 +02:00
|
|
|
import { computed, defineComponent } from "vue";
|
|
|
|
import number from "@/filters/number";
|
2021-10-21 22:36:48 +02:00
|
|
|
|
|
|
|
export default defineComponent({
|
|
|
|
props: {
|
|
|
|
value: {
|
|
|
|
type: Number,
|
2022-06-05 05:26:36 +02:00
|
|
|
required: true,
|
2021-10-21 22:36:48 +02:00
|
|
|
},
|
|
|
|
},
|
|
|
|
|
|
|
|
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
|
|
|
},
|
2021-10-21 22:36:48 +02:00
|
|
|
});
|
|
|
|
</script>
|
|
|
|
|
|
|
|
<style lang="scss" scoped>
|
|
|
|
.ceaaebcd {
|
|
|
|
&.isPlus {
|
|
|
|
color: var(--success);
|
|
|
|
}
|
|
|
|
|
|
|
|
&.isMinus {
|
|
|
|
color: var(--error);
|
|
|
|
}
|
|
|
|
|
|
|
|
&.isZero {
|
|
|
|
opacity: 0.5;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
</style>
|