Click Type
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.
Source
components/kuchi/click-type.tsx
1"use client";23import { loadFont as loadSans } from "@remotion/google-fonts/Inter";4import {5 AbsoluteFill,6 Easing,7 interpolate,8 useCurrentFrame,9 useVideoConfig,10} from "remotion";11import { Caret } from "@/components/kuchi/caret";12import { CursorTrack } from "@/components/kuchi/cursor-track";13import { inputStyleContext } from "@/components/kuchi/input";14import {15 mixOklch,16 type KuchiTheme,17 useKuchiTheme,18 withAlpha,19} from "@/lib/kuchi-ui";2021const { fontFamily: SANS } = loadSans("normal", {22 weights: ["400", "500"],23 subsets: ["latin"],24});2526/**27 * Click to type: a prompt composer whose placeholder writes itself while a28 * cursor flies in and clicks the field — then a hard cut into the field, where29 * the real prompt types at the caret and the send button arms.30 *31 * The composer is Prompt Send's: a glass panel over a soft accent wash, a32 * writing surface inside it, a round ink send button. Same paint, so the two33 * cut together.34 *35 * Two shots of one composer. The close-up is the same scene under a constant36 * camera scale, anchored on the text's first letter, so nothing scales while37 * it moves and the type has no pixel grid to climb.38 */39export interface ClickTypeProps {40 /** Muted text that writes itself in the wide shot. */41 placeholder?: string;42 /** What gets typed after the click, in the close-up. */43 prompt?: string;44 /** Small label at the field's bottom-left. */45 hint?: string;46 /** The wash behind the composer. Defaults to the theme's primary. */47 accentColor?: string;48 theme?: Partial<KuchiTheme>;49 mode?: "light" | "dark";50 /** Time multiplier. */51 speed?: number;52 className?: string;53}5455/** Cursor lands and clicks. */56export const CLICK_AT = 30;57/** The cut into the field. */58export const CUT_AT = 34;59const TYPE_AT = CUT_AT + 4;60const HOLD = 36;6162/** At 720p. */63const PANEL_W = 920;64const PANEL_H = 260;65/** The glass rim between panel and writing surface. */66const PAD = 7;67const RADIUS = 32;68const PAD_X = 34;69const PAD_Y = 34;70const TEXT = 30;71const SEND = 46;72const ZOOM = 1.9;73/** Where the first letter lands in the close-up, as a fraction of the frame. */74const FOCUS = { x: 0.2, y: 0.4 };7576const EASE = Easing.bezier(0.2, 0.6, 0.35, 1);77const CLAMP = {78 extrapolateLeft: "clamp",79 extrapolateRight: "clamp",80} as const;8182/** Frame each character of `prompt` lands on, relative to TYPE_AT. A space costs a beat. */83function keystrokes(prompt: string) {84 const at: number[] = [];85 let f = 0;86 for (const ch of prompt) {87 at.push(f);88 f += ch === " " ? 2 : 1;89 }90 return { at, total: f };91}9293export const DEFAULT_PROMPT = "Build me a marketing site";9495/** Natural length for a given prompt. */96export function clickTypeFrames(prompt: string = DEFAULT_PROMPT): number {97 return TYPE_AT + keystrokes(prompt).total + HOLD;98}99100const PLUS = "M12 7v10M7 12h10";101const MIC =102 "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";103const SPARK = "M12 4v4M12 16v4M4 12h4M16 12h4M6.5 6.5l2.5 2.5M15 15l2.5 2.5";104const ARROW = "M12 19V5M5.5 11.5 12 5l6.5 6.5";105106export function ClickType({107 placeholder = "Describe what you want to build...",108 prompt = DEFAULT_PROMPT,109 hint = "New suggestion",110 accentColor,111 theme,112 mode,113 speed = 1,114 className,115}: ClickTypeProps) {116 const frame = useCurrentFrame() * speed;117 const { width, height } = useVideoConfig();118 const t = useKuchiTheme(theme, mode);119 const ui = inputStyleContext(t);120 const s = height / 720;121 const accent = accentColor ?? t.primary;122123 // Prompt Send's paint, token for token.124 const glassy = withAlpha(t.card, 0.52);125 const surface = withAlpha(t.card, 0.94);126 const hairline = mixOklch(ui.idleBorder, t.background, 0.1);127 const sendIdle = mixOklch(t.foreground, t.card, 0.55);128129 const close = frame >= CUT_AT;130 const panelX = (width - PANEL_W * s) / 2;131 const panelY = (height - PANEL_H * s) / 2;132 const fieldX = panelX + PAD * s;133 const fieldY = panelY + PAD * s;134 const fieldW = (PANEL_W - PAD * 2) * s;135 const fieldH = (PANEL_H - PAD * 2) * s;136 const textX = fieldX + PAD_X * s;137 const textY = fieldY + PAD_Y * s;138139 // Placeholder writes itself at ~1.5 chars a frame from frame 4.140 const shown = Math.max(0, Math.floor((frame - 4) * 1.5));141 const typed = keystrokes(prompt).at.filter(142 (a) => frame >= TYPE_AT + a,143 ).length;144 const armed = close && typed > 0;145 const enter = interpolate(frame, [0, 12], [0, 1], { ...CLAMP, easing: EASE });146147 const path = [148 { at: 6, x: -0.04, y: 0.62, duration: 4 },149 {150 at: 10,151 x: (textX + 8 * s) / width,152 y: (textY + TEXT * 0.9 * s) / height,153 duration: CLICK_AT - 10,154 click: true,155 },156 ];157158 // The close-up: one constant camera, the first letter pinned to FOCUS.159 const camera = close160 ? `translate(${FOCUS.x * width - textX * ZOOM}px, ${FOCUS.y * height - textY * ZOOM}px) scale(${ZOOM})`161 : "none";162163 const glyph = (d: string, color: string, size: number, stroke = 1.8) => (164 <svg165 viewBox="0 0 24 24"166 width={size}167 height={size}168 style={{ display: "block" }}169 >170 <title>Icon</title>171 <path172 d={d}173 fill="none"174 stroke={color}175 strokeWidth={stroke}176 strokeLinecap="round"177 strokeLinejoin="round"178 />179 </svg>180 );181 const iconButton = (d: string) => (182 <div183 style={{184 width: SEND * s,185 height: SEND * s,186 boxSizing: "border-box",187 borderRadius: 999,188 border: `1px solid ${hairline}`,189 background: t.card,190 display: "flex",191 alignItems: "center",192 justifyContent: "center",193 }}194 >195 {glyph(d, ui.mutedForeground, 22 * s)}196 </div>197 );198199 const scene = (200 <AbsoluteFill201 className={className}202 style={{203 background: t.background,204 fontFamily: SANS,205 textRendering: "geometricPrecision",206 overflow: "hidden",207 }}208 >209 <AbsoluteFill style={{ transformOrigin: "0 0", transform: camera }}>210 {/* Prompt Send's wash: a cool field falling from the top right, a211 bright patch left of centre, a pale corner under it — alpha over212 the page, never a hue mix through green. Oversized so the close-up213 never finds its edge. */}214 <div215 style={{216 position: "absolute",217 left: -0.2 * width,218 top: -0.2 * height,219 width: 1.4 * width,220 height: 1.4 * height,221 background: t.background,222 backgroundImage: [223 `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%)`,224 `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%)`,225 `linear-gradient(215deg, ${withAlpha(accent, 0.5)} 0%, ${withAlpha(accent, 0.28)} 52%, ${withAlpha(accent, 0.14)} 100%)`,226 ].join(","),227 }}228 />229 <AbsoluteFill230 style={{231 opacity: close ? 1 : enter,232 transform: close233 ? undefined234 : `translateY(${(1 - enter) * 14 * s}px)`,235 }}236 >237 {/* The glass panel. Hairline as an inset shadow, not a border. */}238 <div239 style={{240 position: "absolute",241 left: panelX,242 top: panelY,243 width: PANEL_W * s,244 height: PANEL_H * s,245 borderRadius: RADIUS * s,246 background: glassy,247 boxShadow: `inset 0 0 0 1px ${withAlpha(t.card, 0.6)}, 0 ${12 * s}px ${32 * s}px ${withAlpha(t.foreground, 0.05)}`,248 }}249 />250 {/* The writing surface. */}251 <div252 style={{253 position: "absolute",254 left: fieldX,255 top: fieldY,256 width: fieldW,257 height: fieldH,258 borderRadius: (RADIUS - 2) * s,259 background: surface,260 boxShadow: `0 ${6 * s}px ${18 * s}px ${withAlpha(t.foreground, 0.05)}`,261 }}262 />263 <div264 style={{265 position: "absolute",266 left: textX,267 top: textY,268 right: width - (fieldX + fieldW) + PAD_X * s,269 fontSize: TEXT * s,270 lineHeight: 1.2,271 fontWeight: 400,272 letterSpacing: "-0.01em",273 whiteSpace: "nowrap",274 display: "flex",275 alignItems: "center",276 }}277 >278 {close ? (279 <>280 <span style={{ color: t.foreground }}>281 {prompt.slice(0, typed)}282 </span>283 <Caret284 color={t.foreground}285 width={Math.max(1.5, 2.4 * s)}286 height={TEXT * 1.15 * s}287 // Solid while it types, blinking once it waits.288 blink={typed === 0 || typed === prompt.length}289 blinkPerSecond={1.6}290 marginLeft={2 * s}291 />292 </>293 ) : (294 <span style={{ color: ui.mutedForeground }}>295 {placeholder.slice(0, shown)}296 </span>297 )}298 </div>299 <div300 style={{301 position: "absolute",302 left: textX,303 right: width - (fieldX + fieldW) + 18 * s,304 top: fieldY + fieldH - (SEND + 18) * s,305 height: SEND * s,306 display: "flex",307 alignItems: "center",308 gap: 10 * s,309 fontSize: 19 * s,310 fontWeight: 500,311 color: ui.mutedForeground,312 }}313 >314 {glyph(SPARK, ui.mutedForeground, 18 * s, 2)}315 <span style={{ flex: 1 }}>{hint}</span>316 {iconButton(PLUS)}317 {iconButton(MIC)}318 <div319 style={{320 width: SEND * s,321 height: SEND * s,322 borderRadius: 999,323 background: armed ? t.foreground : sendIdle,324 display: "flex",325 alignItems: "center",326 justifyContent: "center",327 }}328 >329 {glyph(ARROW, t.card, SEND * 0.52 * s, 2.2)}330 </div>331 </div>332 </AbsoluteFill>333 </AbsoluteFill>334 </AbsoluteFill>335 );336337 // The cursor belongs to the wide shot; the cut leaves it behind.338 return close ? (339 scene340 ) : (341 <CursorTrack path={path} theme={theme} mode={mode} speed={speed}>342 {scene}343 </CursorTrack>344 );345}





