2026-09-21 16:05:05 +08:00
|
|
|
import type { CSSProperties } from "react"
|
|
|
|
|
import {
|
|
|
|
|
getTheme,
|
|
|
|
|
getThemeCssVariables,
|
|
|
|
|
type ThemeColorConfig,
|
|
|
|
|
type ThemeScheme,
|
|
|
|
|
} from "../theme"
|
|
|
|
|
import { cn } from "@workspace/ui/lib/utils"
|
|
|
|
|
|
|
|
|
|
export interface ThemePreviewProps {
|
|
|
|
|
className?: string
|
|
|
|
|
config: ThemeColorConfig
|
|
|
|
|
scheme: ThemeScheme
|
|
|
|
|
}
|
|
|
|
|
|
2026-09-29 20:58:35 +08:00
|
|
|
export function ThemePreview({ scheme, config, className }: ThemePreviewProps) {
|
2026-09-21 16:05:05 +08:00
|
|
|
const themeVariables = getThemeCssVariables(scheme, config)
|
|
|
|
|
const baseTheme = getTheme(config.baseColor) ?? getTheme("neutral")!
|
|
|
|
|
const style = {
|
|
|
|
|
...Object.fromEntries(
|
|
|
|
|
Object.entries(themeVariables).map(([key, value]) => [`--${key}`, value])
|
|
|
|
|
),
|
2026-09-29 17:08:08 +08:00
|
|
|
"--preview-base": baseTheme.cssVars[scheme].accent,
|
2026-09-21 16:05:05 +08:00
|
|
|
} as CSSProperties
|
|
|
|
|
|
|
|
|
|
return (
|
|
|
|
|
<div className={cn(className, `ui:${scheme}`)} style={style}>
|
|
|
|
|
<div className="isolate h-52 max-w-103.5 rounded-lg bg-sidebar p-3 ring ring-border">
|
|
|
|
|
<div className="flex gap-2.5 [&>div]:bg-foreground/10">
|
|
|
|
|
<div className="size-5 rounded-sm" />
|
|
|
|
|
<div className="ml-auto size-5 rounded-sm" />
|
|
|
|
|
<div className="size-5 rounded-sm" />
|
|
|
|
|
<div className="size-5 rounded-sm" />
|
|
|
|
|
</div>
|
|
|
|
|
<div className="flex gap-3">
|
|
|
|
|
<div className="flex w-16 flex-col gap-1 py-5 [&>div]:bg-foreground/10">
|
|
|
|
|
<div className="h-2.5 w-full rounded-r-full" />
|
2026-09-29 17:08:08 +08:00
|
|
|
<div className="h-2.5 w-full rounded-r-full bg-accent!" />
|
2026-09-21 16:05:05 +08:00
|
|
|
<div className="h-2.5 w-full rounded-r-full" />
|
|
|
|
|
<div className="h-2.5 w-full rounded-r-full" />
|
|
|
|
|
<div className="mt-auto h-2.5 w-full rounded-r-full" />
|
|
|
|
|
</div>
|
|
|
|
|
<div className="flex-1 py-5">
|
2026-09-29 20:58:35 +08:00
|
|
|
<div className="space-y-2.5">
|
2026-09-21 16:05:05 +08:00
|
|
|
<div className="flex h-2.5 items-center gap-2 [&>div]:bg-foreground/10">
|
|
|
|
|
<div className="h-2.5 w-3 rounded-sm" />
|
|
|
|
|
<div className="ml-auto size-2.5 rounded-sm" />
|
|
|
|
|
<div className="h-2.5 w-3.75 rounded-sm" />
|
2026-09-29 17:08:08 +08:00
|
|
|
<div className="h-2.5 w-5 rounded-sm bg-accent!" />
|
2026-09-21 16:05:05 +08:00
|
|
|
</div>
|
|
|
|
|
<div className="grid grid-cols-3 gap-2 [&>div]:rounded-sm [&>div]:bg-foreground/10">
|
2026-09-29 20:58:35 +08:00
|
|
|
<div className="flex h-18 items-end gap-2 p-2">
|
2026-09-21 16:05:05 +08:00
|
|
|
<div className="h-6 w-2 rounded-t-sm bg-(--preview-base)/55" />
|
|
|
|
|
<div className="h-4 w-2 rounded-t-sm bg-(--preview-base)/55" />
|
|
|
|
|
<div className="h-11 w-2 rounded-t-sm bg-(--preview-base)/55" />
|
|
|
|
|
<div className="h-8 w-2 rounded-t-sm bg-(--preview-base)/55" />
|
|
|
|
|
<div className="h-9 w-2 rounded-t-sm bg-(--preview-base)/55" />
|
|
|
|
|
</div>
|
|
|
|
|
<div className="flex h-18 flex-col items-stretch justify-between gap-1 p-2">
|
|
|
|
|
<div className="flex items-center gap-1 opacity-55">
|
|
|
|
|
<div className="h-1 w-1 rounded-xs bg-(--preview-base)/55" />
|
|
|
|
|
<div className="h-1 w-1 rounded-xs bg-(--preview-base)/55" />
|
|
|
|
|
<div className="h-1 w-1 rounded-xs bg-(--preview-base)/55" />
|
|
|
|
|
<div className="ml-auto h-1 w-6 rounded-xs bg-(--preview-base)/55" />
|
|
|
|
|
<div className="h-1 w-3 rounded-xs bg-(--preview-base)/55" />
|
|
|
|
|
</div>
|
|
|
|
|
<div className="flex flex-wrap gap-1">
|
|
|
|
|
<div className="size-1 rounded-xs bg-(--preview-base)/55" />
|
|
|
|
|
<div className="h-1 w-6 rounded-xs bg-(--preview-base)/55" />
|
2026-09-29 20:58:35 +08:00
|
|
|
<div className="h-1 w-3 rounded-xs bg-(--preview-base)/55" />
|
2026-09-21 16:05:05 +08:00
|
|
|
<div className="h-1 w-5 rounded-xs bg-(--preview-base)/55" />
|
|
|
|
|
<div className="h-1 w-5 rounded-xs bg-(--preview-base)/55" />
|
|
|
|
|
<div className="size-1 rounded-xs bg-(--preview-base)/55" />
|
|
|
|
|
<div className="h-1 w-5 rounded-xs bg-(--preview-base)/55" />
|
2026-09-29 20:58:35 +08:00
|
|
|
<div className="h-1 w-2 rounded-xs bg-(--preview-base)/55" />
|
|
|
|
|
<div className="size-1 rounded-xs bg-(--preview-base)/55" />
|
2026-09-21 16:05:05 +08:00
|
|
|
<div className="h-1 w-3 rounded-xs bg-(--preview-base)/55" />
|
|
|
|
|
<div className="size-1 rounded-xs bg-(--preview-base)/55" />
|
|
|
|
|
<div className="h-1 w-3 rounded-xs bg-(--preview-base)/55" />
|
2026-09-29 20:58:35 +08:00
|
|
|
<div className="size-1 rounded-xs bg-(--preview-base)/55" />
|
|
|
|
|
<div className="h-1 w-6 rounded-xs bg-(--preview-base)/55" />
|
2026-09-21 16:05:05 +08:00
|
|
|
</div>
|
|
|
|
|
<div className="flex items-center gap-1">
|
2026-09-29 17:08:08 +08:00
|
|
|
<div className="h-2 w-6 rounded-sm bg-accent" />
|
|
|
|
|
<div className="h-2 w-6 rounded-sm bg-accent/75" />
|
2026-09-21 16:05:05 +08:00
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
<div className="h-18" />
|
|
|
|
|
<div className="h-10 flex-1" />
|
|
|
|
|
<div className="h-10 flex-1" />
|
|
|
|
|
<div className="h-10 flex-1" />
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
)
|
|
|
|
|
}
|