{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "motion-tokens",
  "title": "Motion tokens",
  "description": "The feels' springs as numbers, for motion timed in JavaScript, and MotionSpeed, which plays those springs slower or faster.",
  "dependencies": [],
  "files": [
    {
      "path": "registry/lib/motion-tokens.ts",
      "content": "/*\n * Every value the library moves with. Components ask for a role, never for a\n * duration or a spring, so editing a feel here re-times every component.\n */\n\nexport const MOTION_ROLES = ['press', 'enter', 'exit', 'layout', 'morph', 'draw'] as const\n\n/**\n * What a movement is for; each has one spring in every feel.\n * - `press`: a control answering a press (buttons, toggles, thumbs).\n * - `enter`: something arriving (a menu, a popover, a toast, a new row).\n * - `exit`: something leaving. Faster than its entrance, and never bounces.\n * - `layout`: a size or position change (a panel opening, a list reordering).\n * - `morph`: one shape becoming another (a highlight moving to the picked tab).\n * - `draw`: a mark appearing along its length (a tick, a bar filling). Never\n *   bounces: an overshoot would cut the start of the mark.\n *\n * Every role also has a fade easing, the same curve held at its end, for\n * colours: an overshoot would carry a colour past its end, to another colour.\n */\nexport type MotionRole = (typeof MOTION_ROLES)[number]\n\nexport interface MotionSpring {\n  /** Seconds until it looks settled; any bounce happens after. */\n  visualDuration: number\n  /** 0 settles without overshoot; 0.25 overshoots a little. */\n  bounce: number\n}\n\nexport type Feel = Record<MotionRole, MotionSpring>\n\n/** A time played at `speed`, such as 0.25 for slow motion, in the same unit: the same curve over it, longer. */\nexport function atSpeed(time: number, speed: number): number {\n  return time / speed\n}\n\nexport const feels = {\n  /** Slower and soft, for calm products and long reads. */\n  calm: {\n    press: { visualDuration: 0.24, bounce: 0 },\n    enter: { visualDuration: 0.36, bounce: 0 },\n    exit: { visualDuration: 0.24, bounce: 0 },\n    layout: { visualDuration: 0.45, bounce: 0 },\n    morph: { visualDuration: 0.48, bounce: 0 },\n    draw: { visualDuration: 0.4, bounce: 0 },\n  },\n  /** Quick with no overshoot. The default. */\n  crisp: {\n    press: { visualDuration: 0.18, bounce: 0 },\n    enter: { visualDuration: 0.26, bounce: 0 },\n    exit: { visualDuration: 0.18, bounce: 0 },\n    layout: { visualDuration: 0.34, bounce: 0 },\n    morph: { visualDuration: 0.38, bounce: 0 },\n    draw: { visualDuration: 0.3, bounce: 0 },\n  },\n  /** Quicker than Crisp, with an overshoot you can see on everything that arrives or changes shape. */\n  lively: {\n    press: { visualDuration: 0.16, bounce: 0.4 },\n    enter: { visualDuration: 0.24, bounce: 0.3 },\n    exit: { visualDuration: 0.2, bounce: 0 },\n    layout: { visualDuration: 0.3, bounce: 0.25 },\n    morph: { visualDuration: 0.34, bounce: 0.35 },\n    draw: { visualDuration: 0.26, bounce: 0 },\n  },\n} as const satisfies Record<string, Feel>\n\nexport type FeelName = keyof typeof feels\n\n/**\n * How far a pressed control shrinks, as a scale: 0.97 is 3% smaller. A small\n * target such as an icon button presses deeper, or the press can't be seen.\n */\nexport const pressScales = {\n  calm: 0.98,\n  crisp: 0.97,\n  lively: 0.96,\n} as const satisfies Record<FeelName, number>\n\nexport const FEEL_NAMES = Object.keys(feels) as FeelName[]\n\nexport const DEFAULT_FEEL: FeelName = 'crisp'\n",
      "type": "registry:lib",
      "target": "@lib/motion-tokens.ts"
    },
    {
      "path": "registry/lib/motion-speed.tsx",
      "content": "'use client'\n\nimport { createContext, type ReactNode, use } from 'react'\n\nconst SpeedContext = createContext(1)\n\n/**\n * Plays the springs the motion foundation times in JavaScript at this rate,\n * such as 0.25 for a slow-motion demo: `useMotionTransition`'s, and a\n * drawer's. CSS transitions keep their timing.\n */\nfunction MotionSpeed({ speed, children }: { speed: number; children: ReactNode }) {\n  return <SpeedContext value={speed}>{children}</SpeedContext>\n}\n\n/** The rate `MotionSpeed` above sets, 1 without one. */\nfunction useMotionSpeed() {\n  return use(SpeedContext)\n}\n\nexport { MotionSpeed, useMotionSpeed }\n",
      "type": "registry:lib",
      "target": "@lib/motion-speed.tsx"
    }
  ],
  "type": "registry:lib"
}