2021-09-04 08:46:53 +00:00
|
|
|
<template>
|
|
|
|
<div
|
2021-09-04 15:06:35 +00:00
|
|
|
class="d-flex justify-content-center align-items-center profit-pill px-1"
|
2021-09-04 09:10:13 +00:00
|
|
|
:class="isProfitable ? 'profit-pill-profit' : ''"
|
2021-09-04 08:46:53 +00:00
|
|
|
:title="profitDesc"
|
|
|
|
>
|
|
|
|
{{ formatPercent(profitRatio, 2) }}
|
2021-09-04 15:06:35 +00:00
|
|
|
<small class="ml-1" :title="stakeCurrency">
|
|
|
|
{{ profitRatio ? '(' : '' }}{{ `${formatPrice(profitAbs, 3)}`
|
|
|
|
}}{{ profitRatio ? ')' : ` ${stakeCurrency}` }}
|
2021-09-04 08:46:53 +00:00
|
|
|
</small>
|
|
|
|
</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>
|