web/app/components/ui/chart/ChartLegendContent.vue
Yoga Pangestu 0c732e71cf feat: update sidebar and header layout; fix dnd-kit-vue package error
- Fixed import error for `dnd-kit-vue` by installing the package.
- Moved user navigation from sidebar to header, adding a dropdown for account options.
- Added homepage and notification icons to the header.
- Implemented sticky header functionality during scroll.
- Grouped sidebar menu items under a "Master" label for better organization.
- Updated relevant components and package.json to include new dependencies.
2026-07-23 23:43:04 +07:00

61 lines
1.4 KiB
Vue

<script setup lang="ts">
import type { HTMLAttributes } from "vue"
import { computed, onMounted, ref } from "vue"
import { cn } from "@/lib/utils"
import { useChart } from "."
const props = withDefaults(defineProps<{
hideIcon?: boolean
nameKey?: string
verticalAlign?: "bottom" | "top"
// payload?: any[]
class?: HTMLAttributes["class"]
}>(), {
verticalAlign: "bottom",
})
const { id, config } = useChart()
const payload = computed(() => Object.entries(config.value).map(([key, value]) => {
return {
key: props.nameKey || key,
itemConfig: value,
}
}))
const containerSelector = ref("")
onMounted(() => {
containerSelector.value = `[data-chart="chart-${id}"]>[data-vis-xy-container]`
})
</script>
<template>
<div
v-if="containerSelector"
:class="cn(
'flex items-center justify-center gap-4',
verticalAlign === 'top' ? 'pb-3' : 'pt-3',
props.class,
)"
>
<div
v-for="{ key, itemConfig } in payload"
:key="key"
:class="cn(
'[&>svg]:text-muted-foreground flex items-center gap-1.5 [&>svg]:h-3 [&>svg]:w-3',
)"
>
<component :is="itemConfig.icon" v-if="itemConfig.icon" />
<div
v-else
class="h-2 w-2 shrink-0 rounded-xs"
:style="{
backgroundColor: itemConfig?.color,
}"
/>
{{ itemConfig.label }}
</div>
</div>
</template>