Skip to content

Commit

Permalink
add slot for legends title
Browse files Browse the repository at this point in the history
  • Loading branch information
P4l0m4 committed Jul 11, 2024
1 parent d9c0ff6 commit cb225aa
Showing 1 changed file with 31 additions and 12 deletions.
43 changes: 31 additions & 12 deletions @xen-orchestra/web/src/components/DonutWithLegends.vue
Original file line number Diff line number Diff line change
@@ -1,18 +1,21 @@
<template>
<div class="donut-with-legends">
<DonutChart :segments="donutSegments" :icon :max-value="maxValue" />
<ul class="legends">
<UiLegend
v-for="(segment, index) in segments"
:key="index"
:color="segment.color"
:value="segment.value"
:unit="segment.unit"
:tooltip="segment.tooltip"
>
{{ segment.label }}
</UiLegend>
</ul>
<div class="legends-and-title">
<slot />
<ul class="legends">
<UiLegend
v-for="(segment, index) in segments"
:key="index"
:color="segment.color"
:value="segment.value"
:unit="segment.unit"
:tooltip="segment.tooltip"
>
{{ segment.label }}
</UiLegend>
</ul>
</div>
</div>
</template>

Expand All @@ -36,6 +39,10 @@ const props = defineProps<{
maxValue?: number
}>()
defineSlots<{
default: () => void
}>()
const donutSegments = computed(() => {
if (props?.segments.length === 0) {
return []
Expand Down Expand Up @@ -64,4 +71,16 @@ const donutSegments = computed(() => {
align-items: center;
gap: 3.2rem;
}
.legends-and-title {
display: flex;
flex-direction: column;
gap: 0.8rem;
}
.legends {
display: flex;
flex-direction: column;
gap: 0.8rem;
}
</style>

0 comments on commit cb225aa

Please sign in to comment.