mirror of
https://github.com/shadcn-ui/ui.git
synced 2026-06-11 09:51:40 +00:00
* feat: chart color * fix * fix * fix: chart color * chore: changeset * chore: restore directory registry formatting * feat: add fontHeading * feat: rebuild registry * fix: v0 * refactor * fix * fix * fix * fix * fix * fix: refactor preset handling * fix * fix * fix
31 lines
989 B
TypeScript
31 lines
989 B
TypeScript
import { V1_CHART_COLOR_MAP, type PresetConfig } from "shadcn/preset"
|
|
|
|
import { type ChartColorName, type FontHeadingValue } from "@/registry/config"
|
|
|
|
type SearchParamsLike = Pick<URLSearchParams, "get" | "has">
|
|
|
|
export function resolvePresetOverrides(
|
|
searchParams: SearchParamsLike,
|
|
decoded: Pick<PresetConfig, "theme" | "chartColor" | "fontHeading">
|
|
) {
|
|
const hasFontHeadingOverride = searchParams.has("fontHeading")
|
|
const hasChartColorOverride = searchParams.has("chartColor")
|
|
|
|
const fontHeading = hasFontHeadingOverride
|
|
? ((searchParams.get("fontHeading") ??
|
|
decoded.fontHeading) as FontHeadingValue)
|
|
: decoded.fontHeading
|
|
|
|
const chartColor = hasChartColorOverride
|
|
? ((searchParams.get("chartColor") ??
|
|
decoded.chartColor ??
|
|
V1_CHART_COLOR_MAP[decoded.theme] ??
|
|
decoded.theme) as ChartColorName)
|
|
: (decoded.chartColor ?? V1_CHART_COLOR_MAP[decoded.theme] ?? decoded.theme)
|
|
|
|
return {
|
|
fontHeading,
|
|
chartColor,
|
|
}
|
|
}
|