Skip to content

Commit c64b8f5

Browse files
committed
refactor: replace and remove <BcFormatPercent>
See: BEDS-1147
1 parent 10dfa90 commit c64b8f5

File tree

7 files changed

+104
-206
lines changed

7 files changed

+104
-206
lines changed

frontend/components/bc/BcColor.vue

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ export type Color =
33
| 'gray'
44
| 'green'
55
| 'red'
6+
| 'yellow'
67
78
defineProps<{
89
color?: Color,
@@ -15,6 +16,7 @@ defineProps<{
1516
'bc-color--gray': color === 'gray',
1617
'bc-color--green': color === 'green',
1718
'bc-color--red': color === 'red',
19+
'bc-color--yellow': color === 'yellow',
1820
}"
1921
>
2022
<slot />
@@ -28,6 +30,9 @@ defineProps<{
2830
.bc-color--red {
2931
color: var(--negative-color);
3032
}
33+
.bc-color--yellow {
34+
color: var(--equal-color);
35+
}
3136
.bc-color--gray {
3237
color: var(--grey);
3338
}

frontend/components/bc/format/BcFormatPercent.vue

Lines changed: 0 additions & 155 deletions
This file was deleted.

frontend/components/dashboard/chart/DashboardChartSummaryTooltip.vue

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,9 +46,9 @@ defineProps<Props>()
4646
<div class="name">
4747
{{ entry.name }}:
4848
</div>
49-
<BcFormatPercent
49+
<BaseFormatPercent
5050
class="efficiency"
51-
:percent="entry.efficiency"
51+
:value="entry.efficiency / 100"
5252
/>
5353
</div>
5454
</div>

frontend/components/dashboard/table/DashboardTableSummaryValue.vue

Lines changed: 91 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,7 @@ const data = computed(() => {
137137
else if (row && props.property === 'efficiency') {
138138
return {
139139
efficiencyTotal: {
140-
compare: row.average_network_efficiency,
140+
networkEfficiency: row.average_network_efficiency,
141141
value: row.efficiency,
142142
},
143143
}
@@ -334,20 +334,14 @@ const openValidatorModal = () => {
334334
class="space_before"
335335
:value="data.apr.income.el"
336336
source-currency="elCurrency"
337-
/> (
338-
<BaseFormatPercent
339-
:value="data.apr.apr.el"
340-
/>
341-
)
337+
/> (<BaseFormatPercent :value="data.apr.apr.el" />)
342338
</div>
343339
<div class="row">
344340
<b>{{ $t("common.consensus_layer") }}:</b>
345341
<BcFormatAmount
346342
class="space_before"
347343
:value="data.apr.income.cl"
348-
/> (<BaseFormatPercent
349-
:value="data.apr.apr.cl"
350-
/>)
344+
/> (<BaseFormatPercent :value="data.apr.apr.cl" />)
351345
</div>
352346
</template>
353347
</BcTooltip>
@@ -419,25 +413,90 @@ const openValidatorModal = () => {
419413
</BcTooltip>
420414
</div>
421415

422-
<BcFormatPercent
423-
v-else-if="data?.efficiencyTotal"
424-
:percent="data.efficiencyTotal.value * 100"
425-
:compare-percent="data.efficiencyTotal.compare * 100"
426-
:color-break-point="80"
427-
>
428-
<template #leading-tooltip="{ compare }">
429-
<span class="efficiency-total-tooltip">
430-
{{
431-
$t(`dashboard.validator.summary.tooltip.${compare}`, {
432-
name: groupName,
433-
average: formatPercent(row.average_network_efficiency, {
434-
maximumFractionDigits: 2,
435-
}),
436-
})
437-
}}
438-
</span>
439-
</template>
440-
</BcFormatPercent>
416+
<div v-else-if="data?.efficiencyTotal">
417+
<BcColor
418+
v-if="data.efficiencyTotal.value > data.efficiencyTotal.networkEfficiency"
419+
color="green"
420+
>
421+
<BcTooltip>
422+
<BcIcon
423+
name="arrow-up"
424+
size="sm"
425+
class="efficiency-total-comparison-icon"
426+
/>
427+
<template #tooltip>
428+
<span class="efficiency-total-tooltip">
429+
{{
430+
$t('dashboard.validator.summary.tooltip.higher', {
431+
name: groupName,
432+
average: formatPercent(data.efficiencyTotal.networkEfficiency, {
433+
maximumFractionDigits: 2,
434+
}),
435+
})
436+
}}
437+
</span>
438+
</template>
439+
</BcTooltip>
440+
<BaseFormatPercent
441+
:value="data.efficiencyTotal.value"
442+
/>
443+
</BcColor>
444+
<BcColor
445+
v-else-if="data.efficiencyTotal.networkEfficiency === data.efficiencyTotal.value"
446+
color="yellow"
447+
>
448+
<BcTooltip>
449+
<BcIcon
450+
name="arrow-left-right"
451+
size="sm"
452+
class="efficiency-total-comparison-icon"
453+
/>
454+
<template #tooltip>
455+
<span class="efficiency-total-tooltip">
456+
{{
457+
$t('dashboard.validator.summary.tooltip.equal', {
458+
name: groupName,
459+
average: formatPercent(data.efficiencyTotal.networkEfficiency, {
460+
maximumFractionDigits: 2,
461+
}),
462+
})
463+
}}
464+
</span>
465+
</template>
466+
</BcTooltip>
467+
<BaseFormatPercent
468+
:value="data.efficiencyTotal.value"
469+
/>
470+
</BcColor>
471+
<BcColor
472+
v-else
473+
color="red"
474+
>
475+
<BcTooltip>
476+
<BcIcon
477+
name="arrow-down"
478+
size="sm"
479+
class="efficiency-total-comparison-icon"
480+
/>
481+
<template #tooltip>
482+
<span class="efficiency-total-tooltip">
483+
{{
484+
$t('dashboard.validator.summary.tooltip.lower', {
485+
name: groupName,
486+
average: formatPercent(data.efficiencyTotal.networkEfficiency, {
487+
maximumFractionDigits: 2,
488+
}),
489+
})
490+
}}
491+
</span>
492+
</template>
493+
</BcTooltip>
494+
<BaseFormatPercent
495+
:value="data.efficiencyTotal.value"
496+
/>
497+
</BcColor>
498+
</div>
499+
441500
<span v-else-if="data?.simple">
442501
{{ data.simple?.value }}
443502
</span>
@@ -478,6 +537,10 @@ const openValidatorModal = () => {
478537
width: 155px;
479538
}
480539
540+
.efficiency-total-comparison-icon {
541+
margin-right: var(--padding-small);
542+
}
543+
481544
:global(.dashboard-table-summary-value__tooltip) {
482545
white-space: pre-line;
483546
}

frontend/components/dashboard/table/SummaryValidatorsIconRow.vue

Lines changed: 2 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,9 @@
11
<script setup lang="ts">
22
import type { SummaryValidatorsIconRowInfo } from '~/types/validator'
33
4-
interface Props {
5-
absolute: boolean,
4+
defineProps<{
65
icons: SummaryValidatorsIconRowInfo[],
7-
total?: number,
8-
}
9-
const props = defineProps<Props>()
10-
11-
const combinedTotal = computed<number>(
12-
() =>
13-
props.total ?? props.icons?.reduce((sum, icon) => sum + icon.count, 0) ?? 0,
14-
)
6+
}>()
157
</script>
168

179
<template>
@@ -25,13 +17,7 @@ const combinedTotal = computed<number>(
2517
<BcIcon name="power-off" />
2618
</div>
2719
<BcFormatNumber
28-
v-if="absolute"
29-
:value="status.count"
30-
/>
31-
<BcFormatPercent
32-
v-else
3320
:value="status.count"
34-
:base="combinedTotal"
3521
/>
3622
</div>
3723
</template>

frontend/components/dashboard/validator/subset/ValidatorSubsetSubHeader.vue

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,6 @@ const infos = computed(() => {
155155
<span class="sub-title">{{ props?.subTitle }}</span>
156156
<DashboardTableSummaryValidatorsIconRow
157157
:icons="infos.validatorIcons"
158-
:absolute="true"
159158
/>
160159
<div
161160
v-for="(info, index) in infos.list"

0 commit comments

Comments
 (0)