mirror of
https://github.com/hanzoai/shadcn.git
synced 2026-10-30 18:22:59 +00:00
Upstream sync from shadcn-ui/ui (1686 commits since last merge base). Key changes: - packages/shadcn upgraded to 4.1.0 (CLI font transformers, scaffold from github, chart colors) - apps/v4 replaces apps/www as the primary docs/registry app - Font system: 25+ heading font registries, font markers utility, @supports override - Chart improvements: recharts v3 compat, radial chart fixes - templates/ updated with monorepo variants (astro, vite, react-router, start) - skills/shadcn AI skill definitions added - deprecated/ removed (auth, auth-firebase, cli, www) Preserved Hanzo-only paths: app/, pkg/, demo/, docs/, template/next/
86 lines
2.5 KiB
TypeScript
86 lines
2.5 KiB
TypeScript
import { describe, expect, it } from "vitest"
|
|
|
|
import {
|
|
buildRegistryBase,
|
|
DEFAULT_CONFIG,
|
|
designSystemConfigSchema,
|
|
} from "./config"
|
|
|
|
describe("buildRegistryBase", () => {
|
|
it("seeds a font-heading fallback when heading inherits the body font", () => {
|
|
const result = buildRegistryBase(DEFAULT_CONFIG)
|
|
|
|
expect(result.registryDependencies).toContain("font-inter")
|
|
expect(result.registryDependencies).not.toContain("font-heading-inter")
|
|
expect(result.cssVars?.theme?.["--font-heading"]).toBe("var(--font-sans)")
|
|
})
|
|
|
|
it("adds a heading font dependency when a distinct heading font is selected", () => {
|
|
const result = buildRegistryBase({
|
|
...DEFAULT_CONFIG,
|
|
fontHeading: "playfair-display",
|
|
})
|
|
|
|
expect(result.registryDependencies).toContain("font-inter")
|
|
expect(result.registryDependencies).toContain(
|
|
"font-heading-playfair-display"
|
|
)
|
|
expect(result.cssVars?.theme?.["--font-heading"]).toBeUndefined()
|
|
})
|
|
|
|
it("normalizes a matching heading font back to inherit", () => {
|
|
const result = buildRegistryBase({
|
|
...DEFAULT_CONFIG,
|
|
fontHeading: "inter",
|
|
})
|
|
|
|
expect(result.registryDependencies).not.toContain("font-heading-inter")
|
|
expect(result.cssVars?.theme?.["--font-heading"]).toBe("var(--font-sans)")
|
|
})
|
|
|
|
it("inherits the selected body font variable for non-sans body fonts", () => {
|
|
const result = buildRegistryBase({
|
|
...DEFAULT_CONFIG,
|
|
font: "jetbrains-mono",
|
|
fontHeading: "inherit",
|
|
})
|
|
|
|
expect(result.registryDependencies).toContain("font-jetbrains-mono")
|
|
expect(result.cssVars?.theme?.["--font-heading"]).toBe("var(--font-mono)")
|
|
})
|
|
|
|
it("defaults chartColor to neutral when omitted", () => {
|
|
const result = designSystemConfigSchema.parse({
|
|
base: "radix",
|
|
style: "nova",
|
|
iconLibrary: "lucide",
|
|
theme: "neutral",
|
|
font: "inter",
|
|
fontHeading: "inherit",
|
|
menuAccent: "subtle",
|
|
menuColor: "default",
|
|
radius: "default",
|
|
})
|
|
|
|
expect(result.chartColor).toBe("neutral")
|
|
})
|
|
|
|
it("rejects chartColor values that are unavailable for the selected base color", () => {
|
|
const result = designSystemConfigSchema.safeParse({
|
|
base: "radix",
|
|
style: "nova",
|
|
iconLibrary: "lucide",
|
|
baseColor: "neutral",
|
|
theme: "neutral",
|
|
chartColor: "stone",
|
|
font: "inter",
|
|
fontHeading: "inherit",
|
|
menuAccent: "subtle",
|
|
menuColor: "default",
|
|
radius: "default",
|
|
})
|
|
|
|
expect(result.success).toBe(false)
|
|
})
|
|
})
|