refactor(webui): extract repeated dashboard elements into shared components

Markup and helpers that were copied between pages now live in one
place:
- ChartCard, StatDisabledAlert, StatItem, DetailField, BudgetRatioBars,
  LabeledSelect, TargetPicker and LoadStateView components
- lib/scope.ts, lib/columns.ts and lib/chart-palette.ts
- messageOf, isAuthRejection, and the USD to micro-USD conversion
  helpers
- one monthly cost projection, one date formatter, and the
  useCopyFeedback composable

Behaviour is unchanged. Before and after screenshots of every page
match at 390 and 1440 px. Empty-state text now comes from the shared
EmptyState component, and the user run-out date uses the short date
format. admin_assets_gen.go is regenerated.

Claude-Session: https://claude.ai/code/session_01V5jYJNxpDFdJkyyExpADrv
This commit is contained in:
2026-09-24 06:04:46 +01:00
parent ce39b8eb37
commit 2608e01c50
67 changed files with 2008 additions and 1136 deletions
+4 -16
View File
@@ -1,8 +1,9 @@
<script setup lang="ts">
import { faCheck, faCopy, faTriangleExclamation } from '@fortawesome/free-solid-svg-icons'
import { computed, onUnmounted, ref, useTemplateRef } from 'vue'
import { computed, useTemplateRef } from 'vue'
import { Badge } from '@/components/ui/badge'
import { useCopyFeedback } from '@/composables/useCopyFeedback'
import { copyText } from '@/lib/clipboard'
import { formatContextWindow, formatModelCostHover } from '@/lib/format'
import { useToastsStore } from '@/stores/toasts'
@@ -50,17 +51,9 @@ const props = defineProps<{
}>()
const labelRef = useTemplateRef<HTMLElement>('label')
const state = ref<'idle' | 'copied' | 'selected' | 'failed'>('idle')
let resetTimer: ReturnType<typeof setTimeout> | undefined
const { state, set: setCopyFeedback } = useCopyFeedback()
const toasts = useToastsStore()
function scheduleReset(): void {
clearTimeout(resetTimer)
resetTimer = setTimeout(() => {
state.value = 'idle'
}, 1500)
}
async function onClick(): Promise<void> {
const result = await copyText(props.id, labelRef.value ?? undefined)
// 'failed' (neither the Clipboard API nor the selection fallback
@@ -71,9 +64,8 @@ async function onClick(): Promise<void> {
// feedback right at the click target (the icon swap plus this same
// title/aria-label text), so a success toast on top would double-notify
// for something the reader is already looking straight at.
state.value = result
setCopyFeedback(result)
if (result === 'failed') toasts.push({ kind: 'error', message: `Could not copy ${props.id}.` })
scheduleReset()
}
const icon = {
@@ -119,10 +111,6 @@ const title = computed(() => {
const base = baseTitle.value[state.value]
return metaDetail.value ? `${base} · ${metaDetail.value}` : base
})
onUnmounted(() => {
clearTimeout(resetTimer)
})
</script>
<template>