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