{"$schema":"https://ui.shadcn.com/schema/registry-item.json","name":"sticky-note-peel","type":"registry:component","title":"Sticky note peel","description":"Peel the top reminder off by its corner to mark it done.","author":"Yash Bavadiya <https://xevrion.dev>","dependencies":["motion"],"registryDependencies":["utils"],"files":[{"path":"components/sticky-note-peel.tsx","type":"registry:component","content":"\"use client\";\n\nimport { useEffect, useRef, useState } from \"react\";\nimport { flushSync } from \"react-dom\";\nimport {\n  animate,\n  motion,\n  useMotionValue,\n  useTransform,\n  type AnimationPlaybackControls,\n  type MotionValue,\n} from \"motion/react\";\nimport { useReducedMotion } from \"@/hooks/use-reduced-motion\";\nimport { Caveat } from \"next/font/google\";\nimport { cn } from \"@/lib/utils\";\n\n// A marker hand for what is written on the notes. Only the note text uses\n// it; the Done button stays in the interface font because it is chrome.\n// Not preloaded: the index bundles every preview, and other pages should\n// not fetch a font they never draw. The browser loads it on first use.\nconst hand = Caveat({\n  subsets: [\"latin\"],\n  weight: [\"500\", \"600\"],\n  preload: false,\n});\n\nexport type Reminder = {\n  id: number;\n  title: string;\n  detail: string;\n  // A short scribble in the top corner, like \"Fri\" or \"9am\".\n  due?: string;\n};\n\ntype Pt = { x: number; y: number };\ntype Flight = {\n  key: number;\n  note: Reminder;\n  index: number;\n  dx: number;\n  dy: number;\n  vx: number;\n  vy: number;\n  w: number;\n  h: number;\n};\n\n// A permanent dog-ear on the top note says \"this corner lifts\".\nconst REST = 14;\n// Hovering the corner lifts it a little further, as if your thumb found it.\nconst HOVER = 22;\n// Released past this share of the diagonal, the note comes away.\nconst COMMIT = 0.5;\n// A flick toward the far corner peels it however short the drag (px/s).\nconst FLICK = 600;\n// How far the corner may be dragged past the note's own edges, as a share of\n// its size. Keeps the flap from ever widening the page.\nconst OVERDRAG = 0.1;\n// How far along its path a leaving note keeps peeling while it falls.\nconst LEAVE_DISTANCE = 1.25;\n// Holds the corner to the finger with just enough give to feel like paper.\nconst SETTLE = { type: \"spring\", stiffness: 500, damping: 34 } as const;\nconst PEEL_AWAY = { type: \"spring\", stiffness: 170, damping: 26 } as const;\nconst EASE_OUT = [0.23, 1, 0.32, 1] as const;\n// Gravity: the drop gathers speed, which is the one place ease-in is right.\nconst FALL = [0.5, 0, 0.75, 0] as const;\nconst SHOWN_BEHIND = 3;\n\n// Each note sits slightly askew, like a real pad that has been handled.\nconst TILTS = [-1.2, 1.4, -0.6, 2, -1.8];\n// Sticky-note paper is a physical material, so these are raw colors on\n// purpose: the classic canary, then pink, mint, sky and peach pads. The dark\n// theme gets the same paper under dimmer light instead of a glaring pastel.\nconst PAPERS = [\n  \"light-dark(oklch(0.95 0.105 99), oklch(0.83 0.1 96))\",\n  \"light-dark(oklch(0.91 0.065 8), oklch(0.8 0.065 8))\",\n  \"light-dark(oklch(0.93 0.07 158), oklch(0.81 0.065 158))\",\n  \"light-dark(oklch(0.92 0.05 232), oklch(0.8 0.05 232))\",\n  \"light-dark(oklch(0.93 0.075 62), oklch(0.82 0.075 62))\",\n];\n// Ballpoint ink. The paper is light in both themes, so the ink is too.\nconst INK = \"oklch(0.29 0.045 262)\";\nconst tiltOf = (i: number) => TILTS[i % TILTS.length];\n\nconst dot = (a: Pt, b: Pt) => a.x * b.x + a.y * b.y;\n\n// Keeps the part of a convex polygon on one side of the fold line.\nfunction clipSide(poly: Pt[], m: Pt, n: Pt, keepCorner: boolean) {\n  const out: Pt[] = [];\n  const side = (p: Pt) => dot({ x: p.x - m.x, y: p.y - m.y }, n);\n  const inside = (d: number) => (keepCorner ? d > 0 : d <= 0);\n  for (let i = 0; i < poly.length; i++) {\n    const a = poly[i];\n    const b = poly[(i + 1) % poly.length];\n    const da = side(a);\n    const db = side(b);\n    if (inside(da)) out.push(a);\n    if (inside(da) !== inside(db)) {\n      const t = da / (da - db);\n      out.push({ x: a.x + (b.x - a.x) * t, y: a.y + (b.y - a.y) * t });\n    }\n  }\n  return out;\n}\n\nconst toPolygon = (pts: Pt[]) =>\n  pts.length < 3\n    ? \"polygon(0px 0px, 0px 0px, 0px 0px)\"\n    : `polygon(${pts.map((p) => `${p.x.toFixed(2)}px ${p.y.toFixed(2)}px`).join(\", \")})`;\n\n// The bottom-right corner C is lifted to P. The fold is the perpendicular\n// bisector of CP: what lies past it is flipped over the line and shows its\n// back. Reflection across a line is a single affine matrix, so the flap is\n// just the same sheet, clipped and mirrored.\nfunction fold(w: number, h: number, dx: number, dy: number) {\n  const rect = [\n    { x: 0, y: 0 },\n    { x: w, y: 0 },\n    { x: w, y: h },\n    { x: 0, y: h },\n  ];\n  const len = Math.hypot(dx, dy);\n  if (len < 0.5) {\n    return {\n      flat: toPolygon(rect),\n      back: toPolygon([]),\n      matrix: \"none\",\n      crease: \"none\",\n    };\n  }\n  const n = { x: -dx / len, y: -dy / len };\n  const m = { x: w + dx / 2, y: h + dy / 2 };\n  const k = 2 * dot(m, n);\n  const a = 1 - 2 * n.x * n.x;\n  const b = -2 * n.x * n.y;\n  const d = 1 - 2 * n.y * n.y;\n  // Lays a strip along the fold whose local +y points into the flap, so a\n  // top-to-bottom gradient shades the paper right where it bends.\n  const angle = Math.atan2(-n.x, n.y);\n  const span = w + h;\n  return {\n    flat: toPolygon(clipSide(rect, m, n, false)),\n    back: toPolygon(clipSide(rect, m, n, true)),\n    matrix: `matrix(${a}, ${b}, ${b}, ${d}, ${k * n.x}, ${k * n.y})`,\n    crease: `translate(${m.x}px, ${m.y}px) rotate(${angle}rad) translate(${-span}px, 0px)`,\n  };\n}\n\nfunction usePeel(\n  dx: MotionValue<number>,\n  dy: MotionValue<number>,\n  w: MotionValue<number>,\n  h: MotionValue<number>,\n) {\n  const geo = useTransform(() => fold(w.get(), h.get(), dx.get(), dy.get()));\n  return {\n    flat: useTransform(geo, (g) => g.flat),\n    back: useTransform(geo, (g) => g.back),\n    matrix: useTransform(geo, (g) => g.matrix),\n    crease: useTransform(geo, (g) => g.crease),\n  };\n}\n\nexport function StickyNotePeel({\n  notes: initial,\n  onDone,\n  className,\n}: {\n  notes: Reminder[];\n  onDone?: (note: Reminder) => void;\n  className?: string;\n}) {\n  const reduceMotion = useReducedMotion();\n  const [notes, setNotes] = useState(initial);\n  const [flights, setFlights] = useState<Flight[]>([]);\n  const flightKey = useRef(0);\n  const root = useRef<HTMLDivElement>(null);\n  const moveFocus = useRef(false);\n\n  // The top note's lifted corner, as an offset from its bottom-right.\n  const dx = useMotionValue(-REST);\n  const dy = useMotionValue(-REST);\n  // Every other note gets these, never nothing: Motion would keep the old\n  // curl on a note that stopped receiving values.\n  const flat = useMotionValue(0);\n  // Measured, so the fold stays exact at any width.\n  const w = useMotionValue(300);\n  const h = useMotionValue(300);\n  const spring = useRef<AnimationPlaybackControls[]>([]);\n\n  useEffect(() => {\n    const el = root.current;\n    if (!el) return;\n    const ro = new ResizeObserver(([entry]) => {\n      w.set(entry.contentRect.width);\n      h.set(entry.contentRect.height);\n    });\n    ro.observe(el);\n    return () => ro.disconnect();\n  }, [w, h]);\n\n  useEffect(() => {\n    const list = spring.current;\n    return () => list.forEach((c) => c.stop());\n  }, []);\n\n  // After a note leaves, keyboard focus follows to the next one.\n  useEffect(() => {\n    if (!moveFocus.current) return;\n    moveFocus.current = false;\n    root.current?.parentElement\n      ?.querySelector<HTMLElement>(\"[data-next-focus]\")\n      ?.focus();\n  }, [notes]);\n\n  const settle = (x: number, y: number, vx = 0, vy = 0) => {\n    spring.current.forEach((c) => c.stop());\n    if (reduceMotion) {\n      dx.jump(x);\n      dy.jump(y);\n      return;\n    }\n    spring.current = [\n      animate(dx, x, { ...SETTLE, velocity: vx }),\n      animate(dy, y, { ...SETTLE, velocity: vy }),\n    ];\n  };\n\n  const peelOff = (vx = 0, vy = 0) => {\n    const [top] = notes;\n    if (!top) return;\n    const flight: Flight = {\n      key: flightKey.current++,\n      note: top,\n      index: initial.indexOf(top),\n      dx: dx.get(),\n      dy: dy.get(),\n      vx,\n      vy,\n      w: w.get(),\n      h: h.get(),\n    };\n    spring.current.forEach((c) => c.stop());\n    // The stack advances at once; the peeled copy finishes leaving on its\n    // own, so the next note can be grabbed straight away.\n    flushSync(() => {\n      setNotes((list) => list.slice(1));\n      setFlights((list) => [...list, flight]);\n    });\n    // The next note starts flat and lifts its own dog-ear.\n    dx.jump(0);\n    dy.jump(0);\n    settle(-REST, -REST);\n    onDone?.(top);\n  };\n\n  const top = notes[0];\n\n  const release = (vx: number, vy: number) => {\n    const x = dx.get();\n    const y = dy.get();\n    const len = Math.hypot(x, y);\n    const diag = Math.hypot(w.get(), h.get());\n    // Speed toward the far corner counts, not speed in any direction.\n    const toward = (vx * x + vy * y) / (len || 1);\n    // 24px: a tap-sized wobble on the corner never counts as a flick.\n    if (len > diag * COMMIT || (len > 24 && toward > FLICK)) {\n      peelOff(vx, vy);\n    } else {\n      settle(-REST, -REST, vx, vy);\n    }\n  };\n\n  return (\n    <div className={cn(\"flex w-[min(320px,100%)] flex-col gap-5\", className)}>\n      <div ref={root} className=\"relative aspect-square w-full\">\n        {notes.length === 0 && (\n          <div className=\"absolute inset-0 flex flex-col items-center justify-center gap-4 rounded-[4px] border-2 border-dashed border-foreground/10 text-center transition-[opacity,filter] duration-300 ease-out starting:opacity-0 starting:blur-[4px]\">\n            <p className={cn(hand.className, \"text-[28px] leading-none font-semibold text-muted-foreground\")}>\n              All caught up\n            </p>\n            <button\n              type=\"button\"\n              data-next-focus\n              onClick={() => setNotes(initial)}\n              className=\"h-9 touch-manipulation rounded-full bg-muted px-4 text-sm font-medium text-foreground shadow-raised outline-hidden transition-[scale] duration-150 ease-out select-none focus-visible:outline-2 focus-visible:outline-solid focus-visible:outline-offset-2 focus-visible:outline-foreground active:scale-[0.96] motion-reduce:transition-none\"\n            >\n              Restore notes\n            </button>\n          </div>\n        )}\n\n        {notes\n          .slice(0, SHOWN_BEHIND + 1)\n          .reverse()\n          .map((note) => {\n            const index = initial.indexOf(note);\n            // One list with stable keys, so a note moving up to the top keeps\n            // its element instead of remounting.\n            if (note !== top) {\n              return (\n                <Sheet\n                  key={note.id}\n                  note={note}\n                  index={index}\n                  dx={flat}\n                  dy={flat}\n                  w={w}\n                  h={h}\n                  buried\n                />\n              );\n            }\n            return (\n              <Sheet\n                key={note.id}\n                note={note}\n                index={index}\n                dx={dx}\n                dy={dy}\n                w={w}\n                h={h}\n                onDone={() => {\n                  moveFocus.current = true;\n                  peelOff();\n                }}\n                corner={\n                  <Corner\n                    tilt={tiltOf(index)}\n                    dx={dx}\n                    dy={dy}\n                    w={w}\n                    h={h}\n                    settle={settle}\n                    stop={() => spring.current.forEach((c) => c.stop())}\n                    onRelease={release}\n                  />\n                }\n              />\n            );\n          })}\n\n        {flights.map((flight) => (\n          <Leaving\n            key={flight.key}\n            flight={flight}\n            reduce={!!reduceMotion}\n            onGone={() =>\n              setFlights((list) => list.filter((f) => f.key !== flight.key))\n            }\n          />\n        ))}\n      </div>\n\n      <p className=\"text-center text-sm text-muted-foreground tabular-nums\" aria-live=\"polite\">\n        {notes.length === 0\n          ? \"No reminders left\"\n          : `${notes.length} reminder${notes.length === 1 ? \"\" : \"s\"} left`}\n      </p>\n    </div>\n  );\n}\n\nfunction Sheet({\n  note,\n  index,\n  dx,\n  dy,\n  w,\n  h,\n  buried,\n  onDone,\n  corner,\n  style,\n}: {\n  note: Reminder;\n  index: number;\n  dx: MotionValue<number>;\n  dy: MotionValue<number>;\n  w: MotionValue<number>;\n  h: MotionValue<number>;\n  buried?: boolean;\n  onDone?: () => void;\n  corner?: React.ReactNode;\n  style?: React.ComponentProps<typeof motion.div>[\"style\"];\n}) {\n  const { flat, back, matrix, crease } = usePeel(dx, dy, w, h);\n  const paper = PAPERS[index % PAPERS.length];\n\n  return (\n    <motion.div\n      role={buried ? undefined : \"group\"}\n      aria-label={buried ? undefined : note.title}\n      aria-hidden={buried || undefined}\n      inert={buried || undefined}\n      style={{ rotate: tiltOf(index), ...style }}\n      className=\"absolute inset-0\"\n    >\n      {/* Shadow as a filter on a wrapper, so it follows the clipped shape\n          instead of being cut away with it. Only the adhesive strip is\n          stuck down, so the free bottom edge lifts and throws a longer\n          shadow than the top. */}\n      <div className=\"absolute inset-0 [filter:drop-shadow(0_1px_1px_oklch(0_0_0/0.1))_drop-shadow(0_10px_10px_oklch(0_0_0/0.09))] dark:[filter:drop-shadow(0_1px_1px_oklch(0_0_0/0.5))_drop-shadow(0_10px_14px_oklch(0_0_0/0.55))]\">\n        <motion.div\n          style={{ clipPath: flat, backgroundColor: paper, color: INK }}\n          className=\"absolute inset-0 flex flex-col p-6 pt-9\"\n        >\n          {/* The adhesive strip reads as a slightly glossier band, and the\n              lifted bottom edge catches a little less light. */}\n          <span\n            aria-hidden\n            className=\"absolute inset-x-0 top-0 h-8 bg-linear-to-b from-black/[0.045] to-black/[0.015]\"\n          />\n          <span\n            aria-hidden\n            className=\"absolute inset-x-0 bottom-0 h-16 bg-linear-to-t from-black/[0.05] to-transparent\"\n          />\n          {note.due && (\n            <span\n              className={cn(\n                hand.className,\n                \"absolute top-9 right-5 grid h-11 min-w-16 place-items-center px-2 text-[22px] leading-none font-semibold\",\n              )}\n            >\n              {/* Circled in red marker, the way you flag the one that is\n                  due. Red marker is a physical ink, so it is a raw color. */}\n              <svg\n                aria-hidden\n                viewBox=\"0 0 64 44\"\n                preserveAspectRatio=\"none\"\n                className=\"absolute inset-0 size-full overflow-visible\"\n                fill=\"none\"\n                stroke=\"oklch(0.56 0.19 27)\"\n                strokeWidth={1.8}\n                strokeLinecap=\"round\"\n              >\n                <path d=\"M40 5C22 2 5 9 4 22c-1 12 16 19 32 17 15-2 25-9 24-19C59 10 47 4 30 6\" />\n              </svg>\n              <span className=\"sr-only\">Due </span>\n              {note.due}\n            </span>\n          )}\n          <p\n            className={cn(\n              hand.className,\n              \"relative text-[30px] leading-[1.05] font-semibold text-balance\",\n              note.due && \"pr-16\",\n            )}\n          >\n            {note.title}\n          </p>\n          <p\n            className={cn(\n              hand.className,\n              \"relative mt-2.5 text-[22px] leading-[1.15] font-medium text-pretty opacity-75\",\n            )}\n          >\n            {note.detail}\n          </p>\n          {!buried && (\n            <button\n              type=\"button\"\n              data-next-focus\n              onClick={onDone}\n              className=\"relative mt-auto flex h-9 w-fit touch-manipulation items-center gap-2 rounded-full bg-black/[0.07] pr-4 pl-3 text-sm font-medium outline-hidden transition-[scale,background-color] duration-150 ease-out select-none hover:bg-black/[0.11] focus-visible:outline-2 focus-visible:outline-solid focus-visible:outline-offset-2 focus-visible:outline-current active:scale-[0.96] motion-reduce:transition-none\"\n            >\n              <svg\n                viewBox=\"0 0 16 16\"\n                className=\"size-4\"\n                fill=\"none\"\n                stroke=\"currentColor\"\n                strokeWidth={1.75}\n                strokeLinecap=\"round\"\n                strokeLinejoin=\"round\"\n                aria-hidden\n              >\n                <path d=\"m3.5 8.5 3 3 6-7\" />\n              </svg>\n              Done\n            </button>\n          )}\n        </motion.div>\n      </div>\n\n      {/* The flap: the same sheet mirrored across the fold, back side up. The\n          back of sticky paper is the same color, only matte and in its own\n          shade. It lifts off the page, so it casts its own tighter shadow. */}\n      <div\n        aria-hidden\n        className=\"pointer-events-none absolute inset-0 [filter:drop-shadow(-1px_2px_2px_oklch(0_0_0/0.18))] dark:[filter:drop-shadow(-1px_2px_3px_oklch(0_0_0/0.6))]\"\n      >\n        <motion.div\n          style={{\n            clipPath: back,\n            transform: matrix,\n            backgroundColor: `color-mix(in oklch, ${paper} 90%, oklch(0.4 0.02 80))`,\n          }}\n          className=\"absolute inset-0 origin-top-left overflow-hidden\"\n        >\n          <motion.span\n            style={{ transform: crease }}\n            className=\"absolute top-0 left-0 h-10 w-[1200px] origin-top-left bg-linear-to-b from-black/[0.14] to-transparent\"\n          />\n          <span className=\"absolute inset-0 bg-linear-to-br from-white/25 to-transparent\" />\n        </motion.div>\n      </div>\n\n      {corner}\n    </motion.div>\n  );\n}\n\nfunction Corner({\n  tilt,\n  dx,\n  dy,\n  w,\n  h,\n  settle,\n  stop,\n  onRelease,\n}: {\n  tilt: number;\n  dx: MotionValue<number>;\n  dy: MotionValue<number>;\n  w: MotionValue<number>;\n  h: MotionValue<number>;\n  settle: (x: number, y: number) => void;\n  stop: () => void;\n  onRelease: (vx: number, vy: number) => void;\n}) {\n  const drag = useRef<{ id: number; x: number; y: number; dx: number; dy: number } | null>(null);\n  // The sheet is tilted, so screen movement is turned into the sheet's own\n  // axes before it moves the corner.\n  const theta = (-tilt * Math.PI) / 180;\n  const local = (x: number, y: number) => ({\n    x: x * Math.cos(theta) - y * Math.sin(theta),\n    y: x * Math.sin(theta) + y * Math.cos(theta),\n  });\n\n  const end = (e: React.PointerEvent) => {\n    if (drag.current?.id !== e.pointerId) return;\n    drag.current = null;\n    // Already in the sheet's own axes, since that is what was set.\n    onRelease(dx.getVelocity(), dy.getVelocity());\n  };\n\n  return (\n    <div\n      aria-hidden\n      // 56px: a comfortable thumb target that stays inside the corner.\n      className=\"absolute right-0 bottom-0 size-14 cursor-grab touch-none active:cursor-grabbing\"\n      onPointerEnter={(e) => {\n        if (e.pointerType !== \"touch\" && !drag.current) settle(-HOVER, -HOVER);\n      }}\n      onPointerLeave={(e) => {\n        if (e.pointerType !== \"touch\" && !drag.current) settle(-REST, -REST);\n      }}\n      onPointerDown={(e) => {\n        if (drag.current || e.button !== 0) return;\n        e.currentTarget.setPointerCapture(e.pointerId);\n        stop();\n        drag.current = {\n          id: e.pointerId,\n          x: e.clientX,\n          y: e.clientY,\n          dx: dx.get(),\n          dy: dy.get(),\n        };\n      }}\n      onPointerMove={(e) => {\n        const d = drag.current;\n        if (!d || d.id !== e.pointerId) return;\n        const move = local(e.clientX - d.x, e.clientY - d.y);\n        const width = w.get();\n        const height = h.get();\n        dx.set(Math.min(0, Math.max(-width * (1 + OVERDRAG), d.dx + move.x)));\n        dy.set(Math.min(0, Math.max(-height * (1 + OVERDRAG), d.dy + move.y)));\n      }}\n      onPointerUp={end}\n      onPointerCancel={end}\n    />\n  );\n}\n\nfunction Leaving({\n  flight,\n  reduce,\n  onGone,\n}: {\n  flight: Flight;\n  reduce: boolean;\n  onGone: () => void;\n}) {\n  const dx = useMotionValue(flight.dx);\n  const dy = useMotionValue(flight.dy);\n  const w = useMotionValue(flight.w);\n  const h = useMotionValue(flight.h);\n  const y = useMotionValue(0);\n  const rotate = useMotionValue(tiltOf(flight.index));\n  const opacity = useMotionValue(1);\n  const gone = useRef(onGone);\n\n  useEffect(() => {\n    gone.current = onGone;\n  });\n\n  useEffect(() => {\n    if (reduce) {\n      const c = animate(opacity, 0, { duration: 0.15 });\n      c.then(() => gone.current());\n      return () => c.stop();\n    }\n    // Keep peeling the way the hand was going, or up and to the left when\n    // the Done button started it from a flat corner.\n    const len = Math.hypot(flight.dx, flight.dy);\n    const dir =\n      len > 16\n        ? { x: flight.dx / len, y: flight.dy / len }\n        : { x: -0.6, y: -0.8 };\n    const reach = Math.hypot(flight.w, flight.h) * LEAVE_DISTANCE;\n    // An exit you are not waiting on, so it can take its time: the curl and\n    // the fall read as paper, and nothing is blocked while it plays.\n    const all = [\n      animate(dx, dir.x * reach, { ...PEEL_AWAY, velocity: flight.vx }),\n      animate(dy, dir.y * reach, { ...PEEL_AWAY, velocity: flight.vy }),\n      animate(y, 90, { duration: 0.5, ease: FALL }),\n      animate(rotate, rotate.get() - 9, { duration: 0.5, ease: EASE_OUT }),\n      // Paper is opaque: it only fades once it is mostly clear of the pad,\n      // so it never reads as a ghost over the next note.\n      animate(opacity, 0, { duration: 0.2, delay: 0.3, ease: EASE_OUT }),\n    ];\n    all[4].then(() => gone.current());\n    return () => all.forEach((c) => c.stop());\n  }, [flight, reduce, dx, dy, y, rotate, opacity]);\n\n  return (\n    <motion.div\n      aria-hidden\n      inert\n      style={{ y, opacity }}\n      className=\"pointer-events-none absolute inset-0 z-10\"\n    >\n      <Sheet\n        note={flight.note}\n        index={flight.index}\n        dx={dx}\n        dy={dy}\n        w={w}\n        h={h}\n        buried\n        style={{ rotate }}\n      />\n    </motion.div>\n  );\n}\n\nconst NOTES: Reminder[] = [\n  { id: 1, title: \"Call the landlord\", detail: \"Ask about the radiator before it gets cold.\", due: \"Fri\" },\n  { id: 2, title: \"Renew passport\", detail: \"The photos are in the top drawer.\" },\n  { id: 3, title: \"Water the fern\", detail: \"Twice a week, not every day.\", due: \"Sun\" },\n  { id: 4, title: \"Send invoice 118\", detail: \"Net 30. Attach the timesheet.\", due: \"Mon\" },\n  { id: 5, title: \"Book the dentist\", detail: \"A morning slot, any day next week.\" },\n];\n\nexport default function StickyNotePeelDemo() {\n  return <StickyNotePeel notes={NOTES} />;\n}\n"},{"path":"hooks/use-reduced-motion.ts","type":"registry:hook","target":"hooks/use-reduced-motion.ts","content":"\"use client\";\n\nimport { useSyncExternalStore } from \"react\";\n\n// Motion's useReducedMotion reads the media query on the very first client\n// render, but the server can't know it, so every component that renders\n// differently under reduced motion broke hydration for those users. This\n// reports false during hydration, matching the server HTML, then the real\n// preference straight after, and follows it if it changes.\nconst query = \"(prefers-reduced-motion: reduce)\";\n\nfunction subscribe(onChange: () => void) {\n  const media = window.matchMedia(query);\n  media.addEventListener(\"change\", onChange);\n  return () => media.removeEventListener(\"change\", onChange);\n}\n\nexport function useReducedMotion() {\n  return useSyncExternalStore(\n    subscribe,\n    () => window.matchMedia(query).matches,\n    () => false,\n  );\n}\n"}],"cssVars":{"light":{"marker":"#d93d31","shadow-raised":"0 0 0 1px oklch(0 0 0 / 0.06), 0 1px 2px oklch(0 0 0 / 0.06), 0 6px 16px -6px oklch(0 0 0 / 0.12)"},"dark":{"marker":"#ff6b5f","shadow-raised":"0 0 0 1px oklch(1 0 0 / 0.08), 0 1px 2px oklch(0 0 0 / 0.4), 0 6px 16px -6px oklch(0 0 0 / 0.6)"},"theme":{"color-marker":"var(--marker)","shadow-raised":"var(--shadow-raised)"}},"categories":["objects"],"docs":"From ui lab: https://lab.xevrion.dev/lab/sticky-note-peel"}