{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "accent-picker",
  "title": "Accent Picker",
  "description": "A bar of solid swatches that turns the page's glow and focus ring one steady color, in light and dark, and remembers the choice.",
  "dependencies": [
    "motion"
  ],
  "registryDependencies": [
    "utils"
  ],
  "files": [
    {
      "path": "components/ui/accent-picker.tsx",
      "content": "\"use client\"\n\nimport * as React from \"react\"\nimport { motion, useReducedMotion } from \"motion/react\"\n\nimport { springs } from \"@/lib/afterglow\"\nimport { cn } from \"@/lib/utils\"\n\ntype Accent = {\n  id: string\n  label: string\n  /** the accent's hue, in OKLCH degrees */\n  hue: number\n}\n\n// ember is the stock dusk palette, so it clears every override instead of setting one\nconst accents: Accent[] = [\n  { id: \"ember\", label: \"Ember\", hue: 45 },\n  { id: \"ocean\", label: \"Ocean\", hue: 240 },\n  { id: \"mint\", label: \"Mint\", hue: 160 },\n  { id: \"violet\", label: \"Violet\", hue: 295 },\n  { id: \"rose\", label: \"Rose\", hue: 8 },\n]\n\nconst properties = [\"--glow\", \"--glow-2\", \"--glow-3\", \"--ring\"] as const\n\n// one solid color: the glow and both of its tail colors are the same, so nothing blends\n// into a second hue. same lightness and chroma as the stock glow, so only the hue changes\nfunction paint(accent: Accent, isDark: boolean, root: HTMLElement) {\n  if (accent.id === accents[0].id) {\n    properties.forEach((name) => root.style.removeProperty(name))\n    return\n  }\n  const color = isDark ? `oklch(0.8 0.16 ${accent.hue})` : `oklch(0.7 0.19 ${accent.hue})`\n  properties.forEach((name) => root.style.setProperty(name, color))\n}\n\n// every picker on the page shares one saved choice\nconst listeners = new Set<() => void>()\nconst subscribe = (callback: () => void) => {\n  listeners.add(callback)\n  return () => void listeners.delete(callback)\n}\n\ntype AccentPickerProps = Omit<React.ComponentProps<\"div\">, \"onChange\"> & {\n  /** the choices; the first is treated as the stock palette */\n  options?: Accent[]\n  /** where the choice is saved */\n  storageKey?: string\n  onValueChange?: (id: string) => void\n}\n\nfunction AccentPicker({\n  options = accents,\n  storageKey = \"afterglow-accent\",\n  onValueChange,\n  className,\n  ...props\n}: AccentPickerProps) {\n  const reduceMotion = useReducedMotion()\n  const ringId = React.useId()\n\n  const current = React.useSyncExternalStore(\n    subscribe,\n    () => {\n      const saved = window.localStorage.getItem(storageKey)\n      return options.some((option) => option.id === saved) ? saved! : options[0].id\n    },\n    () => options[0].id\n  )\n  const accent = options.find((option) => option.id === current) ?? options[0]\n\n  // paint the page, and again whenever the theme flips between light and dark\n  React.useEffect(() => {\n    const root = document.documentElement\n    const apply = () => paint(accent, root.classList.contains(\"dark\"), root)\n    apply()\n    const observer = new MutationObserver(apply)\n    observer.observe(root, { attributes: true, attributeFilter: [\"class\"] })\n    return () => observer.disconnect()\n  }, [accent])\n\n  function choose(id: string) {\n    window.localStorage.setItem(storageKey, id)\n    listeners.forEach((callback) => callback())\n    onValueChange?.(id)\n  }\n\n  return (\n    <div\n      data-slot=\"accent-picker\"\n      role=\"radiogroup\"\n      aria-label=\"Accent color\"\n      className={cn(\n        \"inline-flex items-center gap-1 rounded-full bg-glass p-1.5 shadow-glass backdrop-blur-xl backdrop-saturate-150\",\n        className\n      )}\n      {...props}\n    >\n      {options.map((option) => {\n        const selected = option.id === current\n        return (\n          <button\n            key={option.id}\n            type=\"button\"\n            role=\"radio\"\n            aria-checked={selected}\n            aria-label={option.label}\n            title={option.label}\n            onClick={() => choose(option.id)}\n            className=\"relative grid size-8 cursor-pointer place-items-center rounded-full outline-none transition-[scale] duration-150 ease-out focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-ring motion-safe:active:scale-[0.96] motion-reduce:transition-none\"\n          >\n            {selected && (\n              <motion.span\n                layoutId={`${ringId}-ring`}\n                aria-hidden\n                // a glass bezel around the swatch: a lit top edge, a shaded lower edge, a soft drop\n                className=\"absolute inset-0 rounded-full border border-foreground/20 bg-linear-to-b from-foreground/[0.22] to-foreground/[0.04] shadow-[inset_0_1px_0_oklch(1_0_0/55%),inset_0_-2px_3px_-1px_oklch(0_0_0/30%),0_2px_5px_-1px_oklch(0_0_0/35%)]\"\n                transition={reduceMotion ? { duration: 0 } : springs.snappy}\n              >\n                <span className=\"absolute inset-x-[18%] top-[6%] h-[36%] rounded-full bg-linear-to-b from-white/45 to-transparent\" />\n              </motion.span>\n            )}\n            <span\n              aria-hidden\n              className=\"relative size-[22px] rounded-full shadow-[inset_0_0_0_1px_oklch(0_0_0/8%)]\"\n              style={{ background: `oklch(0.74 0.17 ${option.hue})` }}\n            />\n          </button>\n        )\n      })}\n    </div>\n  )\n}\n\nexport { AccentPicker, type Accent, type AccentPickerProps }\n",
      "type": "registry:ui"
    },
    {
      "path": "lib/afterglow.ts",
      "content": "import type { CSSProperties } from \"react\"\nimport type { TargetAndTransition, Transition } from \"motion/react\"\n\n// shared spring presets, every component picks from these\nexport const springs = {\n  snappy: { stiffness: 520, damping: 34, mass: 0.6 },\n  soft: { stiffness: 260, damping: 26, mass: 0.8 },\n  glide: { stiffness: 120, damping: 20, mass: 1 },\n} as const\n\nexport type SpringName = keyof typeof springs\n\nexport function spring(name: SpringName): Transition {\n  return { type: \"spring\", ...springs[name] }\n}\n\n// how a glow fades once its source moves away: slow, with a long tail\nexport const afterglow = {\n  linger: 0.9,\n  ease: [0.22, 1, 0.36, 1],\n} as const satisfies { linger: number; ease: Transition[\"ease\"] }\n\n// paints only the padding ring of an element, used for glowing borders\nexport const ringMask: CSSProperties = {\n  WebkitMask:\n    \"linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0)\",\n  WebkitMaskComposite: \"xor\",\n  mask: \"linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0)\",\n  maskComposite: \"exclude\",\n}\n\n// small icon gestures, played when a control is pressed or selected\nexport const iconGestures = {\n  pop: { scale: [1, 1.2, 1] },\n  ring: { rotate: [0, -18, 14, -9, 4, 0], scale: [1, 1.12, 1] },\n  // a gear looks the same after half a turn, so it can rest there and snap back unseen\n  turn: { rotate: [0, 180], scale: [1, 1.12, 1] },\n  hop: { y: [0, -3, 0], scale: [1, 1.1, 1] },\n  nudge: { x: [0, 2.5, 0], scale: [1, 1.1, 1] },\n} satisfies Record<string, TargetAndTransition>\n\nexport type IconGesture = keyof typeof iconGestures\n\n// leaving a gesture is instant: every gesture already ends at, or looks like, its resting pose\nexport const iconRest: TargetAndTransition = { scale: 1, rotate: 0, x: 0, y: 0, transition: { duration: 0 } }\n",
      "type": "registry:lib"
    }
  ],
  "cssVars": {
    "theme": {
      "color-glow": "var(--glow)",
      "color-glow-foreground": "var(--glow-foreground)",
      "color-glow-2": "var(--glow-2)",
      "color-glow-3": "var(--glow-3)",
      "color-glass": "var(--glass)",
      "color-gloss-highlight": "var(--gloss-highlight)",
      "shadow-gloss": "inset 0 1px 0 0 var(--gloss-highlight), inset 0 -1px 0 0 var(--gloss-shade), 0 0 0 1px var(--gloss-edge), 0 1px 2px 0 var(--gloss-depth), 0 4px 12px -4px var(--gloss-depth)",
      "shadow-glass": "inset 0 1px 0 0 var(--gloss-highlight), inset 0 -10px 24px -18px var(--gloss-shade), inset 0 0 0 1px var(--gloss-edge), 0 2px 6px -1px var(--gloss-depth), 0 18px 40px -12px var(--gloss-depth)",
      "shadow-well": "inset 0 1px 3px 0 var(--gloss-depth), inset 0 0 0 1px var(--gloss-edge), 0 1px 0 0 var(--gloss-highlight)"
    },
    "light": {
      "glow": "oklch(0.7 0.19 45)",
      "glow-foreground": "oklch(0.22 0.05 40)",
      "glow-2": "oklch(0.64 0.22 12)",
      "glow-3": "oklch(0.56 0.21 300)",
      "glass": "oklch(1 0 0 / 55%)",
      "gloss-highlight": "oklch(1 0 0 / 95%)",
      "gloss-shade": "oklch(0.3 0.03 285 / 10%)",
      "gloss-depth": "oklch(0.32 0.03 285 / 20%)",
      "gloss-edge": "oklch(0.22 0.02 285 / 10%)",
      "liquid-tint": "oklch(1 0 0 / 18%)",
      "liquid-fallback": "oklch(1 0 0 / 55%)",
      "liquid-rim": "oklch(1 0 0 / 95%)",
      "liquid-edge": "oklch(0.2 0.02 285 / 10%)",
      "liquid-shadow": "oklch(0.22 0.02 285 / 26%)",
      "liquid-glow": "oklch(1 0 0 / 55%)",
      "liquid-shade": "oklch(0.25 0.03 285 / 14%)"
    },
    "dark": {
      "glow": "oklch(0.8 0.16 55)",
      "glow-foreground": "oklch(0.22 0.05 40)",
      "glow-2": "oklch(0.7 0.2 15)",
      "glow-3": "oklch(0.65 0.2 300)",
      "glass": "oklch(0.19 0 0 / 55%)",
      "gloss-highlight": "oklch(1 0 0 / 16%)",
      "gloss-shade": "oklch(0 0 0 / 30%)",
      "gloss-depth": "oklch(0.04 0 0 / 60%)",
      "gloss-edge": "oklch(1 0 0 / 9%)",
      "liquid-tint": "oklch(0.2 0 0 / 22%)",
      "liquid-fallback": "oklch(0.2 0 0 / 45%)",
      "liquid-rim": "oklch(1 0 0 / 60%)",
      "liquid-edge": "oklch(1 0 0 / 10%)",
      "liquid-shadow": "oklch(0 0 0 / 50%)",
      "liquid-glow": "oklch(1 0 0 / 24%)",
      "liquid-shade": "oklch(0 0 0 / 28%)"
    }
  },
  "type": "registry:ui"
}