frequi_origin/src/components/general/ProfitPill.vue

53 lines
1.4 KiB
Vue
Raw Normal View History

2021-09-04 08:46:53 +00:00
<template>
<div
2021-09-18 14:45:11 +00:00
class="d-flex justify-content-center align-items-center profit-pill px-2"
2021-09-04 09:10:13 +00:00
:class="isProfitable ? 'profit-pill-profit' : ''"
2021-09-04 08:46:53 +00:00
:title="profitDesc"
>
{{ profitRatio !== undefined ? formatPercent(profitRatio, 2) : '' }}
2021-09-18 14:45:11 +00:00
<span class="ml-1" :class="profitRatio ? 'small' : ''" :title="stakeCurrency">
{{ profitRatio !== undefined ? '(' : '' }}{{ `${formatPrice(profitAbs, 3)}`
}}{{ profitRatio !== undefined ? ')' : ` ${stakeCurrency}` }}
2021-09-18 14:45:11 +00:00
</span>
2021-09-04 08:46:53 +00:00
</div>
</template>
<script lang="ts">
import { formatPercent, formatPrice, timestampms } from '@/shared/formatters';
import { Component, Prop, Vue } from 'vue-property-decorator';
@Component({})
export default class ProfitPill extends Vue {
2021-09-04 09:10:13 +00:00
@Prop({ required: false, default: undefined, type: Number }) profitRatio?: number;
2021-09-04 08:46:53 +00:00
@Prop({ required: true, type: Number }) profitAbs!: number;
@Prop({ required: true, type: String }) stakeCurrency!: string;
2021-09-04 09:10:13 +00:00
@Prop({ required: false, default: '', type: String }) profitDesc!: string;
2021-09-04 08:46:53 +00:00
formatPercent = formatPercent;
timestampms = timestampms;
formatPrice = formatPrice;
2021-09-04 09:10:13 +00:00
get isProfitable() {
return (
(this.profitRatio !== undefined && this.profitRatio > 0) ||
(this.profitRatio === undefined && this.profitAbs > 0)
);
}
2021-09-04 08:46:53 +00:00
}
</script>
<style scoped lang="scss">
.profit-pill {
2021-09-04 09:20:55 +00:00
background: $color-loss;
2021-09-04 08:46:53 +00:00
border-radius: 6px;
}
.profit-pill-profit {
2021-09-04 09:20:55 +00:00
background: $color-profit;
2021-09-04 08:46:53 +00:00
}
</style>