feat(web/default): unified UI overhaul — Base UI migration, theme presets, rankings dashboard, and table toolbar refactor (#4633)
* 🎨 feat(web/default): add shadcn-style theme presets, radius prefs, and fix selection badges Integrate the qn-platform–style OKLCH color system into the default frontend while keeping the existing blue-tinted dark tokens for the default theme. Add [data-theme-preset] palettes for seven named presets plus the default zinc-like scale, define [data-theme-radius] overrides so user radius beats preset --radius, and align the Tailwind @custom-variant dark helper with .dark usage. Introduce ThemeCustomizationProvider to own preset and radius state, persist choices in cookies (theme-preset, theme-radius), and sync data-theme-preset / data-theme-radius on <html>. Wrap the tree in main.tsx. Extend ConfigDrawer with theme preset swatches (scoped data-theme-preset) and radius previews wired to context; refactor swatch/card markup so selected CircleCheck badges sit outside clipped rows (remove outer overflow-hidden that hid the centered checkmark). Add i18n keys for preset names, radius, and accessibility labels across en, zh, fr, ja, ru, vi. * 🎨 fix(web): align segmented controls with theme radius tokens - Replace hard-coded inner pill radii (rounded-[5px]) on dashboard chart toolbars with radius-md so the active state follows --radius when users change Radius in Theme Settings. - Use nested radii consistent with TabsList/TabsTrigger: outer rounded-lg (var(--radius)) and inner rounded-md (calc(var(--radius) - 2px)) so the track and active thumb stay concentric at small scales (e.g. 0.3rem) instead of a squared “focus” block inside a rounded shell. - Apply the same pattern to pricing SegmentedControl and the segmented groups in consumption-distribution-chart, model-charts, and user-charts. Verified: bun run typecheck (web/default) * ✨ feat(pricing): enrich model details with uptime sparkline and API documentation Add a compact 30-day uptime sparkline (OpenRouter-style bars + aggregate %) with per-day tooltips, surface it in a status row under quick stats and in the per-group performance table, and extend mock data so uptime series are stable and optionally scoped by group. Introduce an API tab with Shiki-highlighted code samples (cURL, Python, TypeScript, JavaScript), endpoint-type switching, authentication guidance, a supported-parameters table, and mock per-group RPM/TPM/RPD limits. Infer vendor, tokenizer, license, and data-retention hints for a provider & data privacy card on the Overview tab (capabilities/modalities stay with model identity; rate limits stay with the API tab). Update i18n for all new user-facing strings across en, zh, fr, ja, ru, and vi. * 🏆 feat(rankings): add comprehensive rankings dashboard Add a mock-data powered rankings experience with period tabs, model, app, and vendor leaderboards, market share and history charts, movers, new releases, and per-category sections while backend analytics are pending. Link ranked models to pricing details and ranked vendors to filtered pricing results, and include localized copy for all supported frontend locales. * fix(theme): correct theme preset selection state - update Base UI Radio selectors to use data-checked/data-unchecked states. - fix unchecked theme options still showing selected indicators. - isolate the default theme preview tokens to prevent preset changes from leaking into it. * fix(setup): correct usage mode radio state - use Base UI data-checked/data-unchecked states for RadioGroup styling. - hide radio indicators when options are unchecked to avoid setup page display issues. - drive usage mode card and icon selection styles from Base UI state. * fix(auth): submit sign-in and sign-up forms * 🎨 refactor: Align default theme with shadcn Base Nova and prune legacy customization Migrate shadcn UI to Base UI primitives via CLI (`base-nova` / `components.json`) and reinstall full component registry with `--overwrite`, including Hugeicons-backed widgets and newly added registry components. - Remove custom multi-preset/theme-radius system (`ThemeCustomizationProvider`, cookies, preset UI from config drawer); rely on official semantic CSS tokens + light/dark only. - Replace `theme.css` with shadcn’s documented neutral `:root`/`.dark` palette and `@theme inline` mappings (plus skeleton token vars for existing shimmer usage). - Update global styles for Base UI: collapsible animation uses `--collapsible-panel-height`; clarify scroll-lock override comment. Application compatibility: - Keep minimal shims where app code diverged from official APIs (popover collision props, combobox legacy `options` callers, Spinner prop typing). - Switch interactive styling from Radix-era `data-state` / `--radix-*` selectors to Base UI semantics (`data-open`, `data-popup-open`, `data-panel-open`, `--anchor-width`, etc.) Tooling / docs / build: - Rename Rsbuild vendor chunk grouping to `@base-ui` + transitive `@radix-ui`. - Refresh AGENTS.md / CLAUDE.md / classic→default sync skill for Base UI stack. - Bump `package.json` / lockfile for shadcn-postinstall deps (Hugeicons, chart stack, themes, etc.) Verified: `bun run typecheck` passes. Note: `bun run lint` still reports pre-existing hooks rule violations elsewhere; not addressed in this change. * 🎨 chore(web/default): unify table toolbar, relocate usage stats, refine filters - Refactor DataTableToolbar to a single wrapping flex row with a right-aligned action cluster (Reset / Search / View / Expand) for a cleaner Ant Design Pro–style filter bar; remove the dedicated stats row and the toolbar `stats` prop. - Move Common Logs summary badges (Usage / RPM / TPM) and the sensitive- data visibility toggle into the page header via CommonLogsHeaderActions and SectionPageLayout.Actions so the toolbar stays focused on filters. - Slim CommonLogsFilterBar props (no stats / preActions eye control). - Improve CompactDateTimeRangePicker: show minute-precision labels on the trigger (seconds omitted; aligns with datetime-local inputs); widen the trigger on sm+ breakpoints so the full range is visible without truncation; apply the same width in task logs filters. - Simplify DataTableViewOptions: text-only “View” trigger, no sliders icon. - Earlier layout tweak: extra top padding on SectionPageLayout scroll content so control focus rings are not clipped by overflow. * feat(web/default): Base UI migration and component foundation Migrate from Radix UI to Base UI, rewrite core UI primitives, update dependencies (recharts, date-fns, next-themes), add shadcn agent skill documentation, and refresh AI element components. This is the foundational work from the v2/localmain lineage that was not covered by the individual feature commits above. --------- Co-authored-by: t0ng7u <dev@aiass.cc> Co-authored-by: QuentinHsu <xuquentinyang@gmail.com>
This commit is contained in:
co-authored by
t0ng7u
QuentinHsu
parent
dac55f0fde
commit
8b2b03d276
+346
-75
@@ -1,6 +1,7 @@
|
||||
import { type SVGProps } from 'react'
|
||||
import { Root as Radio, Item } from '@radix-ui/react-radio-group'
|
||||
import { CircleCheck, RotateCcw, Palette } from 'lucide-react'
|
||||
import { Radio as RadioPrimitive } from '@base-ui/react/radio'
|
||||
import { RadioGroup as Radio } from '@base-ui/react/radio-group'
|
||||
import { CircleCheck, Palette, RotateCcw } from 'lucide-react'
|
||||
import { useTranslation } from 'react-i18next'
|
||||
import { IconDir } from '@/assets/custom/icon-dir'
|
||||
import { IconLayoutCompact } from '@/assets/custom/icon-layout-compact'
|
||||
@@ -12,9 +13,17 @@ import { IconSidebarSidebar } from '@/assets/custom/icon-sidebar-sidebar'
|
||||
import { IconThemeDark } from '@/assets/custom/icon-theme-dark'
|
||||
import { IconThemeLight } from '@/assets/custom/icon-theme-light'
|
||||
import { IconThemeSystem } from '@/assets/custom/icon-theme-system'
|
||||
import {
|
||||
type ContentLayout,
|
||||
THEME_PRESETS,
|
||||
type ThemePreset,
|
||||
type ThemeRadius,
|
||||
type ThemeScale,
|
||||
} from '@/lib/theme-customization'
|
||||
import { cn } from '@/lib/utils'
|
||||
import { useDirection } from '@/context/direction-provider'
|
||||
import { type Collapsible, useLayout } from '@/context/layout-provider'
|
||||
import { useThemeCustomization } from '@/context/theme-customization-provider'
|
||||
import { useTheme } from '@/context/theme-provider'
|
||||
import { Button } from '@/components/ui/button'
|
||||
import {
|
||||
@@ -28,32 +37,38 @@ import {
|
||||
} from '@/components/ui/sheet'
|
||||
import { useSidebar } from './ui/sidebar'
|
||||
|
||||
const Item = RadioPrimitive.Root
|
||||
|
||||
export function ConfigDrawer() {
|
||||
const { t } = useTranslation()
|
||||
const { setOpen } = useSidebar()
|
||||
const { resetDir } = useDirection()
|
||||
const { resetTheme } = useTheme()
|
||||
const { resetLayout } = useLayout()
|
||||
const { resetCustomization } = useThemeCustomization()
|
||||
|
||||
const handleReset = () => {
|
||||
setOpen(true)
|
||||
resetDir()
|
||||
resetTheme()
|
||||
resetLayout()
|
||||
resetCustomization()
|
||||
}
|
||||
|
||||
return (
|
||||
<Sheet>
|
||||
<SheetTrigger asChild>
|
||||
<Button
|
||||
size='icon'
|
||||
variant='ghost'
|
||||
aria-label={t('Open theme settings')}
|
||||
aria-describedby='config-drawer-description'
|
||||
className='rounded-full max-md:hidden'
|
||||
>
|
||||
<Palette className='size-[1.2rem]' aria-hidden='true' />
|
||||
</Button>
|
||||
<SheetTrigger
|
||||
render={
|
||||
<Button
|
||||
size='icon'
|
||||
variant='ghost'
|
||||
aria-label={t('Open theme settings')}
|
||||
aria-describedby='config-drawer-description'
|
||||
className='rounded-full max-md:hidden'
|
||||
/>
|
||||
}
|
||||
>
|
||||
<Palette className='size-[1.2rem]' aria-hidden='true' />
|
||||
</SheetTrigger>
|
||||
<SheetContent className='flex w-full flex-col sm:max-w-md'>
|
||||
<SheetHeader className='pb-0 text-start'>
|
||||
@@ -64,8 +79,12 @@ export function ConfigDrawer() {
|
||||
</SheetHeader>
|
||||
<div className='space-y-6 overflow-y-auto px-4'>
|
||||
<ThemeConfig />
|
||||
<PresetConfig />
|
||||
<RadiusConfig />
|
||||
<ScaleConfig />
|
||||
<SidebarConfig />
|
||||
<LayoutConfig />
|
||||
<ContentLayoutConfig />
|
||||
<DirConfig />
|
||||
</div>
|
||||
<SheetFooter className='gap-2'>
|
||||
@@ -82,12 +101,7 @@ export function ConfigDrawer() {
|
||||
)
|
||||
}
|
||||
|
||||
function SectionTitle({
|
||||
title,
|
||||
showReset = false,
|
||||
onReset,
|
||||
className,
|
||||
}: {
|
||||
function SectionTitle(props: {
|
||||
title: string
|
||||
showReset?: boolean
|
||||
onReset?: () => void
|
||||
@@ -97,16 +111,16 @@ function SectionTitle({
|
||||
<div
|
||||
className={cn(
|
||||
'text-muted-foreground mb-2 flex items-center gap-2 text-sm font-semibold',
|
||||
className
|
||||
props.className
|
||||
)}
|
||||
>
|
||||
{title}
|
||||
{showReset && onReset && (
|
||||
{props.title}
|
||||
{props.showReset && props.onReset && (
|
||||
<Button
|
||||
size='icon'
|
||||
variant='secondary'
|
||||
className='size-4 rounded-full'
|
||||
onClick={onReset}
|
||||
onClick={props.onReset}
|
||||
aria-label='Reset'
|
||||
>
|
||||
<RotateCcw className='size-3' aria-hidden='true' />
|
||||
@@ -116,10 +130,7 @@ function SectionTitle({
|
||||
)
|
||||
}
|
||||
|
||||
function RadioGroupItem({
|
||||
item,
|
||||
isTheme = false,
|
||||
}: {
|
||||
function RadioGroupItem(props: {
|
||||
item: {
|
||||
value: string
|
||||
label: string
|
||||
@@ -127,45 +138,46 @@ function RadioGroupItem({
|
||||
}
|
||||
isTheme?: boolean
|
||||
}) {
|
||||
const isTheme = props.isTheme ?? false
|
||||
return (
|
||||
<Item
|
||||
value={item.value}
|
||||
value={props.item.value}
|
||||
className={cn('group outline-none', 'transition duration-200 ease-in')}
|
||||
aria-label={`Select ${item.label.toLowerCase()}`}
|
||||
aria-describedby={`${item.value}-description`}
|
||||
aria-label={`Select ${props.item.label.toLowerCase()}`}
|
||||
aria-describedby={`${props.item.value}-description`}
|
||||
>
|
||||
<div
|
||||
className={cn(
|
||||
'ring-border relative rounded-[6px] ring-[1px]',
|
||||
'group-data-[state=checked]:ring-primary group-data-[state=checked]:shadow-2xl',
|
||||
'group-data-checked:ring-primary group-data-checked:shadow-2xl',
|
||||
'group-focus-visible:ring-2'
|
||||
)}
|
||||
role='img'
|
||||
aria-hidden='false'
|
||||
aria-label={`${item.label} option preview`}
|
||||
aria-label={`${props.item.label} option preview`}
|
||||
>
|
||||
<CircleCheck
|
||||
className={cn(
|
||||
'fill-primary size-6 stroke-white',
|
||||
'group-data-[state=unchecked]:hidden',
|
||||
'group-data-unchecked:hidden',
|
||||
'absolute top-0 right-0 translate-x-1/2 -translate-y-1/2'
|
||||
)}
|
||||
aria-hidden='true'
|
||||
/>
|
||||
<item.icon
|
||||
<props.item.icon
|
||||
className={cn(
|
||||
!isTheme &&
|
||||
'stroke-primary fill-primary group-data-[state=unchecked]:stroke-muted-foreground group-data-[state=unchecked]:fill-muted-foreground'
|
||||
'stroke-primary fill-primary group-data-unchecked:stroke-muted-foreground group-data-unchecked:fill-muted-foreground'
|
||||
)}
|
||||
aria-hidden='true'
|
||||
/>
|
||||
</div>
|
||||
<div
|
||||
className='mt-1 text-xs'
|
||||
id={`${item.value}-description`}
|
||||
id={`${props.item.value}-description`}
|
||||
aria-live='polite'
|
||||
>
|
||||
{item.label}
|
||||
{props.item.label}
|
||||
</div>
|
||||
</Item>
|
||||
)
|
||||
@@ -189,21 +201,9 @@ function ThemeConfig() {
|
||||
aria-describedby='theme-description'
|
||||
>
|
||||
{[
|
||||
{
|
||||
value: 'system',
|
||||
label: 'System',
|
||||
icon: IconThemeSystem,
|
||||
},
|
||||
{
|
||||
value: 'light',
|
||||
label: 'Light',
|
||||
icon: IconThemeLight,
|
||||
},
|
||||
{
|
||||
value: 'dark',
|
||||
label: 'Dark',
|
||||
icon: IconThemeDark,
|
||||
},
|
||||
{ value: 'system', label: t('System'), icon: IconThemeSystem },
|
||||
{ value: 'light', label: t('Light'), icon: IconThemeLight },
|
||||
{ value: 'dark', label: t('Dark'), icon: IconThemeDark },
|
||||
].map((item) => (
|
||||
<RadioGroupItem key={item.value} item={item} isTheme />
|
||||
))}
|
||||
@@ -215,6 +215,219 @@ function ThemeConfig() {
|
||||
)
|
||||
}
|
||||
|
||||
function PresetConfig() {
|
||||
const { t } = useTranslation()
|
||||
const { defaults, customization, setPreset } = useThemeCustomization()
|
||||
return (
|
||||
<div>
|
||||
<SectionTitle
|
||||
title={t('Color preset')}
|
||||
showReset={customization.preset !== defaults.preset}
|
||||
onReset={() => setPreset(defaults.preset)}
|
||||
/>
|
||||
<Radio
|
||||
value={customization.preset}
|
||||
onValueChange={(v) => setPreset(v as ThemePreset)}
|
||||
className='grid w-full grid-cols-4 gap-3'
|
||||
aria-label={t('Select color preset')}
|
||||
>
|
||||
{THEME_PRESETS.map((preset) => (
|
||||
<Item
|
||||
key={preset.value}
|
||||
value={preset.value}
|
||||
className='group flex flex-col items-stretch outline-none'
|
||||
aria-label={t(`preset.${preset.value}`)}
|
||||
>
|
||||
<div
|
||||
className={cn(
|
||||
'ring-border relative h-12 rounded-md ring-[1px] transition',
|
||||
'group-data-checked:ring-primary group-data-checked:shadow-md',
|
||||
'group-focus-visible:ring-2',
|
||||
'group-hover:ring-primary/60'
|
||||
)}
|
||||
>
|
||||
<div
|
||||
aria-hidden='true'
|
||||
className='absolute inset-0 rounded-md'
|
||||
style={
|
||||
preset.value === 'default'
|
||||
? {
|
||||
background:
|
||||
'linear-gradient(135deg, var(--background) 0%, var(--muted) 50%, var(--foreground) 100%)',
|
||||
}
|
||||
: {
|
||||
background: `linear-gradient(135deg, ${preset.swatches[0]} 0%, ${preset.swatches[1] ?? preset.swatches[0]} 100%)`,
|
||||
}
|
||||
}
|
||||
/>
|
||||
<CircleCheck
|
||||
className={cn(
|
||||
'fill-primary absolute top-0 right-0 z-10 size-5 translate-x-1/2 -translate-y-1/2 stroke-white',
|
||||
'group-data-unchecked:hidden'
|
||||
)}
|
||||
aria-hidden='true'
|
||||
/>
|
||||
</div>
|
||||
<div className='mt-1.5 truncate text-center text-xs'>
|
||||
{t(`preset.${preset.value}`)}
|
||||
</div>
|
||||
</Item>
|
||||
))}
|
||||
</Radio>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
||||
const RADIUS_OPTIONS: {
|
||||
value: ThemeRadius
|
||||
label: string
|
||||
// CSS border-radius value used to render the visual preview corner.
|
||||
preview: string
|
||||
}[] = [
|
||||
{ value: 'default', label: 'Auto', preview: '999px' },
|
||||
{ value: 'none', label: '0', preview: '0' },
|
||||
{ value: 'sm', label: '0.3', preview: '0.3rem' },
|
||||
{ value: 'md', label: '0.5', preview: '0.5rem' },
|
||||
{ value: 'lg', label: '0.75', preview: '0.75rem' },
|
||||
{ value: 'xl', label: '1.0', preview: '1rem' },
|
||||
]
|
||||
|
||||
function RadiusConfig() {
|
||||
const { t } = useTranslation()
|
||||
const { defaults, customization, setRadius } = useThemeCustomization()
|
||||
return (
|
||||
<div>
|
||||
<SectionTitle
|
||||
title={t('Border radius')}
|
||||
showReset={customization.radius !== defaults.radius}
|
||||
onReset={() => setRadius(defaults.radius)}
|
||||
/>
|
||||
<Radio
|
||||
value={customization.radius}
|
||||
onValueChange={(v) => setRadius(v as ThemeRadius)}
|
||||
className='grid w-full grid-cols-6 gap-2'
|
||||
aria-label={t('Select border radius')}
|
||||
>
|
||||
{RADIUS_OPTIONS.map((option) => (
|
||||
<Item
|
||||
key={option.value}
|
||||
value={option.value}
|
||||
className='group flex flex-col items-stretch outline-none'
|
||||
aria-label={
|
||||
option.value === 'default' ? t('System default') : option.label
|
||||
}
|
||||
>
|
||||
<div
|
||||
className={cn(
|
||||
'ring-border relative h-12 rounded-md ring-[1px] transition',
|
||||
'group-data-checked:ring-primary group-data-checked:shadow-md',
|
||||
'group-focus-visible:ring-2',
|
||||
'group-hover:ring-primary/60'
|
||||
)}
|
||||
>
|
||||
<CircleCheck
|
||||
className={cn(
|
||||
'fill-primary absolute top-0 right-0 z-10 size-5 translate-x-1/2 -translate-y-1/2 stroke-white',
|
||||
'group-data-unchecked:hidden'
|
||||
)}
|
||||
aria-hidden='true'
|
||||
/>
|
||||
<span
|
||||
aria-hidden='true'
|
||||
className='border-foreground/70 absolute top-2.5 left-2.5 size-3.5 border-t-[1.5px] border-l-[1.5px]'
|
||||
style={{ borderTopLeftRadius: option.preview }}
|
||||
/>
|
||||
</div>
|
||||
<div className='mt-1.5 text-center text-xs'>{option.label}</div>
|
||||
</Item>
|
||||
))}
|
||||
</Radio>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
||||
/**
|
||||
* Visual preview rows for the density preset. Each row's height represents
|
||||
* the relative line-height density (compact = tight rows, comfortable = wide).
|
||||
*/
|
||||
function ScalePreview(props: { rows: number; rowGap: string }) {
|
||||
return (
|
||||
<div
|
||||
aria-hidden='true'
|
||||
className='absolute inset-2.5 flex flex-col justify-center'
|
||||
style={{ gap: props.rowGap }}
|
||||
>
|
||||
{Array.from({ length: props.rows }).map((_, i) => (
|
||||
<span
|
||||
key={i}
|
||||
className='bg-foreground/60 block h-[2px] rounded-full'
|
||||
style={{ width: `${85 - i * 10}%` }}
|
||||
/>
|
||||
))}
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
||||
function ScaleConfig() {
|
||||
const { t } = useTranslation()
|
||||
const { defaults, customization, setScale } = useThemeCustomization()
|
||||
const scaleOptions: {
|
||||
value: ThemeScale
|
||||
label: string
|
||||
rows: number
|
||||
rowGap: string
|
||||
}[] = [
|
||||
{ value: 'sm', label: t('Compact'), rows: 4, rowGap: '3px' },
|
||||
{ value: 'default', label: t('Default'), rows: 3, rowGap: '6px' },
|
||||
{ value: 'lg', label: t('Comfortable'), rows: 2, rowGap: '10px' },
|
||||
]
|
||||
return (
|
||||
<div>
|
||||
<SectionTitle
|
||||
title={t('Density')}
|
||||
showReset={customization.scale !== defaults.scale}
|
||||
onReset={() => setScale(defaults.scale)}
|
||||
/>
|
||||
<Radio
|
||||
value={customization.scale}
|
||||
onValueChange={(v) => setScale(v as ThemeScale)}
|
||||
className='grid w-full grid-cols-3 gap-4'
|
||||
aria-label={t('Select interface density')}
|
||||
>
|
||||
{scaleOptions.map((option) => (
|
||||
<Item
|
||||
key={option.value}
|
||||
value={option.value}
|
||||
className='group flex flex-col items-stretch outline-none'
|
||||
aria-label={option.label}
|
||||
>
|
||||
<div
|
||||
className={cn(
|
||||
'ring-border relative h-12 rounded-md ring-[1px] transition',
|
||||
'group-data-checked:ring-primary group-data-checked:shadow-md',
|
||||
'group-focus-visible:ring-2',
|
||||
'group-hover:ring-primary/60'
|
||||
)}
|
||||
>
|
||||
<CircleCheck
|
||||
className={cn(
|
||||
'fill-primary absolute top-0 right-0 z-10 size-5 translate-x-1/2 -translate-y-1/2 stroke-white',
|
||||
'group-data-unchecked:hidden'
|
||||
)}
|
||||
aria-hidden='true'
|
||||
/>
|
||||
<ScalePreview rows={option.rows} rowGap={option.rowGap} />
|
||||
</div>
|
||||
<div className='mt-1.5 truncate text-center text-xs'>
|
||||
{option.label}
|
||||
</div>
|
||||
</Item>
|
||||
))}
|
||||
</Radio>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
||||
function SidebarConfig() {
|
||||
const { t } = useTranslation()
|
||||
const { defaultVariant, variant, setVariant } = useLayout()
|
||||
@@ -233,21 +446,13 @@ function SidebarConfig() {
|
||||
aria-describedby='sidebar-description'
|
||||
>
|
||||
{[
|
||||
{
|
||||
value: 'inset',
|
||||
label: 'Inset',
|
||||
icon: IconSidebarInset,
|
||||
},
|
||||
{ value: 'inset', label: t('Inset'), icon: IconSidebarInset },
|
||||
{
|
||||
value: 'floating',
|
||||
label: 'Floating',
|
||||
label: t('Floating'),
|
||||
icon: IconSidebarFloating,
|
||||
},
|
||||
{
|
||||
value: 'sidebar',
|
||||
label: 'Sidebar',
|
||||
icon: IconSidebarSidebar,
|
||||
},
|
||||
{ value: 'sidebar', label: t('Sidebar'), icon: IconSidebarSidebar },
|
||||
].map((item) => (
|
||||
<RadioGroupItem key={item.value} item={item} />
|
||||
))}
|
||||
@@ -291,19 +496,11 @@ function LayoutConfig() {
|
||||
aria-describedby='layout-description'
|
||||
>
|
||||
{[
|
||||
{
|
||||
value: 'default',
|
||||
label: 'Default',
|
||||
icon: IconLayoutDefault,
|
||||
},
|
||||
{
|
||||
value: 'icon',
|
||||
label: 'Compact',
|
||||
icon: IconLayoutCompact,
|
||||
},
|
||||
{ value: 'default', label: t('Default'), icon: IconLayoutDefault },
|
||||
{ value: 'icon', label: t('Compact'), icon: IconLayoutCompact },
|
||||
{
|
||||
value: 'offcanvas',
|
||||
label: 'Full layout',
|
||||
label: t('Full layout'),
|
||||
icon: IconLayoutFull,
|
||||
},
|
||||
].map((item) => (
|
||||
@@ -319,6 +516,80 @@ function LayoutConfig() {
|
||||
)
|
||||
}
|
||||
|
||||
function ContentLayoutConfig() {
|
||||
const { t } = useTranslation()
|
||||
const { defaults, customization, setContentLayout } = useThemeCustomization()
|
||||
return (
|
||||
<div className='max-md:hidden'>
|
||||
<SectionTitle
|
||||
title={t('Content width')}
|
||||
showReset={customization.contentLayout !== defaults.contentLayout}
|
||||
onReset={() => setContentLayout(defaults.contentLayout)}
|
||||
/>
|
||||
<Radio
|
||||
value={customization.contentLayout}
|
||||
onValueChange={(v) => setContentLayout(v as ContentLayout)}
|
||||
className='grid w-full grid-cols-2 gap-4'
|
||||
aria-label={t('Select content width')}
|
||||
>
|
||||
{[
|
||||
{ value: 'full', label: t('Full width') },
|
||||
{ value: 'centered', label: t('Centered') },
|
||||
].map((option) => (
|
||||
<Item
|
||||
key={option.value}
|
||||
value={option.value}
|
||||
className='group flex flex-col items-stretch outline-none'
|
||||
aria-label={option.label}
|
||||
>
|
||||
<div
|
||||
className={cn(
|
||||
'ring-border relative h-12 rounded-md ring-[1px] transition',
|
||||
'group-data-checked:ring-primary group-data-checked:shadow-md',
|
||||
'group-focus-visible:ring-2',
|
||||
'group-hover:ring-primary/60'
|
||||
)}
|
||||
>
|
||||
<CircleCheck
|
||||
className={cn(
|
||||
'fill-primary absolute top-0 right-0 z-10 size-5 translate-x-1/2 -translate-y-1/2 stroke-white',
|
||||
'group-data-unchecked:hidden'
|
||||
)}
|
||||
aria-hidden='true'
|
||||
/>
|
||||
<ContentLayoutPreview centered={option.value === 'centered'} />
|
||||
</div>
|
||||
<div className='mt-1.5 truncate text-center text-xs'>
|
||||
{option.label}
|
||||
</div>
|
||||
</Item>
|
||||
))}
|
||||
</Radio>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
||||
/**
|
||||
* Mini "page" mock used as the visual preview for content-width options.
|
||||
* `full` fills horizontally, `centered` clamps the body to a narrow column.
|
||||
*/
|
||||
function ContentLayoutPreview(props: { centered: boolean }) {
|
||||
return (
|
||||
<div aria-hidden='true' className='absolute inset-2 flex flex-col gap-1.5'>
|
||||
<span className='bg-foreground/40 block h-1.5 w-full rounded-sm' />
|
||||
<div
|
||||
className={cn(
|
||||
'flex flex-1 flex-col gap-1',
|
||||
props.centered ? 'mx-auto w-1/2' : 'w-full'
|
||||
)}
|
||||
>
|
||||
<span className='bg-foreground/60 block h-[2px] w-full rounded-full' />
|
||||
<span className='bg-foreground/60 block h-[2px] w-3/4 rounded-full' />
|
||||
</div>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
||||
function DirConfig() {
|
||||
const { t } = useTranslation()
|
||||
const { defaultDir, dir, setDir } = useDirection()
|
||||
@@ -339,14 +610,14 @@ function DirConfig() {
|
||||
{[
|
||||
{
|
||||
value: 'ltr',
|
||||
label: 'Left to Right',
|
||||
label: t('Left to Right'),
|
||||
icon: (props: SVGProps<SVGSVGElement>) => (
|
||||
<IconDir dir='ltr' {...props} />
|
||||
),
|
||||
},
|
||||
{
|
||||
value: 'rtl',
|
||||
label: 'Right to Left',
|
||||
label: t('Right to Left'),
|
||||
icon: (props: SVGProps<SVGSVGElement>) => (
|
||||
<IconDir dir='rtl' {...props} />
|
||||
),
|
||||
|
||||
Reference in New Issue
Block a user