mirror of
https://github.com/hanzoai/shadcn.git
synced 2026-10-30 18:22:59 +00:00
- Updated lib/colors.ts to match shadcn v4 (added var field, fixed oklch wrapping) - Updated color.tsx with lastCopied state and improved UX - Updated color-palette.tsx (removed Suspense, updated styling) - Updated color-format-selector.tsx from shadcn v4 - Updated colors-nav.tsx from shadcn v4 - Updated use-colors hook with lastCopied state management - Updated lib/themes.ts to use explicit color scheme list (8 themes) All color palettes should now display correctly on /colors page
29 lines
699 B
TypeScript
29 lines
699 B
TypeScript
import { useAtom } from "jotai"
|
|
import { atomWithStorage } from "jotai/utils"
|
|
|
|
import { ColorFormat } from "@/lib/colors"
|
|
import { useMounted } from "@/hooks/use-mounted"
|
|
|
|
type Config = {
|
|
format: ColorFormat
|
|
lastCopied: string
|
|
}
|
|
|
|
const colorsAtom = atomWithStorage<Config>("colors", {
|
|
format: "hsl",
|
|
lastCopied: "",
|
|
})
|
|
|
|
export function useColors() {
|
|
const [colors, setColors] = useAtom(colorsAtom)
|
|
const mounted = useMounted()
|
|
|
|
return {
|
|
isLoading: !mounted,
|
|
format: colors.format,
|
|
lastCopied: colors.lastCopied,
|
|
setFormat: (format: ColorFormat) => setColors({ ...colors, format }),
|
|
setLastCopied: (lastCopied: string) => setColors({ ...colors, lastCopied }),
|
|
}
|
|
}
|