{"$schema":"https://ui.shadcn.com/schema/registry-item.json","name":"click-type","type":"registry:component","title":"Click Type","description":"Click to type: a prompt composer (Prompt Send's glass panel, writing surface and round send button) whose placeholder writes itself while a cursor flies in from the edge and clicks the field, then a hard cut into the field where the real prompt types at the caret and send arms. Two shots of one composer under a constant camera, anchored on the first letter, so the type never scales while it moves.","dependencies":["remotion","@remotion/google-fonts"],"docs":"Needs a Remotion project. If a frame renders black, the component is drawing on a transparent layer: put a background behind it, e.g. <AbsoluteFill style={{ background: \"#faf9f6\" }}><Component /></AbsoluteFill>. Pass mode=\"dark\" for dark frames.","registryDependencies":["https://kuchi.kalarislabs.com/r/kuchi-ui.json","https://kuchi.kalarislabs.com/r/input.json","https://kuchi.kalarislabs.com/r/caret.json","https://kuchi.kalarislabs.com/r/cursor-track.json"],"files":[{"path":"components/kuchi/click-type.tsx","type":"registry:component","target":"components/kuchi/click-type.tsx","content":"/*! Portions Copyright (c) 2026 Sri Nath (snap-cn). MIT License. See THIRD_PARTY_LICENSES. */\n\"use client\";\r\n\r\nimport { loadFont as loadSans } from \"@remotion/google-fonts/Inter\";\r\nimport {\r\n  AbsoluteFill,\r\n  Easing,\r\n  interpolate,\r\n  useCurrentFrame,\r\n  useVideoConfig,\r\n} from \"remotion\";\r\nimport { Caret } from \"@/components/kuchi/caret\";\r\nimport { CursorTrack } from \"@/components/kuchi/cursor-track\";\r\nimport { inputStyleContext } from \"@/components/kuchi/input\";\r\nimport {\r\n  mixOklch,\r\n  type KuchiTheme,\r\n  useKuchiTheme,\r\n  withAlpha,\r\n} from \"@/lib/kuchi-ui\";\r\n\r\nconst { fontFamily: SANS } = loadSans(\"normal\", {\r\n  weights: [\"400\", \"500\"],\r\n  subsets: [\"latin\"],\r\n});\r\n\r\n/**\r\n * Click to type: a prompt composer whose placeholder writes itself while a\r\n * cursor flies in and clicks the field — then a hard cut into the field, where\r\n * the real prompt types at the caret and the send button arms.\r\n *\r\n * The composer is Prompt Send's: a glass panel over a soft accent wash, a\r\n * writing surface inside it, a round ink send button. Same paint, so the two\r\n * cut together.\r\n *\r\n * Two shots of one composer. The close-up is the same scene under a constant\r\n * camera scale, anchored on the text's first letter, so nothing scales while\r\n * it moves and the type has no pixel grid to climb.\r\n */\r\nexport interface ClickTypeProps {\r\n  /** Muted text that writes itself in the wide shot. */\r\n  placeholder?: string;\r\n  /** What gets typed after the click, in the close-up. */\r\n  prompt?: string;\r\n  /** Small label at the field's bottom-left. */\r\n  hint?: string;\r\n  /** The wash behind the composer. Defaults to the theme's primary. */\r\n  accentColor?: string;\r\n  theme?: Partial<KuchiTheme>;\r\n  mode?: \"light\" | \"dark\";\r\n  /** Time multiplier. */\r\n  speed?: number;\r\n  className?: string;\r\n}\r\n\r\n/** Cursor lands and clicks. */\r\nexport const CLICK_AT = 30;\r\n/** The cut into the field. */\r\nexport const CUT_AT = 34;\r\nconst TYPE_AT = CUT_AT + 4;\r\nconst HOLD = 36;\r\n\r\n/** At 720p. */\r\nconst PANEL_W = 920;\r\nconst PANEL_H = 260;\r\n/** The glass rim between panel and writing surface. */\r\nconst PAD = 7;\r\nconst RADIUS = 32;\r\nconst PAD_X = 34;\r\nconst PAD_Y = 34;\r\nconst TEXT = 30;\r\nconst SEND = 46;\r\nconst ZOOM = 1.9;\r\n/** Where the first letter lands in the close-up, as a fraction of the frame. */\r\nconst FOCUS = { x: 0.2, y: 0.4 };\r\n\r\nconst EASE = Easing.bezier(0.2, 0.6, 0.35, 1);\r\nconst CLAMP = {\r\n  extrapolateLeft: \"clamp\",\r\n  extrapolateRight: \"clamp\",\r\n} as const;\r\n\r\n/** Frame each character of `prompt` lands on, relative to TYPE_AT. A space costs a beat. */\r\nfunction keystrokes(prompt: string) {\r\n  const at: number[] = [];\r\n  let f = 0;\r\n  for (const ch of prompt) {\r\n    at.push(f);\r\n    f += ch === \" \" ? 2 : 1;\r\n  }\r\n  return { at, total: f };\r\n}\r\n\r\nexport const DEFAULT_PROMPT = \"Build me a marketing site\";\r\n\r\n/** Natural length for a given prompt. */\r\nexport function clickTypeFrames(prompt: string = DEFAULT_PROMPT): number {\r\n  return TYPE_AT + keystrokes(prompt).total + HOLD;\r\n}\r\n\r\nconst PLUS = \"M12 7v10M7 12h10\";\r\nconst MIC =\r\n  \"M12 4.5a2.5 2.5 0 0 0-2.5 2.5v4.5a2.5 2.5 0 0 0 5 0V7A2.5 2.5 0 0 0 12 4.5zM7 11a5 5 0 0 0 10 0M12 16v3\";\r\nconst SPARK = \"M12 4v4M12 16v4M4 12h4M16 12h4M6.5 6.5l2.5 2.5M15 15l2.5 2.5\";\r\nconst ARROW = \"M12 19V5M5.5 11.5 12 5l6.5 6.5\";\r\n\r\nexport function ClickType({\r\n  placeholder = \"Describe what you want to build...\",\r\n  prompt = DEFAULT_PROMPT,\r\n  hint = \"New suggestion\",\r\n  accentColor,\r\n  theme,\r\n  mode,\r\n  speed = 1,\r\n  className,\r\n}: ClickTypeProps) {\r\n  const frame = useCurrentFrame() * speed;\r\n  const { width, height } = useVideoConfig();\r\n  const t = useKuchiTheme(theme, mode);\r\n  const ui = inputStyleContext(t);\r\n  const s = height / 720;\r\n  const accent = accentColor ?? t.primary;\r\n\r\n  // Prompt Send's paint, token for token.\r\n  const glassy = withAlpha(t.card, 0.52);\r\n  const surface = withAlpha(t.card, 0.94);\r\n  const hairline = mixOklch(ui.idleBorder, t.background, 0.1);\r\n  const sendIdle = mixOklch(t.foreground, t.card, 0.55);\r\n\r\n  const close = frame >= CUT_AT;\r\n  const panelX = (width - PANEL_W * s) / 2;\r\n  const panelY = (height - PANEL_H * s) / 2;\r\n  const fieldX = panelX + PAD * s;\r\n  const fieldY = panelY + PAD * s;\r\n  const fieldW = (PANEL_W - PAD * 2) * s;\r\n  const fieldH = (PANEL_H - PAD * 2) * s;\r\n  const textX = fieldX + PAD_X * s;\r\n  const textY = fieldY + PAD_Y * s;\r\n\r\n  // Placeholder writes itself at ~1.5 chars a frame from frame 4.\r\n  const shown = Math.max(0, Math.floor((frame - 4) * 1.5));\r\n  const typed = keystrokes(prompt).at.filter(\r\n    (a) => frame >= TYPE_AT + a,\r\n  ).length;\r\n  const armed = close && typed > 0;\r\n  const enter = interpolate(frame, [0, 12], [0, 1], { ...CLAMP, easing: EASE });\r\n\r\n  const path = [\r\n    { at: 6, x: -0.04, y: 0.62, duration: 4 },\r\n    {\r\n      at: 10,\r\n      x: (textX + 8 * s) / width,\r\n      y: (textY + TEXT * 0.9 * s) / height,\r\n      duration: CLICK_AT - 10,\r\n      click: true,\r\n    },\r\n  ];\r\n\r\n  // The close-up: one constant camera, the first letter pinned to FOCUS.\r\n  const camera = close\r\n    ? `translate(${FOCUS.x * width - textX * ZOOM}px, ${FOCUS.y * height - textY * ZOOM}px) scale(${ZOOM})`\r\n    : \"none\";\r\n\r\n  const glyph = (d: string, color: string, size: number, stroke = 1.8) => (\r\n    <svg\r\n      viewBox=\"0 0 24 24\"\r\n      width={size}\r\n      height={size}\r\n      style={{ display: \"block\" }}\r\n    >\r\n      <title>Icon</title>\r\n      <path\r\n        d={d}\r\n        fill=\"none\"\r\n        stroke={color}\r\n        strokeWidth={stroke}\r\n        strokeLinecap=\"round\"\r\n        strokeLinejoin=\"round\"\r\n      />\r\n    </svg>\r\n  );\r\n  const iconButton = (d: string) => (\r\n    <div\r\n      style={{\r\n        width: SEND * s,\r\n        height: SEND * s,\r\n        boxSizing: \"border-box\",\r\n        borderRadius: 999,\r\n        border: `1px solid ${hairline}`,\r\n        background: t.card,\r\n        display: \"flex\",\r\n        alignItems: \"center\",\r\n        justifyContent: \"center\",\r\n      }}\r\n    >\r\n      {glyph(d, ui.mutedForeground, 22 * s)}\r\n    </div>\r\n  );\r\n\r\n  const scene = (\r\n    <AbsoluteFill\r\n      className={className}\r\n      style={{\r\n        background: t.background,\r\n        fontFamily: SANS,\r\n        textRendering: \"geometricPrecision\",\r\n        overflow: \"hidden\",\r\n      }}\r\n    >\r\n      <AbsoluteFill style={{ transformOrigin: \"0 0\", transform: camera }}>\r\n        {/* Prompt Send's wash: a cool field falling from the top right, a\r\n            bright patch left of centre, a pale corner under it — alpha over\r\n            the page, never a hue mix through green. Oversized so the close-up\r\n            never finds its edge. */}\r\n        <div\r\n          style={{\r\n            position: \"absolute\",\r\n            left: -0.2 * width,\r\n            top: -0.2 * height,\r\n            width: 1.4 * width,\r\n            height: 1.4 * height,\r\n            background: t.background,\r\n            backgroundImage: [\r\n              `radial-gradient(${0.96 * width}px ${0.8 * height}px at ${0.26 * width}px ${1.18 * height}px, ${withAlpha(t.background, 0.9)} 0%, transparent 62%)`,\r\n              `radial-gradient(${0.74 * width}px ${0.62 * height}px at ${0.3 * width}px ${0.66 * height}px, ${withAlpha(t.card, 0.42)} 0%, transparent 66%)`,\r\n              `linear-gradient(215deg, ${withAlpha(accent, 0.5)} 0%, ${withAlpha(accent, 0.28)} 52%, ${withAlpha(accent, 0.14)} 100%)`,\r\n            ].join(\",\"),\r\n          }}\r\n        />\r\n        <AbsoluteFill\r\n          style={{\r\n            opacity: close ? 1 : enter,\r\n            transform: close\r\n              ? undefined\r\n              : `translateY(${(1 - enter) * 14 * s}px)`,\r\n          }}\r\n        >\r\n          {/* The glass panel. Hairline as an inset shadow, not a border. */}\r\n          <div\r\n            style={{\r\n              position: \"absolute\",\r\n              left: panelX,\r\n              top: panelY,\r\n              width: PANEL_W * s,\r\n              height: PANEL_H * s,\r\n              borderRadius: RADIUS * s,\r\n              background: glassy,\r\n              boxShadow: `inset 0 0 0 1px ${withAlpha(t.card, 0.6)}, 0 ${12 * s}px ${32 * s}px ${withAlpha(t.foreground, 0.05)}`,\r\n            }}\r\n          />\r\n          {/* The writing surface. */}\r\n          <div\r\n            style={{\r\n              position: \"absolute\",\r\n              left: fieldX,\r\n              top: fieldY,\r\n              width: fieldW,\r\n              height: fieldH,\r\n              borderRadius: (RADIUS - 2) * s,\r\n              background: surface,\r\n              boxShadow: `0 ${6 * s}px ${18 * s}px ${withAlpha(t.foreground, 0.05)}`,\r\n            }}\r\n          />\r\n          <div\r\n            style={{\r\n              position: \"absolute\",\r\n              left: textX,\r\n              top: textY,\r\n              right: width - (fieldX + fieldW) + PAD_X * s,\r\n              fontSize: TEXT * s,\r\n              lineHeight: 1.2,\r\n              fontWeight: 400,\r\n              letterSpacing: \"-0.01em\",\r\n              whiteSpace: \"nowrap\",\r\n              display: \"flex\",\r\n              alignItems: \"center\",\r\n            }}\r\n          >\r\n            {close ? (\r\n              <>\r\n                <span style={{ color: t.foreground }}>\r\n                  {prompt.slice(0, typed)}\r\n                </span>\r\n                <Caret\r\n                  color={t.foreground}\r\n                  width={Math.max(1.5, 2.4 * s)}\r\n                  height={TEXT * 1.15 * s}\r\n                  // Solid while it types, blinking once it waits.\r\n                  blink={typed === 0 || typed === prompt.length}\r\n                  blinkPerSecond={1.6}\r\n                  marginLeft={2 * s}\r\n                />\r\n              </>\r\n            ) : (\r\n              <span style={{ color: ui.mutedForeground }}>\r\n                {placeholder.slice(0, shown)}\r\n              </span>\r\n            )}\r\n          </div>\r\n          <div\r\n            style={{\r\n              position: \"absolute\",\r\n              left: textX,\r\n              right: width - (fieldX + fieldW) + 18 * s,\r\n              top: fieldY + fieldH - (SEND + 18) * s,\r\n              height: SEND * s,\r\n              display: \"flex\",\r\n              alignItems: \"center\",\r\n              gap: 10 * s,\r\n              fontSize: 19 * s,\r\n              fontWeight: 500,\r\n              color: ui.mutedForeground,\r\n            }}\r\n          >\r\n            {glyph(SPARK, ui.mutedForeground, 18 * s, 2)}\r\n            <span style={{ flex: 1 }}>{hint}</span>\r\n            {iconButton(PLUS)}\r\n            {iconButton(MIC)}\r\n            <div\r\n              style={{\r\n                width: SEND * s,\r\n                height: SEND * s,\r\n                borderRadius: 999,\r\n                background: armed ? t.foreground : sendIdle,\r\n                display: \"flex\",\r\n                alignItems: \"center\",\r\n                justifyContent: \"center\",\r\n              }}\r\n            >\r\n              {glyph(ARROW, t.card, SEND * 0.52 * s, 2.2)}\r\n            </div>\r\n          </div>\r\n        </AbsoluteFill>\r\n      </AbsoluteFill>\r\n    </AbsoluteFill>\r\n  );\r\n\r\n  // The cursor belongs to the wide shot; the cut leaves it behind.\r\n  return close ? (\r\n    scene\r\n  ) : (\r\n    <CursorTrack path={path} theme={theme} mode={mode} speed={speed}>\r\n      {scene}\r\n    </CursorTrack>\r\n  );\r\n}\r\n"}]}