fix(ui): unify account subscription badges

Use compact badges in the dashboard and switch account rows to a stacked layout when the card is narrow.

Co-authored-by: Codex <noreply@openai.com>
This commit is contained in:
Zyy
2026-12-03 17:59:10 +08:00
co-authored by Codex
parent 77c42cea98
commit 3c560b9276
4 changed files with 17 additions and 16 deletions
@@ -66,10 +66,11 @@ const sizes = {
md: { text: 'text-z-xs font-heavy', singleLine: 'h-5.5 px-2' },
}
const paletteClass = computed(() => {
const appearanceClasses = computed(() => {
const key = props.planType?.trim().toLowerCase() || ''
return planPalettes.get(displayText.value?.trim().toLowerCase() || key)
const palette = planPalettes.get(displayText.value?.trim().toLowerCase() || key)
?? fallbackPalettes[stableVisualIndex(key, fallbackPalettes.length)]
return ['rounded-md', palette]
})
</script>
@@ -77,18 +78,18 @@ const paletteClass = computed(() => {
<AccountUpstreamBadge v-if="upstreamPeer || upstream?.discovered" :size="size" />
<span
v-else-if="wrap"
class="line-clamp-3 max-w-full py-0.75 text-center leading-4 text-balance wrap-anywhere whitespace-normal"
:class="sizes[size].text"
class="line-clamp-3 max-w-full text-center text-balance wrap-anywhere whitespace-normal"
:class="[sizes[size].text, size === 'xs' ? 'py-0.5 leading-3.5' : 'py-0.75 leading-4']"
>
<span class="box-decoration-clone rounded-md px-1.25 py-0.75" :class="paletteClass">
<span class="box-decoration-clone" :class="[appearanceClasses, size === 'xs' ? 'px-1 py-0.5' : 'px-1.25 py-0.75']">
{{ displayText }}
<span v-if="count !== undefined" class="tabular-nums">{{ count }}</span>
</span>
</span>
<span
v-else
class="inline-flex min-w-0 max-w-full items-center justify-center gap-1 rounded-full whitespace-nowrap leading-none shadow-z-tertiary"
:class="[sizes[size].text, sizes[size].singleLine, paletteClass]"
class="inline-flex min-w-0 max-w-full items-center justify-center gap-1 whitespace-nowrap leading-none"
:class="[appearanceClasses, sizes[size].text, sizes[size].singleLine]"
>
<span class="truncate">{{ displayText }}</span>
<span v-if="count !== undefined" class="shrink-0 tabular-nums">{{ count }}</span>
@@ -85,7 +85,7 @@ watch(hasPersonalInfo, (available) => {
v-if="(account.capabilities.quota || quotaEntries.length > 0 || account.upstream?.discovered) && (hasPlanBadge || lastRefreshed)"
class="col-span-2 row-start-2 m-0 flex min-w-0 items-center gap-1.5 text-z-xs font-emphasis text-z-text-secondary"
>
<AccountPlanBadge v-if="hasPlanBadge" :upstream="account.upstream" :authentication-kind="account.authenticationKind" :plan-type="account.planType" :plan-type-display="account.planTypeDisplay" size="sm" class="shrink-0 rounded-md!" />
<AccountPlanBadge v-if="hasPlanBadge" :upstream="account.upstream" :authentication-kind="account.authenticationKind" :plan-type="account.planType" :plan-type-display="account.planTypeDisplay" size="sm" class="shrink-0" />
<span v-if="lastRefreshed" class="min-w-0 truncate">{{ lastRefreshed }}</span>
</p>
<div v-if="hasActions" class="col-start-2 row-start-1 flex items-center gap-0.5 [&_svg]:size-3.5 [&_svg]:stroke-2">
@@ -52,7 +52,7 @@ const avatarToneClass = computed(() =>
<strong class="min-w-0 truncate text-z leading-[1.15] font-heavy text-z-text">
{{ displayTitle }}
</strong>
<AccountPlanBadge :upstream="account.upstream" :authentication-kind="account.authenticationKind" :plan-type="account.planType" :plan-type-display="account.planTypeDisplay" size="xs" />
<AccountPlanBadge wrap size="xs" class="max-w-2/3! shrink-0" :upstream="account.upstream" :authentication-kind="account.authenticationKind" :plan-type="account.planType" :plan-type-display="account.planTypeDisplay" />
</span>
<span
v-if="secondaryText"
@@ -207,7 +207,7 @@ const statusBars = computed(() => {
</script>
<template>
<ZCard as="article" class="w-full xl:h-112.5">
<ZCard as="article" class="w-full xl:min-h-112.5">
<div
class="grid xl:grid-cols-[minmax(0,0.9fr)_minmax(0,1.28fr)_minmax(280px,0.9fr)] xl:gap-7"
>
@@ -261,7 +261,7 @@ const statusBars = computed(() => {
</div>
</section>
<section class="min-w-0 w-full">
<section class="@container min-w-0 w-full">
<h2 class="m-0 text-xl leading-[1.15] font-heavy text-z-text">
{{ t('dashboard.activeAccounts.title') }}
</h2>
@@ -270,7 +270,7 @@ const statusBars = computed(() => {
</p>
<div
class="mt-5 flex w-full flex-col gap-2 overflow-hidden xl:mt-6.75 xl:h-82.5 xl:gap-2.5"
class="mt-5 flex w-full flex-col gap-2 overflow-hidden xl:mt-6.75 xl:gap-2.5 xl:@lg:h-82.5"
>
<ZEmpty
v-if="accounts.length === 0"
@@ -287,15 +287,15 @@ const statusBars = computed(() => {
<article
v-for="account in accounts"
:key="account.id"
class="grid w-full shrink-0 grid-cols-1 gap-3 rounded-xl bg-z-fill-alter/70 px-3.5 py-3.5 transition-colors xl:h-18.75 xl:grid-cols-[minmax(0,1.32fr)_minmax(64px,0.4fr)_minmax(66px,0.42fr)_minmax(96px,0.7fr)] xl:items-center xl:gap-3 xl:px-4 xl:py-0"
class="grid w-full shrink-0 grid-cols-1 gap-3 rounded-xl bg-z-fill-alter/70 px-3.5 py-3.5 transition-colors xl:@lg:h-18.75 xl:@lg:grid-cols-[minmax(0,1.32fr)_minmax(64px,0.4fr)_minmax(66px,0.42fr)_minmax(96px,0.7fr)] xl:@lg:items-center xl:@lg:px-4 xl:@lg:py-0"
>
<DashboardAccountIdentity
:account="account"
class="min-w-0 xl:pr-4"
class="min-w-0 xl:@lg:pr-4"
/>
<span
class="grid min-w-0 grid-cols-[minmax(0,0.82fr)_minmax(0,0.64fr)_minmax(104px,1fr)] items-start gap-3 xl:contents"
class="grid min-w-0 grid-cols-[minmax(0,0.82fr)_minmax(0,0.64fr)_minmax(104px,1fr)] items-start gap-3 xl:@lg:contents"
>
<span class="grid min-w-0 gap-1">
<span class="text-z-xs leading-none font-bold text-z-text-quaternary">
@@ -311,7 +311,7 @@ const statusBars = computed(() => {
<span class="grid min-w-0 gap-1">
<span class="text-z-xs leading-none font-bold text-z-text-quaternary">{{ t('dashboard.activeAccounts.recent') }}</span>
<span
class="min-w-0 truncate text-xs leading-[1.15] font-bold text-z-text-secondary xl:whitespace-nowrap"
class="min-w-0 truncate text-xs leading-[1.15] font-bold text-z-text-secondary"
>
{{ formatRelativeTime(account.lastUsedRelative) }}
</span>