"use client" import * as React from "react" import template from "lodash/template" import { Check, Copy, Moon, Repeat, Sun } from "lucide-react" import { useTheme } from "next-themes" import { cn } from "@/lib/utils" import { useConfig } from "@/hooks/use-config" import { copyToClipboardWithMeta } from "@/components/copy-button" import { ThemeWrapper } from "@/components/theme-wrapper" import { Button } from "@/registry/new-york/ui/button" import { Dialog, DialogContent, DialogDescription, DialogHeader, DialogTitle, DialogTrigger, } from "@/registry/new-york/ui/dialog" import { Drawer, DrawerContent, DrawerTrigger, } from "@/registry/new-york/ui/drawer" import { Label } from "@/registry/new-york/ui/label" import { Popover, PopoverContent, PopoverTrigger, } from "@/registry/new-york/ui/popover" import { Skeleton } from "@/registry/new-york/ui/skeleton" import { Tooltip, TooltipContent, TooltipTrigger, } from "@/registry/new-york/ui/tooltip" import { BaseColor, baseColors } from "@/registry/registry-base-colors" import "@/styles/mdx.css" export function ThemeCustomizer() { const [config, setConfig] = useConfig() const { resolvedTheme: mode } = useTheme() const [mounted, setMounted] = React.useState(false) React.useEffect(() => { setMounted(true) }, []) return (
@layer base {
:root {
--background:{" "}
{activeTheme?.cssVars.light["background"]};
--foreground:{" "}
{activeTheme?.cssVars.light["foreground"]};
{[
"card",
"popover",
"primary",
"secondary",
"muted",
"accent",
"destructive",
].map((prefix) => (
<>
--{prefix}:{" "}
{
activeTheme?.cssVars.light[
prefix as keyof typeof activeTheme.cssVars.light
]
}
;
--{prefix}-foreground:{" "}
{
activeTheme?.cssVars.light[
`${prefix}-foreground` as keyof typeof activeTheme.cssVars.light
]
}
;
>
))}
--border:{" "}
{activeTheme?.cssVars.light["border"]};
--input:{" "}
{activeTheme?.cssVars.light["input"]};
--ring:{" "}
{activeTheme?.cssVars.light["ring"]};
--radius: {config.radius}rem;
{["chart-1", "chart-2", "chart-3", "chart-4", "chart-5"].map(
(prefix) => (
<>
--{prefix}:{" "}
{
activeTheme?.cssVars.light[
prefix as keyof typeof activeTheme.cssVars.light
]
}
;
>
)
)}
}
.dark {
--background:{" "}
{activeTheme?.cssVars.dark["background"]};
--foreground:{" "}
{activeTheme?.cssVars.dark["foreground"]};
{[
"card",
"popover",
"primary",
"secondary",
"muted",
"accent",
"destructive",
].map((prefix) => (
<>
--{prefix}:{" "}
{
activeTheme?.cssVars.dark[
prefix as keyof typeof activeTheme.cssVars.dark
]
}
;
--{prefix}-foreground:{" "}
{
activeTheme?.cssVars.dark[
`${prefix}-foreground` as keyof typeof activeTheme.cssVars.dark
]
}
;
>
))}
--border:{" "}
{activeTheme?.cssVars.dark["border"]};
--input:{" "}
{activeTheme?.cssVars.dark["input"]};
--ring:{" "}
{activeTheme?.cssVars.dark["ring"]};
{["chart-1", "chart-2", "chart-3", "chart-4", "chart-5"].map(
(prefix) => (
<>
--{prefix}:{" "}
{
activeTheme?.cssVars.dark[
prefix as keyof typeof activeTheme.cssVars.dark
]
}
;
>
)
)}
}
}