Skip to content

Self-hosted personal gallery application with online photo management and albums, supporting Live/Motion Photos, EXIF parsing, geolocation recognition, and an explore map.

refactor(ui): standardize SaaS components on Nuxt UI

Timothy Yinf48b878317d8
diff --git a/apps/cloud/app/assets/cloud.css b/apps/cloud/app/assets/cloud.css
index 7bb25f53..a00ac23d 100644
--- a/apps/cloud/app/assets/cloud.css
+++ b/apps/cloud/app/assets/cloud.css
@@ -968,11 +968,6 @@
z-index: 60;
width: 240px;
padding: 8px;
- border: 1px solid var(--border);
- border-radius: 14px;
- background: var(--card);
- color: var(--foreground);
- box-shadow: 0 12px 32px #20281f14;
}
.cf-mobile-menu nav {
display: grid;
diff --git a/apps/cloud/app/components/CloudAlbumsManager.vue b/apps/cloud/app/components/CloudAlbumsManager.vue
index 588c3776..ba2bb609 100644
--- a/apps/cloud/app/components/CloudAlbumsManager.vue
+++ b/apps/cloud/app/components/CloudAlbumsManager.vue
@@ -341,7 +341,9 @@ function menu(album: Album) {
:columns="columns"
:loading="loading && !albums.length"
><template #cover-cell="{ row }"
- ><button
+ ><UButton
+ variant="ghost"
+ color="neutral"
class="cf-library-thumb"
:aria-label="$t('cloud.ui.editNamed', { title: row.original.title })"
:disabled="!admin"
@@ -350,20 +352,20 @@ function menu(album: Album) {
<ThumbImage
v-if="cover(row.original)"
:src="cover(row.original)?.thumbnailUrl || ''"
- :alt="row.original.title"
- /><UIcon
+ :alt="row.original.title" /><UIcon
v-else
name="i-lucide-images"
- class="size-5"
- /></button></template
+ class="size-5" /></UButton></template
><template #title-cell="{ row }"
- ><button
+ ><UButton
+ variant="ghost"
+ color="neutral"
class="cf-photo-title"
:disabled="!admin"
@click="edit(row.original)"
>
{{ row.original.title }}
- </button></template
+ </UButton></template
><template #description-cell="{ row }"
><p class="cf-table-description">
{{ row.original.description || '—' }}
@@ -604,7 +606,9 @@ function menu(album: Album) {
class="w-full mb-4"
/>
<div class="cf-photo-picker">
- <button
+ <UButton
+ variant="ghost"
+ color="neutral"
v-for="photo in choices"
:key="photo.id"
class="cf-picker-photo"
@@ -622,7 +626,7 @@ function menu(album: Album) {
name="i-lucide-circle-check"
class="cf-picker-check"
/>
- </button>
+ </UButton>
</div>
<div class="flex items-center justify-between gap-3 mt-4">
<span class="text-sm text-muted">{{
diff --git a/apps/cloud/app/components/CloudDomainCard.vue b/apps/cloud/app/components/CloudDomainCard.vue
index 7126386b..135a2879 100644
--- a/apps/cloud/app/components/CloudDomainCard.vue
+++ b/apps/cloud/app/components/CloudDomainCard.vue
@@ -10,14 +10,7 @@ import {
RefreshCw,
ShieldCheck,
} from 'lucide-vue-next'
-import {
- DropdownMenuRoot,
- DropdownMenuTrigger,
- DropdownMenuPortal,
- DropdownMenuContent,
- DropdownMenuItem,
- DropdownMenuSeparator,
-} from 'reka-ui'
+
const props = defineProps<{
domain: CustomDomain
admin: boolean
@@ -93,6 +86,66 @@ const guidance = computed(() =>
: 'cloud.domainFlow.routeHelp',
),
)
+const menuItems = computed(() => [
+ ...(props.domain.status === 'active'
+ ? [
+ ...(!props.domain.primary
+ ? [
+ {
+ label: t('cloud.domains.makePrimary'),
+ onSelect: () => emit('action', props.domain, 'primary'),
+ },
+ ]
+ : []),
+ ...(props.domain.primary
+ ? [
+ {
+ label: t(
+ props.domain.redirects
+ ? 'cloud.domains.disableRedirects'
+ : 'cloud.domains.enableRedirects',
+ ),
+ onSelect: () =>
+ emit(
+ 'action',
+ props.domain,
+ 'redirects',
+ !props.domain.redirects,
+ ),
+ },
+ ]
+ : []),
+ ]
+ : []),
+ ...(!['deleting', 'expired'].includes(props.domain.status)
+ ? [
+ {
+ label: t(
+ props.domain.status === 'paused'
+ ? 'cloud.domains.resume'
+ : 'cloud.domains.pause',
+ ),
+ disabled:
+ props.domain.status === 'paused' &&
+ (!props.enabled ||
+ (!!props.domain.holdReason &&
+ props.domain.holdReason !== 'manual')),
+ onSelect: () =>
+ emit(
+ 'action',
+ props.domain,
+ props.domain.status === 'paused' ? 'resume' : 'pause',
+ ),
+ },
+ ]
+ : []),
+ {
+ label: t('cloud.domains.remove'),
+ color: 'error' as const,
+ disabled: props.domain.status === 'deleting',
+ onSelect: () => emit('remove', props.domain),
+ },
+])
</script>
<template>
<article
@@ -136,73 +189,21 @@ const guidance = computed(() =>
<CfBadge :tone="domain.status === 'active' ? 'success' : 'neutral'">{{
statusLabel
}}</CfBadge>
- <DropdownMenuRoot v-if="admin && domain.status !== 'deleting'"
- ><DropdownMenuTrigger as-child
- ><CfButton
- size="icon"
- variant="ghost"
- :aria-label="
- t('cloud.domainFlow.actions', { hostname: domain.hostname })
- "
- :disabled="busy"
- ><MoreHorizontal :size="17" /></CfButton
- ></DropdownMenuTrigger>
- <DropdownMenuPortal
- ><DropdownMenuContent
- class="cf-account-menu"
- align="end"
- :side-offset="6"
- :collision-padding="12"
- >
- <template v-if="domain.status === 'active'">
- <DropdownMenuItem
- v-if="!domain.primary"
- @select="emit('action', domain, 'primary')"
- >{{ t('cloud.domains.makePrimary') }}</DropdownMenuItem
- >
- <DropdownMenuItem
- v-if="domain.primary"
- @select="emit('action', domain, 'redirects', !domain.redirects)"
- >{{
- t(
- domain.redirects
- ? 'cloud.domains.disableRedirects'
- : 'cloud.domains.enableRedirects',
- )
- }}</DropdownMenuItem
- >
- <DropdownMenuSeparator class="cf-menu-separator" />
- </template>
- <DropdownMenuItem
- v-if="!['deleting', 'expired'].includes(domain.status)"
- :disabled="
- domain.status === 'paused' &&
- (!enabled ||
- (!!domain.holdReason && domain.holdReason !== 'manual'))
- "
- @select="
- emit(
- 'action',
- domain,
- domain.status === 'paused' ? 'resume' : 'pause',
- )
- "
- >{{
- t(
- domain.status === 'paused'
- ? 'cloud.domains.resume'
- : 'cloud.domains.pause',
- )
- }}</DropdownMenuItem
- >
- <DropdownMenuItem
- :disabled="domain.status === 'deleting'"
- @select="emit('remove', domain)"
- >{{ t('cloud.domains.remove') }}</DropdownMenuItem
- >
- </DropdownMenuContent></DropdownMenuPortal
- >
- </DropdownMenuRoot>
+ <UDropdownMenu
+ v-if="admin && domain.status !== 'deleting'"
+ :items="menuItems"
+ :content="{ align: 'end', sideOffset: 6, collisionPadding: 12 }"
+ >
+ <CfButton
+ size="icon"
+ variant="ghost"
+ :aria-label="
+ t('cloud.domainFlow.actions', { hostname: domain.hostname })
+ "
+ :disabled="busy"
+ ><MoreHorizontal :size="17"
+ /></CfButton>
+ </UDropdownMenu>
</div>
<p class="cf-field-hint cf-domain-guidance">{{ guidance }}</p>
<div class="cf-domain-card-toolbar">
@@ -220,15 +221,13 @@ const guidance = computed(() =>
<div class="cf-domain-inline-actions">
<CfButton
v-if="domain.status === 'active' && published"
- as-child
size="sm"
variant="ghost"
- ><a
- :href="'https://' + domain.hostname"
- target="_blank"
- rel="noopener noreferrer"
- >{{ t('cloud.messages.viewSite') }}<ExternalLink :size="13" /></a
- ></CfButton>
+ :href="'https://' + domain.hostname"
+ target="_blank"
+ rel="noopener noreferrer"
+ >{{ t('cloud.messages.viewSite') }}<ExternalLink :size="13"
+ /></CfButton>
<CfButton
v-if="
admin && !['paused', 'deleting', 'expired'].includes(domain.status)
diff --git a/apps/cloud/app/components/CloudMarketingHeader.vue b/apps/cloud/app/components/CloudMarketingHeader.vue
index e149d7bf..7fd3295e 100644
--- a/apps/cloud/app/components/CloudMarketingHeader.vue
+++ b/apps/cloud/app/components/CloudMarketingHeader.vue
@@ -1,6 +1,5 @@
<script setup lang="ts">
import { ArrowUpRight, ArrowRight, Menu } from 'lucide-vue-next'
-import { PopoverRoot, PopoverTrigger, PopoverContent } from 'reka-ui'
const route = useRoute()
const { authenticated } = useCloudMarketingSession()
const mobileMenuOpen = ref(false),
@@ -29,66 +28,51 @@ const mobileMenuOpen = ref(false),
><CloudThemeToggle />
<CfButton
v-if="authenticated"
- as-child
size="sm"
- ><NuxtLink
- :to="links.console"
- external
- >{{ $t('cloud.messages.visitConsole')
- }}<ArrowUpRight :size="14" /></NuxtLink
- ></CfButton>
+ :to="links.console"
+ external
+ >{{ $t('cloud.messages.visitConsole') }}<ArrowUpRight :size="14"
+ /></CfButton>
<template v-else>
<CfButton
- as-child
variant="secondary"
size="sm"
- ><NuxtLink
- :to="links.signin"
- external
- >{{ $t('cloud.messages.logIn') }}</NuxtLink
- ></CfButton
+ :to="links.signin"
+ external
+ >{{ $t('cloud.messages.logIn') }}</CfButton
><CfButton
- as-child
size="sm"
- ><NuxtLink
- :to="links.signup"
- external
- >{{ $t('cloud.messages.getStarted')
- }}<ArrowUpRight :size="14" /></NuxtLink
- ></CfButton>
+ :to="links.signup"
+ external
+ >{{ $t('cloud.messages.getStarted') }}<ArrowUpRight :size="14"
+ /></CfButton>
</template>
</nav>
<div class="cf-mobile-header-actions">
<CfButton
- as-child
size="sm"
- ><NuxtLink
- :to="authenticated ? links.console : links.signup"
- external
- >{{
- $t(
- authenticated
- ? 'cloud.messages.visitConsole'
- : 'cloud.messages.signUp',
- )
- }}</NuxtLink
- ></CfButton
+ :to="authenticated ? links.console : links.signup"
+ external
+ >{{
+ $t(
+ authenticated
+ ? 'cloud.messages.visitConsole'
+ : 'cloud.messages.signUp',
+ )
+ }}</CfButton
+ >
+ <UPopover
+ v-model:open="mobileMenuOpen"
+ :content="{ align: 'end', sideOffset: 12, collisionPadding: 20 }"
+ :ui="{ content: 'cf-mobile-menu' }"
>
- <PopoverRoot v-model:open="mobileMenuOpen">
- <PopoverTrigger as-child
- ><CfButton
- variant="ghost"
- size="icon"
- :aria-label="$t('cloud.messages.openNavigation')"
- ><Menu :size="20" /></CfButton
- ></PopoverTrigger>
- <PopoverContent
- class="cf-mobile-menu"
- align="end"
- :side-offset="12"
- :collision-padding="20"
- :aria-label="$t('cloud.messages.navigation')"
- >
+ <CfButton
+ variant="ghost"
+ size="icon"
+ :aria-label="$t('cloud.messages.openNavigation')"
+ ><Menu :size="20"
+ /></CfButton>
+ <template #content>
<nav :aria-label="$t('cloud.messages.mobileNavigation')">
<NuxtLink
:to="authenticated ? links.console : links.signin"
@@ -113,8 +97,8 @@ const mobileMenuOpen = ref(false),
<span>{{ $t('cloud.messages.appearance') }}</span
><CloudThemeToggle />
</div>
- </PopoverContent>
- </PopoverRoot>
+ </template>
+ </UPopover>
</div>
</header>
</template>
diff --git a/apps/cloud/app/components/CloudPhotoLibrary.vue b/apps/cloud/app/components/CloudPhotoLibrary.vue
index a9d1f920..2bd56f6e 100644
--- a/apps/cloud/app/components/CloudPhotoLibrary.vue
+++ b/apps/cloud/app/components/CloudPhotoLibrary.vue
@@ -477,7 +477,9 @@ watch(
(v) => (selection[row.original.id] = !!v)
" /></template
><template #thumbnailUrl-cell="{ row }"
- ><button
+ ><UButton
+ variant="ghost"
+ color="neutral"
class="cf-library-thumb"
:aria-label="
$t('cloud.ui.previewNamed', { title: row.original.title })
@@ -493,13 +495,15 @@ watch(
class="cf-live-label"
>{{ $t('cloud.messages.live') }}</span
>
- </button></template
+ </UButton></template
><template #title-cell="{ row }"
- ><button
+ ><UButton
+ variant="ghost"
+ color="neutral"
class="cf-photo-title"
@click="preview = row.original"
>
- {{ row.original.title }}</button
+ {{ row.original.title }}</UButton
><span class="cf-photo-dimensions"
>{{ row.original.width }} × {{ row.original.height }}</span
></template
@@ -787,7 +791,7 @@ watch(
<p>{{ livePhoto?.title }}</p>
<label class="cf-field"
>{{ processingText('MOV companion video', 'MOV 配对视频')
- }}<input
+ }}<UInput
type="file"
accept=".mov,video/quicktime"
:disabled="attaching"
diff --git a/apps/cloud/app/components/CloudPricing.vue b/apps/cloud/app/components/CloudPricing.vue
index 4e24dc53..27555c85 100644
--- a/apps/cloud/app/components/CloudPricing.vue
+++ b/apps/cloud/app/components/CloudPricing.vue
@@ -630,13 +630,10 @@ async function submitCheckout(plan: any, mode?: string) {
</p>
<CfButton
v-if="redeemOnly"
- as-child
:variant="plan.featured ? 'default' : 'secondary'"
- ><NuxtLink
- :to="links.redeem"
- :external="!portal"
- >{{ $t('cloud.billing.redeem') }}</NuxtLink
- ></CfButton
+ :to="links.redeem"
+ :external="!portal"
+ >{{ $t('cloud.billing.redeem') }}</CfButton
>
<CfButton
v-else-if="portal && !payment && payments?.error.value"
@@ -722,17 +719,14 @@ async function submitCheckout(plan: any, mode?: string) {
>
<CfButton
v-else
- as-child
:variant="plan.featured ? 'default' : 'secondary'"
- ><NuxtLink
- :to="action(plan)"
- external
- >{{
- amount(plan) === 0
- ? $t('cloud.billing.createAccount')
- : $t('cloud.billing.buyPlan', { plan: plan.name })
- }}</NuxtLink
- ></CfButton
+ :to="action(plan)"
+ external
+ >{{
+ amount(plan) === 0
+ ? $t('cloud.billing.createAccount')
+ : $t('cloud.billing.buyPlan', { plan: plan.name })
+ }}</CfButton
>
<ul class="cf-plan-features">
<li>
@@ -880,20 +874,27 @@ async function submitCheckout(plan: any, mode?: string) {
})
}}
</p>
- <label v-if="checkoutPlan.id !== entitlement.planId"
- ><input
- v-model="startMode"
- type="radio"
- value="immediate"
- />{{ $t('cloud.payments.startImmediately') }}</label
- >
- <label v-if="entitlement.expiresAt !== null"
- ><input
- v-model="startMode"
- type="radio"
- value="after_entitlement"
- />{{ $t('cloud.payments.startAfterEntitlement') }}</label
- >
+ <URadioGroup
+ v-model="startMode"
+ :items="[
+ ...(checkoutPlan.id !== entitlement.planId
+ ? [
+ {
+ value: 'immediate',
+ label: $t('cloud.payments.startImmediately'),
+ },
+ ]
+ : []),
+ ...(entitlement.expiresAt !== null
+ ? [
+ {
+ value: 'after_entitlement',
+ label: $t('cloud.payments.startAfterEntitlement'),
+ },
+ ]
+ : []),
+ ]"
+ />
<p>
{{
$t(
@@ -904,10 +905,9 @@ async function submitCheckout(plan: any, mode?: string) {
}}
</p>
<label v-if="startMode === 'immediate'"
- ><input
- v-model="replaceConfirmed"
- type="checkbox"
- />{{ $t('cloud.payments.replaceConsent') }}</label
+ ><CfCheckbox v-model="replaceConfirmed" />{{
+ $t('cloud.payments.replaceConsent')
+ }}</label
>
<p
v-if="paymentError"
diff --git a/apps/cloud/app/components/CloudProcessingSettings.vue b/apps/cloud/app/components/CloudProcessingSettings.vue
index 8c99e0e8..d4801a0b 100644
--- a/apps/cloud/app/components/CloudProcessingSettings.vue
+++ b/apps/cloud/app/components/CloudProcessingSettings.vue
@@ -50,9 +50,8 @@ async function save() {
@submit.prevent="save"
>
<label class="processing-toggle"
- ><input
+ ><CfCheckbox
v-model="erase"
- type="checkbox"
:disabled="busy || !!error"
/><span>{{
t(
diff --git a/apps/cloud/app/components/CloudQuotaLabel.vue b/apps/cloud/app/components/CloudQuotaLabel.vue
index a147cbe5..cbbdcd24 100644
--- a/apps/cloud/app/components/CloudQuotaLabel.vue
+++ b/apps/cloud/app/components/CloudQuotaLabel.vue
@@ -8,7 +8,9 @@ defineProps<{ quota: string }>()
v-if="quota === 'photos'"
:ui="{ content: 'max-w-xs h-auto whitespace-normal' }"
>
- <button
+ <UButton
+ variant="ghost"
+ color="neutral"
type="button"
class="inline-flex shrink-0 items-center text-muted focus-visible:outline-2 focus-visible:outline-offset-2"
:aria-label="$t('cloud.billing.photosQuotaHelp')"
@@ -17,7 +19,7 @@ defineProps<{ quota: string }>()
name="i-lucide-info"
class="size-3.5"
/>
- </button>
+ </UButton>
<template #content>
<span class="block whitespace-normal break-words py-1 leading-relaxed">
{{ $t('cloud.billing.photosQuotaHelp') }}
diff --git a/apps/cloud/app/components/CloudQuotaNotice.vue b/apps/cloud/app/components/CloudQuotaNotice.vue
index 450ac1f3..d0fbf21f 100644
--- a/apps/cloud/app/components/CloudQuotaNotice.vue
+++ b/apps/cloud/app/components/CloudQuotaNotice.vue
@@ -17,20 +17,21 @@ const emit = defineEmits<{ retry: [] }>()
}}</strong>
<p v-if="reason === 'upgrade'">{{ $t('cloud.dashboard.quotaHelp') }}</p>
</div>
- <CfButton
- v-if="error"
- variant="secondary"
- size="sm"
- @click="emit('retry')"
- >{{ $t('cloud.messages.retry') }}</CfButton
- ><CfButton
- v-else-if="reason === 'upgrade'"
- as-child
- variant="secondary"
- size="sm"
- ><NuxtLink to="/account/plan#plans">{{
- $t('cloud.dashboard.viewPlans')
- }}</NuxtLink></CfButton
+ <template #actions
+ ><CfButton
+ v-if="error"
+ variant="secondary"
+ size="sm"
+ @click="emit('retry')"
+ >{{ $t('cloud.messages.retry') }}</CfButton
+ >
+ <CfButton
+ v-else-if="reason === 'upgrade'"
+ variant="secondary"
+ size="sm"
+ to="/account/plan#plans"
+ >{{ $t('cloud.dashboard.viewPlans') }}</CfButton
+ ></template
></CfAlert
>
</template>
diff --git a/apps/cloud/app/components/CloudSitePublication.vue b/apps/cloud/app/components/CloudSitePublication.vue
index 619090c3..647f9183 100644
--- a/apps/cloud/app/components/CloudSitePublication.vue
+++ b/apps/cloud/app/components/CloudSitePublication.vue
@@ -89,15 +89,13 @@ async function unpublish() {
<div class="cf-site-page-actions">
<CfButton
v-if="context?.published && address"
- as-child
variant="secondary"
size="sm"
- ><a
- :href="address"
- target="_blank"
- rel="noopener noreferrer"
- >{{ $t('cloud.messages.viewSite') }}<ArrowUpRight :size="14" /></a
- ></CfButton>
+ :href="address"
+ target="_blank"
+ rel="noopener noreferrer"
+ >{{ $t('cloud.messages.viewSite') }}<ArrowUpRight :size="14"
+ /></CfButton>
<CfButton
v-if="admin"
:variant="context?.published ? 'ghost' : 'default'"
@@ -124,11 +122,13 @@ async function unpublish() {
v-if="domainError"
tone="error"
>{{ $t('cloud.domains.loadFailed')
- }}<CfButton
- size="sm"
- variant="secondary"
- @click="refreshDomains()"
- >{{ $t('cloud.messages.retry') }}</CfButton
+ }}<template #actions
+ ><CfButton
+ size="sm"
+ variant="secondary"
+ @click="refreshDomains()"
+ >{{ $t('cloud.messages.retry') }}</CfButton
+ ></template
></CfAlert
>
<div class="cf-site-address-block">
diff --git a/apps/cloud/app/components/CloudSiteSettings.vue b/apps/cloud/app/components/CloudSiteSettings.vue
index 85825de8..f9831537 100644
--- a/apps/cloud/app/components/CloudSiteSettings.vue
+++ b/apps/cloud/app/components/CloudSiteSettings.vue
@@ -263,7 +263,7 @@ async function save() {
for="gallery-icon"
class="cf-icon-picker"
>{{ $t('cloud.ui.chooseIcon') }}</label
- ><input
+ ><UInput
class="cf-icon-file"
id="gallery-icon"
type="file"
@@ -295,48 +295,38 @@ async function save() {
<p class="cf-field-hint">
{{ $t('cloud.presentation.themeHelp') }}
</p>
- <fieldset :disabled="busy">
- <legend class="sr-only">
- {{ $t('cloud.presentation.theme') }}
- </legend>
- <label
- v-for="option in ['light', 'dark', 'system'] as const"
- :key="option"
- class="cf-layout-option"
- >
- <input
- v-model="theme"
- type="radio"
- name="gallery-theme"
- :value="option"
- />
- <span>{{
- $t('cloud.presentation.themeOptions.' + option)
- }}</span>
- </label>
- </fieldset>
+ <URadioGroup
+ v-model="theme"
+ :disabled="busy"
+ :aria-label="$t('cloud.presentation.theme')"
+ orientation="horizontal"
+ variant="card"
+ :items="
+ (['light', 'dark', 'system'] as const).map((value) => ({
+ value,
+ label: $t('cloud.presentation.themeOptions.' + value),
+ }))
+ "
+ />
</section>
<section class="cf-gallery-presentation">
<h3>{{ $t('cloud.presentation.layout') }}</h3>
<p class="cf-field-hint">
{{ $t('cloud.presentation.layoutHelp') }}
</p>
- <fieldset :disabled="busy">
- <legend class="sr-only">
- {{ $t('cloud.presentation.layout') }}
- </legend>
- <label
- v-for="option in ['embedded', 'fixed'] as const"
- :key="option"
- class="cf-layout-option"
- ><input
- v-model="homeHeaderLayout"
- type="radio"
- name="home-header-layout"
- :value="option"
- /><span>{{ $t('cloud.presentation.' + option) }}</span></label
- >
- </fieldset>
+ <URadioGroup
+ v-model="homeHeaderLayout"
+ :disabled="busy"
+ :aria-label="$t('cloud.presentation.layout')"
+ orientation="horizontal"
+ variant="card"
+ :items="
+ (['embedded', 'fixed'] as const).map((value) => ({
+ value,
+ label: $t('cloud.presentation.' + value),
+ }))
+ "
+ />
</section>
<section class="cf-gallery-presentation">
<h3>{{ $t('cloud.presentation.social') }}</h3>
diff --git a/apps/cloud/app/components/CloudSiteWorkspace.vue b/apps/cloud/app/components/CloudSiteWorkspace.vue
index 8d6c23bc..ac645a34 100644
--- a/apps/cloud/app/components/CloudSiteWorkspace.vue
+++ b/apps/cloud/app/components/CloudSiteWorkspace.vue
@@ -33,15 +33,17 @@ const status = computed(() => (loading.value ? 'pending' : 'success'))
v-if="loadError"
tone="error"
>
- {{ loadError
- }}<CfButton
- size="sm"
- variant="secondary"
- :loading="loading"
- @click="refreshMedia"
- >{{ $t('cloud.messages.retry') }}</CfButton
- >
- </CfAlert>
+ {{ loadError }}
+ <template #actions
+ ><CfButton
+ size="sm"
+ variant="secondary"
+ :loading="loading"
+ @click="refreshMedia"
+ >{{ $t('cloud.messages.retry') }}</CfButton
+ ></template
+ ></CfAlert
+ >
<CfAlert
class="mb-4"
v-if="message && message !== loadError"
diff --git a/apps/cloud/app/components/CloudStorageSettings.vue b/apps/cloud/app/components/CloudStorageSettings.vue
index acf2e257..fd884cd6 100644
--- a/apps/cloud/app/components/CloudStorageSettings.vue
+++ b/apps/cloud/app/components/CloudStorageSettings.vue
@@ -177,7 +177,7 @@ const byosAdmission = computed(() => quota.gate('byos'))
>
<label
>{{ $t('cloud.messages.newAccessKeyId')
- }}<input
+ }}<CfInput
v-model="rotation.accessKeyId"
class="cf-input"
autocomplete="off"
@@ -185,7 +185,7 @@ const byosAdmission = computed(() => quota.gate('byos'))
/></label>
<label
>{{ $t('cloud.messages.newSecretAccessKey')
- }}<input
+ }}<CfInput
v-model="rotation.secretAccessKey"
class="cf-input"
type="password"
@@ -211,7 +211,7 @@ const byosAdmission = computed(() => quota.gate('byos'))
>
<label
>{{ $t('cloud.messages.endpoint')
- }}<input
+ }}<CfInput
v-model="storage.endpoint"
class="cf-input"
type="url"
@@ -220,21 +220,21 @@ const byosAdmission = computed(() => quota.gate('byos'))
/></label>
<label
>{{ $t('cloud.messages.region')
- }}<input
+ }}<CfInput
v-model="storage.region"
class="cf-input"
required
/></label>
<label
>{{ $t('cloud.messages.bucket')
- }}<input
+ }}<CfInput
v-model="storage.bucket"
class="cf-input"
required
/></label>
<label
>{{ $t('cloud.messages.accessKeyId')
- }}<input
+ }}<CfInput
v-model="storage.accessKeyId"
class="cf-input"
autocomplete="off"
@@ -242,7 +242,7 @@ const byosAdmission = computed(() => quota.gate('byos'))
/></label>
<label
>{{ $t('cloud.messages.secretAccessKey')
- }}<input
+ }}<CfInput
v-model="storage.secretAccessKey"
class="cf-input"
type="password"
diff --git a/apps/cloud/app/components/CloudTransferPanel.vue b/apps/cloud/app/components/CloudTransferPanel.vue
index 45641932..5610ccd5 100644
--- a/apps/cloud/app/components/CloudTransferPanel.vue
+++ b/apps/cloud/app/components/CloudTransferPanel.vue
@@ -93,7 +93,9 @@ function photoName(job: Job) {
:aria-label="t('cloud.transfer.title')"
>
<header class="flex items-center gap-2 border-b border-default p-4">
- <button
+ <UButton
+ variant="ghost"
+ color="neutral"
class="flex min-w-0 flex-1 items-center gap-3 text-left"
type="button"
:aria-expanded="!collapsed"
@@ -116,7 +118,7 @@ function photoName(job: Job) {
"
class="size-4 shrink-0"
/>
- </button>
+ </UButton>
<UButton
v-if="!hasActive"
icon="i-lucide-x"
diff --git a/apps/cloud/app/components/CloudUploadDrawer.vue b/apps/cloud/app/components/CloudUploadDrawer.vue
index aa58bd22..b4386ab1 100644
--- a/apps/cloud/app/components/CloudUploadDrawer.vue
+++ b/apps/cloud/app/components/CloudUploadDrawer.vue
@@ -184,7 +184,9 @@ async function startUpload() {
:aria-label="$t('cloud.messages.choosePhotographs')"
:disabled="selectionLocked || !uploadAllowed || !admin"
@change="selectFiles"
- /><button
+ /><UButton
+ variant="ghost"
+ color="neutral"
class="cf-upload-dropzone"
@dragover.prevent
@drop.prevent="dropFiles"
@@ -203,7 +205,7 @@ async function startUpload() {
size: (fileLimit / 1048576).toFixed(0),
})
}}</span>
- </button>
+ </UButton>
<section
v-if="selectedFiles.length"
class="space-y-3"
diff --git a/apps/cloud/app/components/CloudUserMenu.vue b/apps/cloud/app/components/CloudUserMenu.vue
index ec23a578..3f76302b 100644
--- a/apps/cloud/app/components/CloudUserMenu.vue
+++ b/apps/cloud/app/components/CloudUserMenu.vue
@@ -1,21 +1,8 @@
<script setup lang="ts">
const { t } = useI18n()
-import {
- ChevronsUpDown,
- UserRound,
- LogOut,
- CreditCard,
- Ticket,
-} from 'lucide-vue-next'
-import {
- DropdownMenuRoot,
- DropdownMenuTrigger,
- DropdownMenuPortal,
- DropdownMenuContent,
- DropdownMenuItem,
- DropdownMenuSeparator,
-} from 'reka-ui'
+import { ChevronsUpDown } from 'lucide-vue-next'
+
const user = usePortalIdentity(),
{ busy, error, signOut } = useCloudSignOut()
const label = computed(
@@ -30,6 +17,41 @@ const initials = computed(() =>
.join('')
.toUpperCase(),
)
+const menuItems = computed(() => [
+ [{ type: 'label' as const, label: label.value }],
+ [
+ {
+ label: t('cloud.messages.accountSecurity'),
+ icon: 'i-lucide-user-round',
+ to: '/account',
+ },
+ {
+ label: t('cloud.billing.plan'),
+ icon: 'i-lucide-credit-card',
+ to: '/account/plan',
+ },
+ {
+ label: t('cloud.billing.redeem'),
+ icon: 'i-lucide-ticket',
+ to: '/account/redeem',
+ },
+ {
+ label: '[email protected]',
+ icon: 'i-lucide-mail',
+ href: 'mailto:[email protected]',
+ },
+ ],
+ [
+ {
+ label: busy.value
+ ? t('cloud.messages.signingOut')
+ : t('cloud.messages.signOut'),
+ icon: 'i-lucide-log-out',
+ disabled: busy.value,
+ onSelect: () => signOut(),
+ },
+ ],
+])
</script>
<template>
<div class="cf-user-menu">
@@ -40,63 +62,33 @@ const initials = computed(() =>
>
{{ error }}
</p>
- <DropdownMenuRoot
- ><DropdownMenuTrigger as-child
- ><button
- class="cf-user-trigger"
- :aria-label="$t('cloud.messages.openUserMenu')"
- >
- <span class="cf-user-avatar">{{ initials }}</span
- ><span class="cf-user-identity"
- ><strong>{{ label }}</strong
- ><span>{{
- user?.email || $t('cloud.messages.accountSettings')
- }}</span></span
- ><ChevronsUpDown :size="15" /></button
- ></DropdownMenuTrigger>
- <DropdownMenuPortal
- ><DropdownMenuContent
- class="cf-account-menu"
- side="top"
- align="start"
- :side-offset="8"
- :collision-padding="12"
- :aria-label="$t('cloud.messages.userMenu')"
- >
- <div class="cf-account-menu-label">
- <strong>{{ label }}</strong
- ><span>{{ user?.email }}</span>
- </div>
- <DropdownMenuSeparator class="cf-menu-separator" />
- <DropdownMenuItem as-child
- ><NuxtLink to="/account"
- ><UserRound :size="16" />{{
- $t('cloud.messages.accountSecurity')
- }}</NuxtLink
- ></DropdownMenuItem
- >
- <DropdownMenuItem as-child
- ><NuxtLink to="/account/plan"
- ><CreditCard :size="16" />{{ $t('cloud.billing.plan') }}</NuxtLink
- ></DropdownMenuItem
- ><DropdownMenuItem as-child
- ><NuxtLink to="/account/redeem"
- ><Ticket :size="16" />{{ $t('cloud.billing.redeem') }}</NuxtLink
- ></DropdownMenuItem
- >
- <DropdownMenuItem as-child><CloudSupportLink /></DropdownMenuItem>
- <DropdownMenuSeparator class="cf-menu-separator" />
- <DropdownMenuItem
- :disabled="busy"
- @select="signOut"
- ><LogOut :size="16" />{{
- busy
- ? $t('cloud.messages.signingOut')
- : $t('cloud.messages.signOut')
- }}</DropdownMenuItem
- >
- </DropdownMenuContent></DropdownMenuPortal
+ <UDropdownMenu
+ :items="menuItems"
+ :content="{
+ side: 'top',
+ align: 'start',
+ sideOffset: 8,
+ collisionPadding: 12,
+ }"
+ >
+ <UButton
+ color="neutral"
+ variant="ghost"
+ class="cf-user-trigger"
+ :aria-label="$t('cloud.messages.openUserMenu')"
>
- </DropdownMenuRoot>
+ <UAvatar
+ :text="initials"
+ size="sm"
+ />
+ <span class="cf-user-identity"
+ ><strong>{{ label }}</strong
+ ><span>{{
+ user?.email || $t('cloud.messages.accountSettings')
+ }}</span></span
+ >
+ <ChevronsUpDown :size="15" />
+ </UButton>
+ </UDropdownMenu>
</div>
</template>
diff --git a/apps/cloud/app/error.vue b/apps/cloud/app/error.vue
index a5e56378..336a75ca 100644
--- a/apps/cloud/app/error.vue
+++ b/apps/cloud/app/error.vue
@@ -34,10 +34,8 @@ const notFound = computed(() => props.error.statusCode === 404)
<div class="cf-header-actions">
<CfButton
variant="secondary"
- as-child
- ><a href="https://chronoframe.art/"
- ><ArrowLeft :size="15" />{{ $t('cloud.messages.backToHome') }}</a
- ></CfButton
+ href="https://chronoframe.art/"
+ ><ArrowLeft :size="15" />{{ $t('cloud.messages.backToHome') }}</CfButton
><CfButton
v-if="!notFound"
@click="reloadNuxtApp({ force: true })"
diff --git a/apps/cloud/app/pages/account/plan.vue b/apps/cloud/app/pages/account/plan.vue
index aa751793..62cde55e 100644
--- a/apps/cloud/app/pages/account/plan.vue
+++ b/apps/cloud/app/pages/account/plan.vue
@@ -167,11 +167,9 @@ const date = (time: number) => new Date(time).toLocaleString(locale.value)
</p>
<CfButton
v-if="data.workspace.role === 'admin'"
- as-child
variant="secondary"
- ><NuxtLink :to="links.redeem">{{
- $t('cloud.billing.redeem')
- }}</NuxtLink></CfButton
+ :to="links.redeem"
+ >{{ $t('cloud.billing.redeem') }}</CfButton
>
</div>
<p
diff --git a/apps/cloud/app/pages/index.vue b/apps/cloud/app/pages/index.vue
index 443d8ae3..7c76b564 100644
--- a/apps/cloud/app/pages/index.vue
+++ b/apps/cloud/app/pages/index.vue
@@ -16,11 +16,51 @@ import {
const entrance = useCloudMotion()
const links = useCloudLinks()
const photoColumns = [
- ['mountains', 'lake', 'forest', 'desert', 'coast', 'valley', 'waterfall', 'hills', 'sea'],
- ['coast', 'waterfall', 'hills', 'forest', 'sea', 'mountains', 'lake', 'desert', 'valley'],
- ['forest', 'valley', 'sea', 'lake', 'mountains', 'waterfall', 'desert', 'coast', 'hills'],
- ['desert', 'mountains', 'coast', 'hills', 'waterfall', 'valley', 'forest', 'sea', 'lake'],
-].map(column => column.map(name => `/images/${name}.jpg`))
+ [
+ 'mountains',
+ 'lake',
+ 'forest',
+ 'desert',
+ 'coast',
+ 'valley',
+ 'waterfall',
+ 'hills',
+ 'sea',
+ ],
+ [
+ 'coast',
+ 'waterfall',
+ 'hills',
+ 'forest',
+ 'sea',
+ 'mountains',
+ 'lake',
+ 'desert',
+ 'valley',
+ ],
+ [
+ 'forest',
+ 'valley',
+ 'sea',
+ 'lake',
+ 'mountains',
+ 'waterfall',
+ 'desert',
+ 'coast',
+ 'hills',
+ ],
+ [
+ 'desert',
+ 'mountains',
+ 'coast',
+ 'hills',
+ 'waterfall',
+ 'valley',
+ 'forest',
+ 'sea',
+ 'lake',
+ ],
+].map((column) => column.map((name) => `/images/${name}.jpg`))
const preview = ref<HTMLElement | null>(null)
let frame = 0
let currentX = 0
@@ -46,7 +86,11 @@ function animatePreview(time: number) {
}
function updatePreview(event: PointerEvent) {
- if (event.pointerType !== 'mouse' || matchMedia('(prefers-reduced-motion: reduce)').matches) return
+ if (
+ event.pointerType !== 'mouse' ||
+ matchMedia('(prefers-reduced-motion: reduce)').matches
+ )
+ return
const bounds = (event.currentTarget as HTMLElement).getBoundingClientRect()
targetX = (0.5 - (event.clientY - bounds.top) / bounds.height) * 8
targetY = ((event.clientX - bounds.left) / bounds.width - 0.5) * 10
@@ -75,8 +119,7 @@ useSeoMeta({
tabindex="-1"
>
<section class="cf-hero">
- <motion.div v-bind="entrance"
- >
+ <motion.div v-bind="entrance">
<h1 class="cf-hero-title">
{{ $t('cloud.messages.everyFrame') }}<br /><em>{{
$t('cloud.messages.yourStory')
@@ -87,21 +130,18 @@ useSeoMeta({
</p>
<div class="cf-hero-actions">
<CfButton
- as-child
size="lg"
- ><NuxtLink
- :to="links.signup"
- external
- >{{ $t('cloud.messages.createYourAccount')
- }}<ArrowRight :size="16" /></NuxtLink></CfButton
+ :to="links.signup"
+ external
+ >{{ $t('cloud.messages.createYourAccount')
+ }}<ArrowRight :size="16" /></CfButton
><CfButton
- as-child
variant="secondary"
size="lg"
- ><a href="https://docs.chronoframe.art/guide/getting-started.html"
- >{{ $t('cloud.messages.exploreSelfHosted')
- }}<ArrowUpRight :size="16" /></a
- ></CfButton>
+ href="https://docs.chronoframe.art/guide/getting-started.html"
+ >{{ $t('cloud.messages.exploreSelfHosted')
+ }}<ArrowUpRight :size="16"
+ /></CfButton>
</div>
<p class="cf-small-note">
{{ $t('cloud.messages.chooseHostedOrSelfHosted') }}
@@ -109,36 +149,63 @@ useSeoMeta({
>
<motion.div v-bind="entrance"
><div
- ref="preview" class="cf-gallery-preview" @pointermove="updatePreview" @pointerleave="resetPreview"
+ ref="preview"
+ class="cf-gallery-preview"
+ @pointermove="updatePreview"
+ @pointerleave="resetPreview"
:aria-label="$t('cloud.messages.examplePhotographyGallery')"
>
- <div class="cf-preview-header" aria-hidden="true">
+ <div
+ class="cf-preview-header"
+ aria-hidden="true"
+ >
<div class="cf-preview-avatar">C</div>
- <div class="cf-preview-identity"><strong>My Memories</strong><span>A ChronoFrame gallery</span></div>
- <div class="cf-preview-info"><strong>128 photos</strong><span>Small moments. Wide horizons.</span></div>
+ <div class="cf-preview-identity">
+ <strong>My Memories</strong><span>A ChronoFrame gallery</span>
+ </div>
+ <div class="cf-preview-info">
+ <strong>128 photos</strong
+ ><span>Small moments. Wide horizons.</span>
+ </div>
<Search :size="15" /><SlidersHorizontal :size="15" />
</div>
- <div class="cf-photo-wall" aria-hidden="true">
- <div v-for="(column, columnIndex) in photoColumns" :key="columnIndex" class="cf-photo-column">
+ <div
+ class="cf-photo-wall"
+ aria-hidden="true"
+ >
+ <div
+ v-for="(column, columnIndex) in photoColumns"
+ :key="columnIndex"
+ class="cf-photo-column"
+ >
<div class="cf-photo-track">
- <div v-for="copy in 2" :key="copy" class="cf-photo-sequence">
- <img v-for="(photo, index) in column" :key="photo" :src="photo" :class="`cf-photo-${(index + columnIndex) % 3}`" alt="" width="400" height="300" />
+ <div
+ v-for="copy in 2"
+ :key="copy"
+ class="cf-photo-sequence"
+ >
+ <img
+ v-for="(photo, index) in column"
+ :key="photo"
+ :src="photo"
+ :class="`cf-photo-${(index + columnIndex) % 3}`"
+ alt=""
+ width="400"
+ height="300"
+ />
</div>
</div>
</div>
- </div>
- </div></motion.div
- >
+ </div></div
+ ></motion.div>
</section>
<section aria-labelledby="features-heading">
<div class="cf-section-heading">
<div>
-
<h2 id="features-heading">
{{ $t('cloud.messages.thoughtfullySimpleEntirelyYours') }}
</h2>
</div>
-
</div>
<div class="cf-features">
<article>
@@ -183,37 +250,256 @@ useSeoMeta({
</article>
</div>
</section>
- <section class="cf-story" aria-labelledby="story-heading">
+ <section
+ class="cf-story"
+ aria-labelledby="story-heading"
+ >
<div class="cf-story-intro">
<h2 id="story-heading">{{ $t('cloud.home.storyTitle') }}</h2>
<p>{{ $t('cloud.home.storyDescription') }}</p>
</div>
<div class="cf-story-layout">
- <div class="cf-story-gallery" aria-hidden="true">
- <img src="/images/valley.jpg" alt="" loading="lazy" width="600" height="400" />
- <img src="/images/forest.jpg" alt="" loading="lazy" width="400" height="300" />
- <img src="/images/coast.jpg" alt="" loading="lazy" width="400" height="300" />
+ <div
+ class="cf-story-gallery"
+ aria-hidden="true"
+ >
+ <img
+ src="/images/valley.jpg"
+ alt=""
+ loading="lazy"
+ width="600"
+ height="400"
+ />
+ <img
+ src="/images/forest.jpg"
+ alt=""
+ loading="lazy"
+ width="400"
+ height="300"
+ />
+ <img
+ src="/images/coast.jpg"
+ alt=""
+ loading="lazy"
+ width="400"
+ height="300"
+ />
</div>
<div class="cf-story-details">
- <div><Image :size="21" :stroke-width="1.5" aria-hidden="true" /><h3>{{ $t('cloud.home.browseTitle') }}</h3><p>{{ $t('cloud.home.browseDescription') }}</p></div>
- <div><Search :size="21" :stroke-width="1.5" aria-hidden="true" /><h3>{{ $t('cloud.home.detailTitle') }}</h3><p>{{ $t('cloud.home.detailDescription') }}</p></div>
+ <div>
+ <Image
+ :size="21"
+ :stroke-width="1.5"
+ aria-hidden="true"
+ />
+ <h3>{{ $t('cloud.home.browseTitle') }}</h3>
+ <p>{{ $t('cloud.home.browseDescription') }}</p>
+ </div>
+ <div>
+ <Search
+ :size="21"
+ :stroke-width="1.5"
+ aria-hidden="true"
+ />
+ <h3>{{ $t('cloud.home.detailTitle') }}</h3>
+ <p>{{ $t('cloud.home.detailDescription') }}</p>
+ </div>
</div>
</div>
</section>
- <section class="cf-ways" aria-labelledby="ways-heading">
+ <section
+ class="cf-ways"
+ aria-labelledby="ways-heading"
+ >
<div class="cf-ways-heading">
-
<h2 id="ways-heading">{{ $t('cloud.home.waysTitle') }}</h2>
<p>{{ $t('cloud.home.waysDescription') }}</p>
</div>
<div class="cf-ways-grid">
- <NuxtLink :to="links.signup" external class="cf-way-card cf-way-cloud"><svg class="cf-way-art" viewBox="0 0 200 150" fill="none" aria-hidden="true"><rect x="22" y="22" width="158" height="116" rx="8" fill="var(--card)" stroke="currentColor"/><path d="M22 46h158" stroke="currentColor"/><circle cx="34" cy="34" r="2" fill="currentColor"/><circle cx="42" cy="34" r="2" fill="currentColor"/><rect x="32" y="56" width="65" height="72" rx="3" fill="currentColor" opacity=".32"/><rect x="103" y="56" width="67" height="32" rx="3" fill="currentColor" opacity=".18"/><rect x="103" y="94" width="67" height="34" rx="3" fill="currentColor" opacity=".24"/></svg><span class="cf-way-ribbon">{{ $t('cloud.home.trialRibbon') }}</span><div class="cf-way-icon" aria-hidden="true"><Cloud :size="22" :stroke-width="1.5" /></div><h3>ChronoFrame Cloud <ArrowRight :size="16" aria-hidden="true" /></h3><p>{{ $t('cloud.home.cloudDescription') }}</p></NuxtLink>
- <a href="https://docs.chronoframe.art/guide/getting-started.html" class="cf-way-card cf-way-server"><svg class="cf-way-art" viewBox="0 0 200 150" fill="none" aria-hidden="true"><rect x="22" y="22" width="158" height="116" rx="8" fill="var(--card)" stroke="currentColor"/><path d="M22 46h158M59 46v92" stroke="currentColor"/><circle cx="34" cy="34" r="2" fill="currentColor"/><circle cx="42" cy="34" r="2" fill="currentColor"/><path d="M33 62h15M33 73h15M33 84h15" stroke="currentColor" stroke-linecap="round"/><rect x="70" y="57" width="98" height="18" rx="3" fill="currentColor" opacity=".23"/><rect x="70" y="82" width="98" height="18" rx="3" fill="currentColor" opacity=".16"/><rect x="70" y="107" width="98" height="18" rx="3" fill="currentColor" opacity=".23"/></svg><div class="cf-way-icon" aria-hidden="true"><Server :size="22" :stroke-width="1.5" /></div><h3>{{ $t('cloud.home.selfHostedTitle') }} <ArrowUpRight :size="16" aria-hidden="true" /></h3><p>{{ $t('cloud.home.selfHostedDescription') }}</p></a>
+ <NuxtLink
+ :to="links.signup"
+ external
+ class="cf-way-card cf-way-cloud"
+ ><svg
+ class="cf-way-art"
+ viewBox="0 0 200 150"
+ fill="none"
+ aria-hidden="true"
+ >
+ <rect
+ x="22"
+ y="22"
+ width="158"
+ height="116"
+ rx="8"
+ fill="var(--card)"
+ stroke="currentColor"
+ />
+ <path
+ d="M22 46h158"
+ stroke="currentColor"
+ />
+ <circle
+ cx="34"
+ cy="34"
+ r="2"
+ fill="currentColor"
+ />
+ <circle
+ cx="42"
+ cy="34"
+ r="2"
+ fill="currentColor"
+ />
+ <rect
+ x="32"
+ y="56"
+ width="65"
+ height="72"
+ rx="3"
+ fill="currentColor"
+ opacity=".32"
+ />
+ <rect
+ x="103"
+ y="56"
+ width="67"
+ height="32"
+ rx="3"
+ fill="currentColor"
+ opacity=".18"
+ />
+ <rect
+ x="103"
+ y="94"
+ width="67"
+ height="34"
+ rx="3"
+ fill="currentColor"
+ opacity=".24"
+ /></svg
+ ><span class="cf-way-ribbon">{{
+ $t('cloud.home.trialRibbon')
+ }}</span>
+ <div
+ class="cf-way-icon"
+ aria-hidden="true"
+ >
+ <Cloud
+ :size="22"
+ :stroke-width="1.5"
+ />
+ </div>
+ <h3>
+ ChronoFrame Cloud
+ <ArrowRight
+ :size="16"
+ aria-hidden="true"
+ />
+ </h3>
+ <p>{{ $t('cloud.home.cloudDescription') }}</p></NuxtLink
+ >
+ <a
+ href="https://docs.chronoframe.art/guide/getting-started.html"
+ class="cf-way-card cf-way-server"
+ ><svg
+ class="cf-way-art"
+ viewBox="0 0 200 150"
+ fill="none"
+ aria-hidden="true"
+ >
+ <rect
+ x="22"
+ y="22"
+ width="158"
+ height="116"
+ rx="8"
+ fill="var(--card)"
+ stroke="currentColor"
+ />
+ <path
+ d="M22 46h158M59 46v92"
+ stroke="currentColor"
+ />
+ <circle
+ cx="34"
+ cy="34"
+ r="2"
+ fill="currentColor"
+ />
+ <circle
+ cx="42"
+ cy="34"
+ r="2"
+ fill="currentColor"
+ />
+ <path
+ d="M33 62h15M33 73h15M33 84h15"
+ stroke="currentColor"
+ stroke-linecap="round"
+ />
+ <rect
+ x="70"
+ y="57"
+ width="98"
+ height="18"
+ rx="3"
+ fill="currentColor"
+ opacity=".23"
+ />
+ <rect
+ x="70"
+ y="82"
+ width="98"
+ height="18"
+ rx="3"
+ fill="currentColor"
+ opacity=".16"
+ />
+ <rect
+ x="70"
+ y="107"
+ width="98"
+ height="18"
+ rx="3"
+ fill="currentColor"
+ opacity=".23"
+ />
+ </svg>
+ <div
+ class="cf-way-icon"
+ aria-hidden="true"
+ >
+ <Server
+ :size="22"
+ :stroke-width="1.5"
+ />
+ </div>
+ <h3>
+ {{ $t('cloud.home.selfHostedTitle') }}
+ <ArrowUpRight
+ :size="16"
+ aria-hidden="true"
+ />
+ </h3>
+ <p>{{ $t('cloud.home.selfHostedDescription') }}</p></a
+ >
</div>
</section>
- <section class="cf-home-cta" aria-labelledby="home-cta-heading">
- <div><h2 id="home-cta-heading">{{ $t('cloud.home.ctaTitle') }}</h2><p>{{ $t('cloud.home.ctaDescription') }}</p></div>
- <CfButton as-child size="lg"><NuxtLink :to="links.signup" external>{{ $t('cloud.messages.createYourAccount') }} <ArrowRight :size="16" /></NuxtLink></CfButton>
+ <section
+ class="cf-home-cta"
+ aria-labelledby="home-cta-heading"
+ >
+ <div>
+ <h2 id="home-cta-heading">{{ $t('cloud.home.ctaTitle') }}</h2>
+ <p>{{ $t('cloud.home.ctaDescription') }}</p>
+ </div>
+ <CfButton
+ size="lg"
+ :to="links.signup"
+ external
+ >{{ $t('cloud.messages.createYourAccount') }} <ArrowRight :size="16"
+ /></CfButton>
</section>
</main>
<footer class="cf-marketing-footer">
@@ -223,8 +509,11 @@ useSeoMeta({
<p>{{ $t('cloud.messages.aHomeForYourPhotographs') }}</p>
</div>
<div class="cf-footer-links">
- <a href="https://github.com/HoshinoSuzumi/chronoframe/blob/main/LICENSING.md">
- {{ $t('cloud.messages.sourceAndLicensing') }}<ArrowUpRight :size="13" />
+ <a
+ href="https://github.com/HoshinoSuzumi/chronoframe/blob/main/LICENSING.md"
+ >
+ {{ $t('cloud.messages.sourceAndLicensing')
+ }}<ArrowUpRight :size="13" />
</a>
<CloudSupportLink />
</div>
diff --git a/apps/cloud/app/pages/legal/[kind].vue b/apps/cloud/app/pages/legal/[kind].vue
index 58b07f5c..c2aefbab 100644
--- a/apps/cloud/app/pages/legal/[kind].vue
+++ b/apps/cloud/app/pages/legal/[kind].vue
@@ -67,11 +67,11 @@ const updated = computed(() =>
v-if="error"
tone="error"
>{{ $t('cloud.legal.loadFailed')
- }}<CfButton
+ }}<template #actions><CfButton
variant="secondary"
@click="refresh()"
>{{ $t('cloud.messages.retry') }}</CfButton
- ></CfAlert
+ ></template></CfAlert
>
<article
v-else-if="document"
diff --git a/apps/cloud/app/pages/sites/[siteId]/overview.vue b/apps/cloud/app/pages/sites/[siteId]/overview.vue
index aaa7ba50..d0f3a909 100644
--- a/apps/cloud/app/pages/sites/[siteId]/overview.vue
+++ b/apps/cloud/app/pages/sites/[siteId]/overview.vue
@@ -181,13 +181,15 @@ const {
<p class="cf-field-hint">
{{ $t('cloud.dashboard.popularError') }}
</p>
- <button
+ <UButton
+ variant="ghost"
+ color="neutral"
type="button"
class="cf-text-link"
@click="refreshPopular()"
>
{{ $t('cloud.messages.retry') }}
- </button>
+ </UButton>
</div>
<ol
v-else-if="popular?.pages?.length"
diff --git a/apps/cloud/app/pages/workspace.vue b/apps/cloud/app/pages/workspace.vue
index 828c0c2c..74531d02 100644
--- a/apps/cloud/app/pages/workspace.vue
+++ b/apps/cloud/app/pages/workspace.vue
@@ -58,11 +58,13 @@ useSeoMeta({
v-if="billing.error.value"
tone="error"
>{{ $t('cloud.dashboard.quotaUnavailable')
- }}<CfButton
- size="sm"
- variant="secondary"
- @click="billing.refresh()"
- >{{ $t('cloud.messages.retry') }}</CfButton
+ }}<template #actions
+ ><CfButton
+ size="sm"
+ variant="secondary"
+ @click="billing.refresh()"
+ >{{ $t('cloud.messages.retry') }}</CfButton
+ ></template
></CfAlert
>
<section
@@ -90,13 +92,11 @@ useSeoMeta({
<h2>{{ $t('cloud.dashboard.galleries') }}</h2>
<CfButton
v-if="sites.length > 1"
- as-child
variant="ghost"
size="sm"
- ><NuxtLink to="/sites"
- >{{ $t('cloud.messages.allSites')
- }}<ArrowUpRight :size="14" /></NuxtLink
- ></CfButton>
+ to="/sites"
+ >{{ $t('cloud.messages.allSites') }}<ArrowUpRight :size="14"
+ /></CfButton>
</div>
<ul
v-if="sites.length"
@@ -128,13 +128,12 @@ useSeoMeta({
</div>
<CfButton
v-if="!site.suspended"
- as-child
variant="secondary"
size="sm"
- ><NuxtLink :to="`/sites/${site.siteId}/overview`"
- >{{ $t('cloud.dashboard.manageGallery')
- }}<ChevronRight :size="14" /></NuxtLink
- ></CfButton>
+ :to="`/sites/${site.siteId}/overview`"
+ >{{ $t('cloud.dashboard.manageGallery')
+ }}<ChevronRight :size="14"
+ /></CfButton>
</div>
<div
v-if="!site.suspended"
diff --git a/packages/saas-ui/app/app.config.ts b/packages/saas-ui/app/app.config.ts
index 2410c5ed..7927e364 100644
--- a/packages/saas-ui/app/app.config.ts
+++ b/packages/saas-ui/app/app.config.ts
@@ -2,7 +2,10 @@
// Explicit radii avoid Nuxt UI scaling --ui-radius into oversized menu corners.
const selectSlots = {
base: 'min-h-[var(--cf-control-height)] pointer-coarse:min-h-11 pointer-coarse:text-base rounded-[6px]',
- content: 'bg-default text-default ring ring-default rounded-[6px] shadow-lg',
+ content:
+ 'w-max min-w-(--reka-select-trigger-width) max-w-[min(32rem,calc(100vw-2rem))] bg-default text-default ring ring-default rounded-[6px] shadow-lg',
+ itemLabel: 'whitespace-normal overflow-visible text-clip break-words',
+ itemDescription: 'whitespace-normal overflow-visible text-clip break-words',
item: 'before:rounded-[4px] data-highlighted:not-data-disabled:before:bg-muted',
}
@@ -18,7 +21,13 @@ export default defineAppConfig({
error: 'red',
},
select: { slots: selectSlots },
- selectMenu: { slots: selectSlots },
+ selectMenu: {
+ slots: {
+ ...selectSlots,
+ content:
+ 'w-max min-w-(--reka-combobox-trigger-width) max-w-[min(32rem,calc(100vw-2rem))] bg-default text-default ring ring-default rounded-[6px] shadow-lg',
+ },
+ },
dropdownMenu: {
slots: {
content:
@@ -34,6 +43,13 @@ export default defineAppConfig({
},
},
},
+ input: {
+ slots: {
+ root: 'w-full',
+ base: 'min-h-[var(--cf-control-height)] pointer-coarse:min-h-11 pointer-coarse:text-base',
+ },
+ },
+ textarea: { slots: { root: 'w-full', base: 'pointer-coarse:text-base' } },
button: { slots: { base: 'cursor-pointer rounded-md font-medium' } },
modal: {
variants: { overlay: { true: { overlay: 'bg-black/55' } } },
@@ -58,6 +74,9 @@ export default defineAppConfig({
card: {
variants: {
variant: {
+ outline: {
+ root: 'bg-elevated ring ring-default divide-y divide-default',
+ },
// Compatibility for inherited gallery/console surfaces, without glass.
glassmorphism: {
root: 'bg-default ring ring-default rounded-lg divide-y divide-default',
diff --git a/packages/saas-ui/app/assets/primitives.css b/packages/saas-ui/app/assets/primitives.css
index 493b5e79..e050da37 100644
--- a/packages/saas-ui/app/assets/primitives.css
+++ b/packages/saas-ui/app/assets/primitives.css
@@ -6,193 +6,26 @@
.cf-error :is(h1, h2, p) {
margin: 0;
}
-.cf-root a,
-.cf-error a {
+.cf-root a:not([data-slot]),
+.cf-error a:not([data-slot]) {
text-decoration: none;
}
-.cf-root :is(a, button, input, select, textarea):focus-visible,
-.cf-error a:focus-visible {
+.cf-root a:not([data-slot]):focus-visible,
+.cf-error a:not([data-slot]):focus-visible {
outline: 2px solid var(--ring);
outline-offset: 4px;
}
.cf-root button,
-.cf-root a,
-.cf-error a {
+.cf-root a:not([data-slot]),
+.cf-error a:not([data-slot]) {
-webkit-tap-highlight-color: transparent;
}
-.cf-button {
- display: inline-flex;
- align-items: center;
- justify-content: center;
- gap: 6px;
- height: var(--cf-control-height);
- padding: 0 12px;
- border: 1px solid transparent;
- border-radius: 6px;
- font-size: 13px;
- font-weight: 550;
- white-space: nowrap;
- cursor: pointer;
- transition:
- background 0.18s,
- border-color 0.18s,
- transform 0.18s;
-}
-.cf-button:focus-visible,
-.cf-input:focus-visible,
-.cf-segmented-item:focus-visible {
- outline: 2px solid var(--ring);
- outline-offset: 3px;
-}
-.cf-spin {
- animation: cf-spin 1s linear infinite;
-}
-.cf-button-primary {
- background: var(--primary);
- color: var(--primary-foreground);
-}
-.cf-button-primary:hover {
- filter: brightness(1.1);
-}
-.cf-button-secondary {
- background: var(--card);
- color: var(--foreground);
- border-color: var(--border);
-}
-.cf-button-secondary:hover,
-.cf-button-ghost:hover {
- background: var(--secondary);
-}
-.cf-button-ghost {
- background: transparent;
- color: var(--foreground);
-}
-.cf-button-destructive {
- background: transparent;
- color: var(--destructive);
- border-color: var(--border);
-}
-.cf-button-destructive:hover {
- background: var(--muted);
-}
-.cf-button-lg {
- height: 40px;
- padding: 0 22px;
- font-size: 14px;
-}
-.cf-button-sm {
- height: 30px;
- padding: 0 12px;
- font-size: 12px;
-}
-.cf-button-icon {
- width: 32px;
- height: 32px;
- padding: 0;
-}
-.cf-button:disabled {
- opacity: 0.5;
- cursor: not-allowed;
-}
+/* Component visuals come from Nuxt UI; Cf classes are layout hooks only. */
.cf-input {
width: 100%;
- min-height: var(--cf-control-height);
- border: 1px solid var(--input);
- border-radius: 6px;
- padding: 7px 10px;
- background: var(--card);
- color: var(--foreground);
- font: inherit;
- transition: border-color 0.15s;
-}
-.cf-input::placeholder {
- color: var(--muted-foreground);
- opacity: 0.75;
-}
-.cf-input:disabled {
- background: var(--muted);
- color: var(--muted-foreground);
- cursor: not-allowed;
-}
-.cf-input[aria-invalid='true'] {
- border-color: var(--destructive);
-}
-.cf-card {
- background: var(--card);
- color: var(--card-foreground);
- border: 1px solid var(--border);
- border-radius: var(--radius);
-}
-.cf-badge {
- display: inline-flex;
- align-items: center;
- gap: 6px;
- padding: 3px 9px;
- border: 1px solid var(--border);
- border-radius: 5px;
- font-size: 11px;
- font-weight: 500;
- line-height: 1.6;
- white-space: nowrap;
-}
-.cf-badge-neutral {
- color: var(--muted-foreground);
- background: var(--muted);
-}
-.cf-badge-success {
- color: var(--success);
- background: var(--secondary);
-}
-.cf-badge-warning {
- color: var(--muted-foreground);
- background: var(--background);
-}
-
-.cf-progress {
- overflow: hidden;
- height: 4px;
- width: 100%;
- border-radius: 999px;
- background: var(--muted);
-}
-.cf-progress-indicator {
- height: 100%;
- background: var(--accent);
- border-radius: inherit;
- transition: width 180ms ease;
-}
-.cf-skeleton {
- display: inline-block;
- min-height: 1em;
- border-radius: 5px;
- background: var(--muted);
- animation: cf-pulse 1.8s ease-in-out infinite;
-}
-.cf-separator {
- height: 1px;
- width: 100%;
- background: var(--border);
- flex-shrink: 0;
-}
-.cf-alert {
- display: flex;
- flex-wrap: wrap;
- align-items: center;
- justify-content: space-between;
- gap: 12px;
- padding: 14px 16px;
- border: 1px solid var(--border);
- border-radius: 8px;
- background: var(--secondary);
- font-size: 13px;
-}
-.cf-alert[data-tone='error'] {
- color: var(--destructive);
}
-.cf-alert p {
- color: var(--muted-foreground);
- font-size: 12px;
- margin-top: 3px;
+.cf-spin {
+ animation: cf-spin 1s linear infinite;
}
.cf-select {
width: 100%;
@@ -209,33 +42,6 @@
.cf-table td > .cf-button + .cf-button {
margin-inline-start: 6px;
}
-.cf-segmented-control {
- display: inline-flex;
- padding: 4px;
- gap: 3px;
- border: 1px solid var(--border);
- border-radius: 8px;
- background: var(--muted);
-}
-.cf-segmented-item {
- border: 0;
- background: transparent;
- color: var(--muted-foreground);
- border-radius: 5px;
- padding: 7px 13px;
- font: inherit;
- font-size: 12px;
- cursor: pointer;
-}
-.cf-segmented-item[data-state='checked'] {
- background: var(--card);
- color: var(--foreground);
- box-shadow: 0 1px 3px #0000000a;
-}
-.cf-segmented-item:disabled {
- opacity: 0.5;
- cursor: not-allowed;
-}
.cf-stat-card {
display: grid;
align-content: start;
@@ -325,13 +131,6 @@
cursor: not-allowed;
}
@media (pointer: coarse) {
- .cf-input {
- min-height: 44px;
- font-size: 16px;
- }
- .cf-button {
- min-height: 40px;
- }
}
@media (prefers-reduced-motion: reduce) {
.cf-skeleton,
diff --git a/packages/saas-ui/app/assets/tokens.css b/packages/saas-ui/app/assets/tokens.css
index bb0243b0..43e907c9 100644
--- a/packages/saas-ui/app/assets/tokens.css
+++ b/packages/saas-ui/app/assets/tokens.css
@@ -21,6 +21,7 @@
--destructive: #b13f48;
--success: #297451;
--radius: 0.5rem;
+ --cf-link: #3b6b9a;
--cf-primary: var(--accent);
--cf-ink: var(--foreground);
--cf-muted: var(--muted-foreground);
@@ -52,7 +53,7 @@
--ui-border: var(--border);
--ui-border-muted: var(--border);
--ui-border-accented: var(--input);
- --ui-radius: var(--radius);
+ --ui-radius: 0.25rem;
}
.dark {
color-scheme: dark;
@@ -72,6 +73,7 @@
--accent: #c2a56f;
--destructive: #ed959e;
--success: #8bc6a7;
+ --cf-link: #8fb2d6;
}
html,
body {
diff --git a/packages/saas-ui/app/components/CfAlert.vue b/packages/saas-ui/app/components/CfAlert.vue
index a9e93c0a..c5a7dc9c 100644
--- a/packages/saas-ui/app/components/CfAlert.vue
+++ b/packages/saas-ui/app/components/CfAlert.vue
@@ -4,11 +4,14 @@ withDefaults(defineProps<{ tone?: 'info' | 'error' | 'success' }>(), {
})
</script>
<template>
- <div
+ <UAlert
+ :color="tone === 'info' ? 'neutral' : tone"
+ variant="subtle"
:role="tone === 'error' ? 'alert' : 'status'"
- class="cf-alert"
- :data-tone="tone"
- >
- <slot />
- </div>
+ ><template #description><slot /></template
+ ><template
+ v-if="$slots.actions"
+ #actions
+ ><slot name="actions" /></template
+ ></UAlert>
</template>
diff --git a/packages/saas-ui/app/components/CfAnalyticsPageLink.vue b/packages/saas-ui/app/components/CfAnalyticsPageLink.vue
index e152acd5..c7409829 100644
--- a/packages/saas-ui/app/components/CfAnalyticsPageLink.vue
+++ b/packages/saas-ui/app/components/CfAnalyticsPageLink.vue
@@ -14,6 +14,14 @@ const parts = computed(() =>
? [
...(props.admin ? [props.row.page.site] : []),
...props.row.page.segments,
+ ...(props.admin && !props.row.page.segments.length
+ ? [
+ {
+ title: props.zh ? '首页' : 'Home',
+ href: props.row.page.site.href,
+ },
+ ]
+ : []),
]
: [],
)
@@ -29,8 +37,8 @@ const parts = computed(() =>
:href="row.page.site.href"
target="_blank"
rel="noopener noreferrer"
- >/</a
- ><span v-else>/</span></template
+ >{{ zh ? '首页' : 'Home' }}</a
+ ><span v-else>{{ zh ? '首页' : 'Home' }}</span></template
>
<template
v-for="(part, index) in parts"
@@ -49,17 +57,17 @@ const parts = computed(() =>
}}</span>
</template>
</span>
- <span v-else>{{ row.label }}</span>
+ <span v-else>{{
+ row.label === '/' ? (zh ? '首页' : 'Home') : row.label
+ }}</span>
</template>
<style scoped>
.cf-page-links a {
- color: var(--color-blue-600, #2563eb);
+ color: var(--cf-link);
+ font-weight: 500;
text-decoration: none;
}
.cf-page-links a:hover {
text-decoration: underline;
}
-:global(.dark .cf-page-links a) {
- color: #60a5fa;
-}
</style>
diff --git a/packages/saas-ui/app/components/CfAnalyticsRange.vue b/packages/saas-ui/app/components/CfAnalyticsRange.vue
index e73b3e03..258555f3 100644
--- a/packages/saas-ui/app/components/CfAnalyticsRange.vue
+++ b/packages/saas-ui/app/components/CfAnalyticsRange.vue
@@ -192,8 +192,9 @@ function changeZone() {
:aria-label="tr('Select time range', '选择时间段')"
>
<div class="cf-range-custom">
- <input
+ <CfInput
v-model="custom"
+ variant="none"
class="cf-input"
:aria-label="tr('Custom duration', '自定义时长')"
:placeholder="
@@ -224,30 +225,33 @@ function changeZone() {
/>
</div>
<div class="cf-range-presets">
- <button
+ <UButton
+ color="neutral"
v-for="seconds in ANALYTICS_PRESETS"
:key="seconds"
type="button"
- :class="{ active: preset === seconds && !allTime }"
+ :variant="preset === seconds && !allTime ? 'soft' : 'ghost'"
@click="choose(seconds)"
>
{{ title(seconds) }}
- </button>
+ </UButton>
<div class="cf-range-long-divider"></div>
- <button
+ <UButton
+ color="neutral"
type="button"
- :class="{ active: preset === 365 * 86400 && !allTime }"
+ :variant="preset === 365 * 86400 && !allTime ? 'soft' : 'ghost'"
@click="choose(365 * 86400)"
>
{{ tr('Past year', '过去一年') }}
- </button>
- <button
+ </UButton>
+ <UButton
+ color="neutral"
type="button"
- :class="{ active: allTime }"
+ :variant="allTime ? 'soft' : 'ghost'"
@click="chooseAll"
>
{{ tr('All time', '所有时间') }}
- </button>
+ </UButton>
</div>
</div>
<p
@@ -267,7 +271,7 @@ function changeZone() {
>
<label
>{{ tr('Start', '开始')
- }}<input
+ }}<CfInput
v-model="draftFrom"
type="datetime-local"
class="cf-input"
@@ -275,7 +279,7 @@ function changeZone() {
@change="syncCalendar" /></label
><label
>{{ tr('End', '结束')
- }}<input
+ }}<CfInput
v-model="draftTo"
type="datetime-local"
class="cf-input"
@@ -317,7 +321,7 @@ function changeZone() {
.cf-range-picker {
width: min(540px, calc(100vw - 24px));
background: var(--card);
- border-radius: 12px;
+ border-radius: 8px;
overflow-y: auto;
max-height: min(90dvh, var(--reka-popover-content-available-height, 90dvh));
}
@@ -349,19 +353,8 @@ function changeZone() {
gap: 2px;
padding: 16px 12px;
}
-.cf-range-presets button {
- text-align: left;
- border: 0;
- background: transparent;
- border-radius: 6px;
- padding: 7px 12px;
- font-size: 13px;
- color: var(--foreground);
- cursor: pointer;
-}
-.cf-range-presets button:hover,
-.cf-range-presets button.active {
- background: var(--secondary);
+.cf-range-presets :deep(button) {
+ justify-content: flex-start;
}
.cf-range-all-time {
padding: 16px;
diff --git a/packages/saas-ui/app/components/CfAnalyticsReport.vue b/packages/saas-ui/app/components/CfAnalyticsReport.vue
index b2ed78ad..5ffab27f 100644
--- a/packages/saas-ui/app/components/CfAnalyticsReport.vue
+++ b/packages/saas-ui/app/components/CfAnalyticsReport.vue
@@ -18,6 +18,22 @@ const groups = computed(() => [
tr('Campaigns (source / medium / campaign)', '推广来源/媒介/活动'),
],
])
+const columns = (time = false) => [
+ {
+ accessorKey: 'label',
+ header: time ? tr('Time (UTC)', '时间(UTC)') : tr('Dimension', '维度'),
+ },
+ {
+ accessorKey: 'pv',
+ header: 'PV',
+ meta: { class: { th: 'text-right', td: 'text-right whitespace-nowrap' } },
+ },
+ {
+ accessorKey: 'uv',
+ header: time ? 'UV' : tr('Daily UV total', '每日 UV 合计'),
+ meta: { class: { th: 'text-right', td: 'text-right whitespace-nowrap' } },
+ },
+]
</script>
<template>
<div class="cf-analytics-report">
@@ -102,35 +118,21 @@ const groups = computed(() => [
/></template>
</ClientOnly>
<div class="cf-analytics-table-wrap">
- <table class="cf-analytics-table">
- <thead>
- <tr>
- <th>{{ tr('Time (UTC)', '时间(UTC)') }}</th>
- <th>PV</th>
- <th>UV</th>
- </tr>
- </thead>
- <tbody>
- <tr
- v-for="row in report.daily"
- :key="row.page?.key ?? row.label"
- >
- <td>{{ row.label }}</td>
- <td>{{ format(row.pv) }}</td>
- <td>{{ format(row.uv) }}</td>
- </tr>
- <tr v-if="!report.daily.length">
- <td colspan="3">
- {{
- tr(
- 'No visits in this date range.',
- '此日期范围内暂无访问记录。',
- )
- }}
- </td>
- </tr>
- </tbody>
- </table>
+ <UTable
+ :data="report.daily"
+ :columns="columns(true)"
+ :ui="{
+ root: 'overflow-visible',
+ td: 'whitespace-normal break-words text-[13px] px-2 py-2.5',
+ th: 'text-[13px] px-2 py-2.5',
+ }"
+ >
+ <template #pv-cell="{ row }">{{ format(row.original.pv) }}</template>
+ <template #uv-cell="{ row }">{{ format(row.original.uv) }}</template>
+ <template #empty>{{
+ tr('No visits in this date range.', '此日期范围内暂无访问记录。')
+ }}</template>
+ </UTable>
</div>
</CfCard>
<div class="cf-analytics-breakdowns">
@@ -144,35 +146,32 @@ const groups = computed(() => [
<small class="cf-field-hint">{{ tr('Top 20', '前 20 项') }}</small>
</h2>
<div class="cf-analytics-table-wrap">
- <table class="cf-analytics-table">
- <thead>
- <tr>
- <th>{{ tr('Dimension', '维度') }}</th>
- <th>PV</th>
- <th>{{ tr('Daily UV total', '每日 UV 合计') }}</th>
- </tr>
- </thead>
- <tbody>
- <tr
- v-for="row in report[key]"
- :key="row.page?.key ?? row.label"
- >
- <td>
- <CfAnalyticsPageLink
- v-if="key === 'pages'"
- :row="row"
- :admin="admin"
- :zh="zh"
- /><template v-else>{{ row.label }}</template>
- </td>
- <td>{{ format(row.pv) }}</td>
- <td>{{ format(row.uv) }}</td>
- </tr>
- <tr v-if="!report[key].length">
- <td colspan="3">{{ tr('No data', '暂无数据') }}</td>
- </tr>
- </tbody>
- </table>
+ <UTable
+ :data="report[key]"
+ :columns="columns()"
+ :get-row-id="(row) => row.page?.key ?? row.label"
+ :ui="{
+ root: 'overflow-visible',
+ td: 'whitespace-normal break-words text-[13px] px-2 py-2.5',
+ th: 'text-[13px] px-2 py-2.5',
+ }"
+ >
+ <template #label-cell="{ row }"
+ ><CfAnalyticsPageLink
+ v-if="key === 'pages'"
+ :row="row.original"
+ :admin="admin"
+ :zh="zh"
+ /><template v-else>{{ row.original.label }}</template></template
+ >
+ <template #pv-cell="{ row }">{{
+ format(row.original.pv)
+ }}</template>
+ <template #uv-cell="{ row }">{{
+ format(row.original.uv)
+ }}</template>
+ <template #empty>{{ tr('No data', '暂无数据') }}</template>
+ </UTable>
</div>
</CfCard>
</div>
@@ -205,25 +204,6 @@ const groups = computed(() => [
margin: 0 -20px -20px;
padding: 0 20px 20px;
}
-.cf-analytics-table {
- width: 100%;
- border-collapse: collapse;
- font-size: 13px;
-}
-.cf-analytics-table th,
-.cf-analytics-table td {
- text-align: left;
- padding: 10px 8px;
- border-bottom: 1px solid var(--ui-border);
-}
-.cf-analytics-table td:first-child {
- overflow-wrap: anywhere;
-}
-.cf-analytics-table th:not(:first-child),
-.cf-analytics-table td:not(:first-child) {
- text-align: right;
- white-space: nowrap;
-}
.cf-traffic-chart-placeholder {
width: 100%;
height: 260px;
diff --git a/packages/saas-ui/app/components/CfAppShell.vue b/packages/saas-ui/app/components/CfAppShell.vue
index de650540..34ab898c 100644
--- a/packages/saas-ui/app/components/CfAppShell.vue
+++ b/packages/saas-ui/app/components/CfAppShell.vue
@@ -1,15 +1,5 @@
<script setup lang="ts">
import { Menu, X } from 'lucide-vue-next'
-import {
- DialogRoot,
- DialogTrigger,
- DialogPortal,
- DialogOverlay,
- DialogContent,
- DialogTitle,
- DialogDescription,
- DialogClose,
-} from 'reka-ui'
// The shell owns presentation and accessibility; consumers supply their own
// navigation, identity and permissions. Admin never imports Cloud's business UI.
@@ -33,37 +23,39 @@ watch(
<div class="cf-shell-brand"><slot name="brand" /></div>
<header class="cf-portal-header">
<div class="cf-shell-location">
- <DialogRoot v-model:open="open">
- <DialogTrigger as-child>
- <CfButton
- class="cf-sidebar-toggle"
- variant="ghost"
- size="icon"
- :aria-label="openLabel"
- ><Menu :size="16"
- /></CfButton>
- </DialogTrigger>
- <DialogPortal>
- <DialogOverlay class="cf-sidebar-overlay" />
- <DialogContent class="cf-sidebar-drawer">
- <DialogTitle class="sr-only">{{ navigationLabel }}</DialogTitle>
- <DialogDescription class="sr-only">{{
- navigationDescription
- }}</DialogDescription>
- <div class="cf-drawer-heading">
- <slot name="brand" /><DialogClose as-child
- ><CfButton
- variant="ghost"
- size="icon"
- :aria-label="closeLabel"
- ><X :size="16" /></CfButton
- ></DialogClose>
- </div>
- <slot name="navigation" />
- <div class="cf-sidebar-bottom"><slot name="footer" /></div>
- </DialogContent>
- </DialogPortal>
- </DialogRoot>
+ <USlideover
+ v-model:open="open"
+ side="left"
+ :close="false"
+ :title="navigationLabel"
+ :description="navigationDescription"
+ :ui="{
+ content: 'w-72',
+ body: 'p-0 flex flex-col',
+ header: 'sr-only',
+ }"
+ >
+ <CfButton
+ class="cf-sidebar-toggle"
+ variant="ghost"
+ size="icon"
+ :aria-label="openLabel"
+ ><Menu :size="16"
+ /></CfButton>
+ <template #body>
+ <div class="cf-drawer-heading">
+ <slot name="brand" /><CfButton
+ variant="ghost"
+ size="icon"
+ :aria-label="closeLabel"
+ @click="open = false"
+ ><X :size="16"
+ /></CfButton>
+ </div>
+ <slot name="navigation" />
+ <div class="cf-sidebar-bottom"><slot name="footer" /></div>
+ </template>
+ </USlideover>
<slot name="location" />
</div>
<div class="cf-header-actions"><slot name="actions" /></div>
diff --git a/packages/saas-ui/app/components/CfBadge.vue b/packages/saas-ui/app/components/CfBadge.vue
index 8f60a497..170672d3 100644
--- a/packages/saas-ui/app/components/CfBadge.vue
+++ b/packages/saas-ui/app/components/CfBadge.vue
@@ -4,9 +4,10 @@ withDefaults(defineProps<{ tone?: 'neutral' | 'success' | 'warning' }>(), {
})
</script>
<template>
- <span
+ <UBadge
+ :color="tone"
+ variant="subtle"
class="cf-badge"
- :class="`cf-badge-${tone}`"
><slot
- /></span>
+ /></UBadge>
</template>
diff --git a/packages/saas-ui/app/components/CfButton.vue b/packages/saas-ui/app/components/CfButton.vue
index 063d2d74..18232c44 100644
--- a/packages/saas-ui/app/components/CfButton.vue
+++ b/packages/saas-ui/app/components/CfButton.vue
@@ -1,71 +1,41 @@
<script setup lang="ts">
import type { Component } from 'vue'
-import { Primitive, type PrimitiveProps } from 'reka-ui'
-import { cva, type VariantProps } from 'class-variance-authority'
-import { cn } from '../utils/cn'
-import { LoaderCircle } from 'lucide-vue-next'
-const variants = cva('cf-button', {
- variants: {
- variant: {
- default: 'cf-button-primary',
- secondary: 'cf-button-secondary',
- soft: 'cf-button-soft',
- ghost: 'cf-button-ghost',
- destructive: 'cf-button-destructive',
- },
- size: {
- default: '',
- sm: 'cf-button-sm',
- lg: 'cf-button-lg',
- icon: 'cf-button-icon',
- },
- },
- defaultVariants: { variant: 'default', size: 'default' },
-})
-type ButtonVariants = VariantProps<typeof variants>
+import type { ButtonProps } from '@nuxt/ui'
const props = withDefaults(
- defineProps<
- PrimitiveProps & {
- variant?: ButtonVariants['variant']
- size?: ButtonVariants['size']
- icon?: Component
- loading?: boolean
- disabled?: boolean
- class?: string
- }
- >(),
- { as: 'button' },
+ defineProps<{
+ variant?: ButtonProps['variant'] | 'default' | 'secondary' | 'destructive'
+ color?: ButtonProps['color']
+ size?: ButtonProps['size'] | 'default' | 'icon'
+ icon?: Component
+ loading?: boolean
+ disabled?: boolean
+ }>(),
+ { variant: 'default', size: 'default' },
)
-function guardDisabled(event: Event) {
- if (props.disabled || props.loading) {
- event.preventDefault()
- event.stopImmediatePropagation()
- }
-}
+const appearance = computed(() => {
+ if (props.variant === 'default') return 'solid'
+ if (props.variant === 'secondary' || props.variant === 'destructive')
+ return 'outline'
+ return props.variant
+})
</script>
<template>
- <Primitive
- :as="as"
- :as-child="asChild"
- :class="cn(variants({ variant, size }), props.class)"
- :disabled="disabled || loading || undefined"
- :aria-busy="loading || undefined"
- :type="as === 'button' && !asChild ? 'button' : undefined"
- :data-disabled="disabled || loading || undefined"
- :aria-disabled="disabled || loading || undefined"
- :tabindex="asChild && (disabled || loading) ? -1 : undefined"
- @click.capture="guardDisabled"
+ <UButton
+ :variant="appearance"
+ :color="color ?? (variant === 'destructive' ? 'error' : 'neutral')"
+ :size="size === 'icon' || size === 'default' ? 'md' : size"
+ :square="size === 'icon'"
+ :loading="loading"
+ :disabled="disabled"
+ :class="['cf-button', size === 'icon' && 'cf-button-icon']"
>
- <LoaderCircle
- v-if="loading && !asChild"
- class="cf-spin"
- :size="16"
- aria-hidden="true"
- /><component
- v-else-if="icon && !asChild"
- :is="icon"
- :size="16"
- aria-hidden="true"
- /><slot />
- </Primitive>
+ <template
+ v-if="icon && !loading"
+ #leading
+ ><component
+ :is="icon"
+ :size="16"
+ aria-hidden="true" /></template
+ ><slot />
+ </UButton>
</template>
diff --git a/packages/saas-ui/app/components/CfCard.vue b/packages/saas-ui/app/components/CfCard.vue
index 588746a5..d6ab84fd 100644
--- a/packages/saas-ui/app/components/CfCard.vue
+++ b/packages/saas-ui/app/components/CfCard.vue
@@ -1,7 +1,7 @@
-<script setup lang="ts">
-import { cn } from '../utils/cn'
-const props = defineProps<{ class?: string }>()
-</script>
<template>
- <div :class="cn('cf-card', props.class)"><slot /></div>
+ <UCard
+ class="cf-card"
+ :ui="{ body: 'contents' }"
+ ><slot
+ /></UCard>
</template>
diff --git a/packages/saas-ui/app/components/CfCheckbox.vue b/packages/saas-ui/app/components/CfCheckbox.vue
new file mode 100644
index 00000000..cde1e556
--- /dev/null
+++ b/packages/saas-ui/app/components/CfCheckbox.vue
@@ -0,0 +1,43 @@
+<script setup lang="ts">
+import { normalizeClass } from 'vue'
+defineOptions({ inheritAttrs: false })
+// Compatibility for existing array-valued fields and native change handlers.
+const props = withDefaults(
+ defineProps<{ checked?: boolean; value?: string | number }>(),
+ { checked: undefined, value: undefined },
+)
+const model = defineModel<boolean | (string | number)[]>()
+const emit = defineEmits<{ change: [event: Event] }>()
+const checkedValue = computed(() =>
+ props.checked !== undefined
+ ? props.checked
+ : Array.isArray(model.value)
+ ? model.value.includes(props.value!)
+ : !!model.value,
+)
+function update(value: boolean | 'indeterminate') {
+ const checked = value === true
+ if (Array.isArray(model.value))
+ model.value = checked
+ ? [...new Set([...model.value, props.value!])]
+ : model.value.filter((item) => item !== props.value)
+ else model.value = checked
+ const event = new Event('change', { bubbles: true })
+ Object.defineProperty(event, 'target', {
+ value: { checked, value: props.value },
+ })
+ emit('change', event)
+}
+</script>
+<template>
+ <UCheckbox
+ v-bind="{
+ ...$attrs,
+ class: normalizeClass($attrs.class)
+ .split(/\s+/)
+ .filter((name) => name !== 'cf-input'),
+ }"
+ :model-value="checkedValue"
+ @update:model-value="update"
+ />
+</template>
diff --git a/packages/saas-ui/app/components/CfInput.vue b/packages/saas-ui/app/components/CfInput.vue
index dfde4018..001a29f7 100644
--- a/packages/saas-ui/app/components/CfInput.vue
+++ b/packages/saas-ui/app/components/CfInput.vue
@@ -1,11 +1,29 @@
<script setup lang="ts">
-import { cn } from '../utils/cn'
-const model = defineModel<string>({ default: '' })
-const props = defineProps<{ class?: string }>()
+defineOptions({ inheritAttrs: false })
+const emit = defineEmits<{ input: [event: Event] }>()
+// Existing validation callbacks must observe the new model, as with native v-model.
+function onInput(event: Event) {
+ void nextTick(() => emit('input', event))
+}
+withDefaults(defineProps<{ value?: string | number | null }>(), {
+ value: undefined,
+})
+const model = defineModel<string | number | null>()
+const input = useTemplateRef<{ inputRef: HTMLInputElement }>('input')
+defineExpose({
+ focus: () => input.value?.inputRef?.focus(),
+ setCustomValidity: (message: string) =>
+ input.value?.inputRef?.setCustomValidity(message),
+ inputRef: computed(() => input.value?.inputRef),
+})
</script>
<template>
- <input
- v-model="model"
- :class="cn('cf-input', props.class)"
+ <UInput
+ ref="input"
+ v-bind="$attrs"
+ :model-value="value !== undefined ? value : model"
+ class="cf-input"
+ @update:model-value="model = $event"
+ @input="onInput"
/>
</template>
diff --git a/packages/saas-ui/app/components/CfProgress.vue b/packages/saas-ui/app/components/CfProgress.vue
index d145a693..3757a82e 100644
--- a/packages/saas-ui/app/components/CfProgress.vue
+++ b/packages/saas-ui/app/components/CfProgress.vue
@@ -1,5 +1,4 @@
<script setup lang="ts">
-import { ProgressRoot, ProgressIndicator } from 'reka-ui'
const props = withDefaults(defineProps<{ value?: number; max?: number }>(), {
value: 0,
max: 100,
@@ -15,16 +14,18 @@ const normalized = computed(() =>
)
</script>
<template>
- <ProgressRoot
- :model-value="normalized"
- :max="maximum"
- class="cf-progress"
+ <div
+ role="progressbar"
+ :aria-valuenow="normalized"
+ :aria-valuemin="0"
+ :aria-valuemax="maximum"
>
- <ProgressIndicator
- class="cf-progress-indicator"
- :style="{
- width: (normalized / maximum) * 100 + '%',
- }"
+ <UProgress
+ :model-value="normalized"
+ :max="maximum"
+ size="xs"
+ color="neutral"
+ aria-hidden="true"
/>
- </ProgressRoot>
+ </div>
</template>
diff --git a/packages/saas-ui/app/components/CfRadioGroup.vue b/packages/saas-ui/app/components/CfRadioGroup.vue
index 366daca3..8773dee5 100644
--- a/packages/saas-ui/app/components/CfRadioGroup.vue
+++ b/packages/saas-ui/app/components/CfRadioGroup.vue
@@ -1,5 +1,4 @@
<script setup lang="ts">
-import { RadioGroupRoot, RadioGroupItem } from 'reka-ui'
defineProps<{
options: { value: string; label: string; disabled?: boolean }[]
label: string
@@ -7,17 +6,10 @@ defineProps<{
const model = defineModel<string>()
</script>
<template>
- <RadioGroupRoot
+ <URadioGroup
v-model="model"
- class="cf-segmented-control"
+ :items="options"
:aria-label="label"
- ><RadioGroupItem
- v-for="option in options"
- :key="option.value"
- :value="option.value"
- :disabled="option.disabled"
- class="cf-segmented-item"
- >{{ option.label }}</RadioGroupItem
- ></RadioGroupRoot
- >
+ orientation="horizontal"
+ />
</template>
diff --git a/packages/saas-ui/app/components/CfSeparator.vue b/packages/saas-ui/app/components/CfSeparator.vue
index 6dbc4364..573679f3 100644
--- a/packages/saas-ui/app/components/CfSeparator.vue
+++ b/packages/saas-ui/app/components/CfSeparator.vue
@@ -1,9 +1 @@
-<script setup lang="ts">
-import { Separator } from 'reka-ui'
-</script>
-<template>
- <Separator
- decorative
- class="cf-separator"
- />
-</template>
+<template><USeparator decorative /></template>
diff --git a/packages/saas-ui/app/components/CfSkeleton.vue b/packages/saas-ui/app/components/CfSkeleton.vue
index ac29ea93..26c50024 100644
--- a/packages/saas-ui/app/components/CfSkeleton.vue
+++ b/packages/saas-ui/app/components/CfSkeleton.vue
@@ -1,7 +1,3 @@
<template>
- <span
- aria-hidden="true"
- class="cf-skeleton"
- ><slot>&nbsp;</slot></span
- >
+ <USkeleton aria-hidden="true"><slot>&nbsp;</slot></USkeleton>
</template>
diff --git a/packages/saas-ui/app/components/CfTable.vue b/packages/saas-ui/app/components/CfTable.vue
index cd2a38a0..e247cc31 100644
--- a/packages/saas-ui/app/components/CfTable.vue
+++ b/packages/saas-ui/app/components/CfTable.vue
@@ -42,7 +42,7 @@ const renderedColumns = computed(() =>
:data="data"
:columns="renderedColumns"
:ui="{
- root: 'cf-data-table min-w-0 rounded-lg border border-[var(--border)] bg-[var(--card)]',
+ root: 'cf-data-table min-w-0 rounded-lg bg-[var(--card)]',
base: 'cf-table table-auto border-collapse',
tr: 'hover:bg-[var(--cf-table-hover)] transition-colors',
th: 'bg-[var(--secondary)] text-[var(--muted-foreground)] text-xs font-medium whitespace-nowrap px-4 py-3',
diff --git a/packages/saas-ui/app/components/CfTextarea.vue b/packages/saas-ui/app/components/CfTextarea.vue
new file mode 100644
index 00000000..a27014b6
--- /dev/null
+++ b/packages/saas-ui/app/components/CfTextarea.vue
@@ -0,0 +1,21 @@
+<script setup lang="ts">
+defineOptions({ inheritAttrs: false })
+const emit = defineEmits<{ input: [event: Event] }>()
+// Existing validation callbacks must observe the new model, as with native v-model.
+function onInput(event: Event) {
+ void nextTick(() => emit('input', event))
+}
+withDefaults(defineProps<{ value?: string | number | null }>(), {
+ value: undefined,
+})
+const model = defineModel<string | number | null>()
+</script>
+<template>
+ <UTextarea
+ v-bind="$attrs"
+ :model-value="value !== undefined ? value : model"
+ class="cf-input w-full"
+ @update:model-value="model = $event"
+ @input="onInput"
+ />
+</template>
diff --git a/packages/saas-ui/app/utils/cn.ts b/packages/saas-ui/app/utils/cn.ts
deleted file mode 100644
index 631ec27a..00000000
--- a/packages/saas-ui/app/utils/cn.ts
+++ /dev/null
@@ -1,6 +0,0 @@
-import { clsx, type ClassValue } from 'clsx'
-import { twMerge } from 'tailwind-merge'
-/** Merge shadcn utility classes while allowing local overrides. */
-export function cn(...inputs: ClassValue[]) {
- return twMerge(clsx(inputs))
-}
diff --git a/packages/saas-ui/package.json b/packages/saas-ui/package.json
index 92f0015e..fb158c01 100644
--- a/packages/saas-ui/package.json
+++ b/packages/saas-ui/package.json
@@ -9,13 +9,9 @@
},
"dependencies": {
"@internationalized/date": "3.12.0",
- "class-variance-authority": "^0.7.1",
- "clsx": "^2.1.1",
"echarts": "6.1.0",
"lucide-vue-next": "^1.0.0",
"markdown-it": "^14.3.3",
- "reka-ui": "^2.11.0",
- "tailwind-merge": "^3.7.0",
"vue": "3.5.43",
"vue-echarts": "8.3.2"
},
diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml
index 5a931336..ba6687dc 100644
--- a/pnpm-lock.yaml
+++ b/pnpm-lock.yaml
@@ -921,12 +921,6 @@ importers:
'@nuxt/ui':
specifier: ^4.11.3
version: 4.11.3(92e70d591260dd1b8304e46d7e1fe6ea)
- class-variance-authority:
- specifier: ^0.7.1
- version: 0.7.1
- clsx:
- specifier: ^2.1.1
- version: 2.1.1
echarts:
specifier: 6.1.0
version: 6.1.0
@@ -936,12 +930,6 @@ importers:
markdown-it:
specifier: ^14.3.3
version: 14.3.3
- reka-ui:
- specifier: ^2.11.0
- version: 2.11.0([email protected])
- tailwind-merge:
- specifier: ^3.7.0
- version: 3.7.0
vue:
specifier: 3.5.43
version: 3.5.43([email protected])
@@ -6067,9 +6055,6 @@ packages:
resolution: {integrity: sha512-+6vJA3L98yv+IdfKGZHBNiGW5KHn22e/JwID0Strsz8h4S/csAu/OuICwxrg44k5MRiZHWIo8XXuJgQTriRP4w==}
- resolution: {integrity: sha512-Ka+9Trutv7G8M6WT6SeiRWz792K5qEqIGEGzXKhAE6xOWAY6pPH8U+9IY3oCMv6kqTmLsv7Xh/2w2RigkePMsg==}
-
resolution: {integrity: sha512-ROn/mdV2pR8WFdpJjFDCSouLRg9myf95xacO1iy8G/AVO/x5y124pjF3EaoWrTBRWC3vh0DPqa/MhKyx3mMeKg==}
engines: {node: '>=22.1.0'}
@@ -6084,10 +6069,6 @@ packages:
resolution: {integrity: sha512-ROoL94jJH2dUVML2Y/5PEDNaSHgeOdSDicUyS7izcF63G6sTc/FTjLub4b8Il9S8S0beOfYt0TaA5qvFK+w0wA==}
- resolution: {integrity: sha512-eYm0QWBtUrBWZWG0d386OGAw16Z995PiOVo2B7bjWSbHedGl5e0ZWaq65kOGgUSNesEIDkB9ISbTg/JK9dhCZA==}
- engines: {node: '>=6'}
-
resolution: {integrity: sha512-rwHwUfXL40Chm1r08yrhU3qpUvdVlgkKNeyeGPOxnW8/SyVDvgRaed/Uz54AqWNaTCAThlj6QAs3TZcKI0xDEw==}
engines: {node: '>=0.10.0'}
@@ -16611,10 +16592,6 @@ snapshots:
- dependencies:
- clsx: 2.1.1
-
@@ -16633,8 +16610,6 @@ snapshots:
dependencies:
mimic-response: 1.0.1
-
diff --git a/scripts/check-saas-ui-boundaries.mjs b/scripts/check-saas-ui-boundaries.mjs
index d4ccc109..4f48a2a3 100644
--- a/scripts/check-saas-ui-boundaries.mjs
+++ b/scripts/check-saas-ui-boundaries.mjs
@@ -18,9 +18,31 @@ async function sources(directory) {
)
).flat()
}
+function checkNuxtFoundation(file, source) {
+ if (!file.endsWith('.vue')) return
+ if (/from\s*['"](?:reka-ui|class-variance-authority)['"]/.test(source))
+ failures.push(
+ `${file}: use Nuxt UI components rather than a separate primitive system`,
+ )
+ for (const match of source.matchAll(
+ /<(input|textarea|button|table)\b[^>]*>/g,
+ )) {
+ // The upload transport is hidden; its visible trigger and all form controls use Nuxt UI.
+ if (
+ match[1] === 'input' &&
+ /type="file"/.test(match[0]) &&
+ /class="sr-only"/.test(match[0])
+ )
+ continue
+ failures.push(
+ `${file}: native ${match[1]} bypasses the shared Nuxt UI theme`,
+ )
+ }
+}
const failures = []
for (const file of await sources(root)) {
const source = await readFile(file, 'utf8')
+ checkNuxtFoundation(file, source)
if (file.endsWith('.css')) continue // Tailwind @source deliberately scans consumers.
for (const match of source.matchAll(
/(?:from\s*|import\s*(?:\(\s*)?)['"]([^'"]+)['"]/g,
@@ -46,6 +68,7 @@ if (!cloud.includes('../../packages/saas-ui'))
failures.push('Cloud must extend the SaaS UI layer')
for (const file of await sources(resolve('apps/cloud/app'))) {
const source = await readFile(file, 'utf8')
+ checkNuxtFoundation(file, source)
if (
/<Cloud(?:Button|Input|Select|Card|Badge|Progress|Alert|Skeleton|Separator|RadioGroup|StatCard|PageHeader)\b/.test(
source,
@@ -56,6 +79,8 @@ for (const file of await sources(resolve('apps/cloud/app'))) {
// When Admin is implemented, opting into the same foundation is mandatory.
try {
const admin = await readFile('apps/admin/nuxt.config.ts', 'utf8')
+ for (const file of await sources(resolve('apps/admin/app')))
+ checkNuxtFoundation(file, await readFile(file, 'utf8'))
if (!/packages\/saas-ui|@chronoframe\/saas-ui/.test(admin))
failures.push('Admin must extend the SaaS UI layer')
} catch (error) {
diff --git a/tests/saas-ui.test.ts b/tests/saas-ui.test.ts
index 6460eb58..d0aade7e 100644
--- a/tests/saas-ui.test.ts
+++ b/tests/saas-ui.test.ts
@@ -8,7 +8,8 @@ import ts from 'typescript'
const require = createRequire(resolve('packages/saas-ui/package.json'))
const { parse, compileScript } = require('vue/compiler-sfc')
-const { createSSRApp, h, computed } = require('vue')
+const vue = require('vue')
+const { createSSRApp, h, computed, defineComponent } = vue
const { renderToString } = require('vue/server-renderer')
function evaluate(code: string) {
const exports: Record<string, any> = {}
@@ -21,11 +22,10 @@ function evaluate(code: string) {
}).outputText,
{
exports,
+ ...vue,
+ Event,
computed,
- require: (name: string) =>
- name === '../utils/cn'
- ? evaluate(readFileSync('packages/saas-ui/app/utils/cn.ts', 'utf8'))
- : require(name),
+ require,
},
)
return exports
@@ -44,49 +44,144 @@ function component(name: string) {
}).content,
).default
}
-const render = (name: string, props = {}, children?: () => any) =>
- renderToString(
- createSSRApp({ render: () => h(component(name), props, children) }),
+// Probe the adapter boundary; real Nuxt UI interactions are also exercised in the browser.
+async function render(
+ name: string,
+ props: Record<string, any> = {},
+ target = 'UButton',
+) {
+ let received: Record<string, any> = {}
+ const app = createSSRApp({ render: () => h(component(name), props) })
+ app.component(
+ target,
+ defineComponent({
+ inheritAttrs: false,
+ props: ['modelValue', 'max'],
+ setup(_props: unknown, { attrs }: any) {
+ received = { ...attrs, ...(_props as object) }
+ return () => h('span')
+ },
+ }),
)
-
-test('Shared buttons preserve form semantics and a single pending polymorphic link', async () => {
- assert.match(await render('CfButton'), /type="button"/)
- assert.match(await render('CfButton', { type: 'submit' }), /type="submit"/)
- const pending = await render(
- 'CfButton',
- { asChild: true, loading: true },
- () => h('a', { href: '/sites' }, 'Sites'),
+ const html = await renderToString(app)
+ return { html, received }
+}
+test('button adapters preserve submit, pending and disabled navigation props through Nuxt UI', async () => {
+ const submit = await render('CfButton', { type: 'submit' })
+ assert.equal(submit.received.type, 'submit')
+ assert.equal(submit.received.variant, 'solid')
+ const pending = await render('CfButton', {
+ to: '/sites',
+ loading: true,
+ disabled: true,
+ variant: 'secondary',
+ })
+ assert.equal(pending.received.to, '/sites')
+ assert.equal(pending.received.loading, true)
+ assert.equal(pending.received.disabled, true)
+ assert.equal(pending.received.variant, 'outline')
+ assert.equal(pending.received.color, 'neutral')
+})
+test('input adapters forward controlled values, validation and labels to Nuxt UI', async () => {
+ const { received } = await render(
+ 'CfInput',
+ {
+ id: 'gallery-name',
+ value: 'Local Gallery',
+ required: true,
+ maxlength: 80,
+ 'aria-invalid': true,
+ },
+ 'UInput',
+ )
+ assert.equal(received.id, 'gallery-name')
+ assert.equal(received.modelValue, 'Local Gallery')
+ assert.equal(received.required, true)
+ assert.equal(received.maxlength, 80)
+ assert.equal(received['aria-invalid'], true)
+})
+test('progress adapters clamp invalid usage and expose exactly one labeled progressbar', async () => {
+ const over = await render(
+ 'CfProgress',
+ { value: 125, 'aria-label': 'Sites' },
+ 'UProgress',
)
- assert.equal(pending.match(/<([a-z][a-z0-9]*)\b/i)?.[1], 'a')
- assert.match(pending, /aria-busy="true"/)
- assert.match(pending, /aria-disabled="true"/)
- assert.match(pending, /tabindex="-1"/)
- assert.match(pending, /href="\/sites"/)
- assert.doesNotMatch(pending, /<button|<svg/)
+ assert.equal(over.received.modelValue, 100)
+ assert.match(over.html, /aria-valuenow="100"/)
+ assert.match(over.html, /aria-label="Sites"/)
+ const invalid = await render(
+ 'CfProgress',
+ { value: Number.NaN, max: 0 },
+ 'UProgress',
+ )
+ assert.equal(invalid.received.modelValue, 0)
+ assert.equal(invalid.received.max, 100)
+})
+test('checkbox adapters retain array membership and native change handlers without mutating the input', async () => {
+ const original = ['a']
+ let updated: unknown
+ let event: Event | undefined
+ const { received } = await render(
+ 'CfCheckbox',
+ {
+ modelValue: original,
+ value: 'b',
+ 'onUpdate:modelValue': (value: unknown) => (updated = value),
+ onChange: (value: Event) => (event = value),
+ },
+ 'UCheckbox',
+ )
+ assert.equal(received.modelValue, false)
+ received['onUpdate:modelValue'](true)
+ assert.deepEqual(Array.from(updated as string[]), ['a', 'b'])
+ assert.deepEqual(original, ['a'])
+ assert.equal((event?.target as HTMLInputElement)?.checked, true)
})
-test('Shared native input forwards labels, validation and required form attributes', async () => {
- const html = await render('CfInput', {
- id: 'gallery-name',
- modelValue: 'Local Gallery',
- required: true,
- maxlength: 80,
- 'aria-invalid': true,
+
+test('resolved home paths display a localized home label and retain independent site links', async () => {
+ const row = {
+ label: '/',
+ page: {
+ site: { title: 'Gallery', href: 'https://gallery.example/' },
+ segments: [],
+ },
+ }
+ const home = await render('CfAnalyticsPageLink', { row, zh: true })
+ assert.match(home.html, /首页/)
+ assert.ok(home.html.includes('href="https://gallery.example/"'))
+ const admin = await render('CfAnalyticsPageLink', {
+ row,
+ admin: true,
+ zh: true,
})
- for (const attribute of [
- 'id="gallery-name"',
- 'value="Local Gallery"',
- 'required',
- 'maxlength="80"',
- 'aria-invalid="true"',
- ])
- assert.ok(html.includes(attribute), attribute)
+ assert.match(admin.html, /Gallery/)
+ assert.match(admin.html, /首页/)
+ assert.equal((admin.html.match(/<a /g) ?? []).length, 2)
})
-test('Shared progress clamps invalid and over-limit usage while retaining accessible labels', async () => {
- const over = await render('CfProgress', { value: 125, 'aria-label': 'Sites' })
- assert.match(over, /aria-valuenow="100"/)
- assert.match(over, /aria-label="Sites"/)
- assert.match(over, /width:100%/)
- const unknown = await render('CfProgress', { value: Number.NaN, max: 0 })
- assert.match(unknown, /aria-valuenow="0"/)
- assert.match(unknown, /aria-valuemax="100"/)
+
+test('input validation callbacks observe the updated model for fields and textareas', async () => {
+ for (const [componentName, target] of [
+ ['CfInput', 'UInput'],
+ ['CfTextarea', 'UTextarea'],
+ ]) {
+ let model = 'before',
+ observed = ''
+ const { received } = await render(
+ componentName,
+ {
+ modelValue: model,
+ 'onUpdate:modelValue': (value: string) => {
+ model = value
+ },
+ onInput: () => {
+ observed = model
+ },
+ },
+ target,
+ )
+ received.onInput(new Event('input'))
+ received['onUpdate:modelValue']('after')
+ await vue.nextTick()
+ assert.equal(observed, 'after')
+ }
})