Claude Chat
Animated Claude chat input — types a prompt character-by-character and the waveform button morphs into a terracotta send button the moment text appears. Warm light/dark themes.
Source
components/kuchi/claude-chat.tsx
1"use client";23import { loadFont as loadBodyFont } from "@remotion/google-fonts/Inter";4import {5 AbsoluteFill,6 interpolate,7 spring,8 useCurrentFrame,9 useVideoConfig,10} from "remotion";11import { Caret } from "@/components/kuchi/type-caret";12import { useTypewriter } from "@/lib/kuchi-kit";1314const { fontFamily: SANS_FAMILY } = loadBodyFont();1516export interface ClaudeChatProps {17 greeting?: string;18 placeholder?: string;19 prompt?: string;20 modelName?: string;21 modelTier?: string;22 accentColor?: string;23 speed?: number;24}2526interface Theme {27 page: string;28 cardBg: string;29 cardBorder: string;30 fg: string;31 fgMuted: string;32 placeholder: string;33 iconBtnBorder: string;34}3536export const THEMES: Record<"light" | "dark", Theme> = {37 light: {38 page: "#F5F4EF",39 cardBg: "#FFFFFF",40 cardBorder: "#E8E5DD",41 fg: "#1F1E1D",42 fgMuted: "#73726C",43 placeholder: "#A3A097",44 iconBtnBorder: "#E0DDD4",45 },46 dark: {47 page: "#262624",48 cardBg: "#1F1E1D",49 cardBorder: "#3A3936",50 fg: "#F0EEE6",51 fgMuted: "#9B9892",52 placeholder: "#73726C",53 iconBtnBorder: "#3A3936",54 },55};5657export const TYPING_START_FRAME = 42;5859export const TYPING_CPS = 22;6061export function morphProgressAt(62 frame: number,63 opts: { startFrame?: number; fps: number; speed: number },64): number {65 const startFrame = opts.startFrame ?? TYPING_START_FRAME;66 const value = spring({67 fps: opts.fps,68 frame: frame * opts.speed - startFrame,69 config: { damping: 14, stiffness: 200, mass: 0.6 },70 });71 return Math.max(0, Math.min(value, 1));72}7374export function introBounceIn(75 frame: number,76 fps: number,77): { translateY: number; scale: number } {78 const s = spring({79 fps,80 frame,81 config: { damping: 14, stiffness: 110, mass: 0.7 },82 });83 const translateY = interpolate(s, [0, 1], [28, 0]);84 const scale = interpolate(s, [0, 1], [0.97, 1]);85 return { translateY, scale };86}8788export function fadeUpAt(89 frame: number,90 range: [number, number],91): { opacity: number; translateY: number } {92 const opts = {93 extrapolateLeft: "clamp" as const,94 extrapolateRight: "clamp" as const,95 };96 return {97 opacity: interpolate(frame, range, [0, 1], opts),98 translateY: interpolate(frame, range, [12, 0], opts),99 };100}101102function ChevronDown({ size, color }: { size: number; color: string }) {103 return (104 <svg width={size} height={size} viewBox="0 0 24 24" fill="none">105 <title>Expand</title>106 <path107 d="M6 9l6 6 6-6"108 stroke={color}109 strokeWidth={2}110 strokeLinecap="round"111 strokeLinejoin="round"112 />113 </svg>114 );115}116117function PlusIcon({ size, color }: { size: number; color: string }) {118 return (119 <svg width={size} height={size} viewBox="0 0 24 24" fill="none">120 <title>Add</title>121 <path122 d="M12 5v14M5 12h14"123 stroke={color}124 strokeWidth={2}125 strokeLinecap="round"126 />127 </svg>128 );129}130131function MicIcon({ size, color }: { size: number; color: string }) {132 return (133 <svg width={size} height={size} viewBox="0 0 24 24" fill="none">134 <title>Voice input</title>135 <rect136 x={9}137 y={3}138 width={6}139 height={11}140 rx={3}141 stroke={color}142 strokeWidth={1.8}143 />144 <path145 d="M5.5 11a6.5 6.5 0 0013 0M12 17.5V21M9 21h6"146 stroke={color}147 strokeWidth={1.8}148 strokeLinecap="round"149 strokeLinejoin="round"150 />151 </svg>152 );153}154155function WaveformIcon({ size, color }: { size: number; color: string }) {156 const bars = [157 { x: 4, h: 8 },158 { x: 9, h: 16 },159 { x: 14, h: 12 },160 { x: 19, h: 20 },161 ];162 return (163 <svg width={size} height={size} viewBox="0 0 24 24" fill="none">164 <title>Voice</title>165 {bars.map((bar) => (166 <rect167 key={bar.x}168 x={bar.x - 1}169 y={(24 - bar.h) / 2}170 width={2.4}171 height={bar.h}172 rx={1.2}173 fill={color}174 />175 ))}176 </svg>177 );178}179180function SendIcon({ size }: { size: number }) {181 return (182 <svg width={size} height={size} viewBox="0 0 24 24" fill="none">183 <title>Send</title>184 <path185 d="M12 19V5M12 5l-6 6M12 5l6 6"186 stroke="#FFFFFF"187 strokeWidth={2.2}188 strokeLinecap="round"189 strokeLinejoin="round"190 />191 </svg>192 );193}194195function IconButton({196 size,197 border,198 children,199}: {200 size: number;201 border: string;202 children: React.ReactNode;203}) {204 return (205 <div206 style={{207 width: size,208 height: size,209 borderRadius: "100%",210 border: `1px solid ${border}`,211 display: "flex",212 alignItems: "center",213 justifyContent: "center",214 flexShrink: 0,215 }}216 >217 {children}218 </div>219 );220}221222export function ClaudeChat({223 placeholder = "Try: draft an email · summarize a doc · plan your week",224 prompt = "Draft a launch tweet for our new release",225 modelName = "Opus 4.8",226 modelTier = "Max",227 accentColor = "#D97757",228 speed = 1,229}: ClaudeChatProps) {230 const frame = useCurrentFrame();231 const { width, height, fps } = useVideoConfig();232 const t = THEMES.light;233234 const refW = 1280;235 const refH = 720;236 const stageScale = Math.min(width / refW, height / refH);237238 const tw = useTypewriter(prompt, {239 cps: TYPING_CPS,240 speed,241 startFrame: TYPING_START_FRAME,242 });243 const visibleText = tw.text;244 const showText = tw.count > 0;245 const morph = morphProgressAt(frame, { fps, speed });246247 const intro = introBounceIn(frame * speed, fps);248 const cardFade = fadeUpAt(frame * speed, [6, 22]);249250 const cardWidth = 860;251 const cardLeft = (refW - cardWidth) / 2;252 const iconBtnSize = 36;253 const morphSize = 40;254255 return (256 <AbsoluteFill style={{ background: "transparent" }}>257 <div258 style={{259 position: "absolute",260 left: "50%",261 top: "50%",262 width: refW,263 height: refH,264 translate: "-50% -50%",265 scale: `${stageScale}`,266 }}267 >268 <div269 style={{270 position: "absolute",271 left: cardLeft,272 top: 300,273 width: cardWidth,274 background: t.cardBg,275 border: `1px solid ${t.cardBorder}`,276 borderRadius: 24,277 boxShadow: "0 8px 30px -12px rgba(31,30,29,0.12)",278 opacity: cardFade.opacity,279 translate: `0 ${cardFade.translateY + intro.translateY}px`,280 scale: `${intro.scale}`,281 transformOrigin: "center top",282 }}283 >284 <div285 style={{286 padding: "26px 28px",287 minHeight: 58,288 fontFamily: SANS_FAMILY,289 fontSize: 21,290 lineHeight: 1.3,291 display: "flex",292 alignItems: "center",293 }}294 >295 {showText ? (296 <span style={{ color: t.fg }}>297 {visibleText}298 <Caret299 color={t.fg}300 blink={!tw.typing}301 speed={speed}302 height={24}303 radius={0}304 marginLeft={1}305 style={{306 verticalAlign: "text-bottom",307 translate: "0 3px",308 }}309 />310 </span>311 ) : (312 <span313 style={{314 color: t.placeholder,315 display: "inline-flex",316 alignItems: "center",317 }}318 >319 <Caret320 color={t.fg}321 blink={!tw.typing}322 speed={speed}323 height={24}324 radius={0}325 marginLeft={1}326 style={{327 verticalAlign: "text-bottom",328 translate: "0 3px",329 }}330 />331 <span style={{ marginLeft: 2 }}>{placeholder}</span>332 </span>333 )}334 </div>335336 <div337 style={{338 padding: "14px 18px",339 display: "flex",340 justifyContent: "space-between",341 alignItems: "center",342 }}343 >344 <IconButton size={iconBtnSize} border={t.iconBtnBorder}>345 <PlusIcon size={20} color={t.fg} />346 </IconButton>347348 <div349 style={{350 display: "flex",351 alignItems: "center",352 gap: 14,353 }}354 >355 <div356 style={{357 display: "flex",358 alignItems: "center",359 gap: 7,360 }}361 >362 <span363 style={{364 fontFamily: SANS_FAMILY,365 fontSize: 18,366 fontWeight: 500,367 color: t.fg,368 }}369 >370 {modelName}371 </span>372 <span373 style={{374 fontFamily: SANS_FAMILY,375 fontSize: 18,376 fontWeight: 400,377 color: t.fgMuted,378 }}379 >380 {modelTier}381 </span>382 <ChevronDown size={16} color={t.fgMuted} />383 </div>384385 <IconButton size={iconBtnSize} border={t.iconBtnBorder}>386 <MicIcon size={20} color={t.fg} />387 </IconButton>388389 <div390 style={{391 position: "relative",392 width: morphSize,393 height: morphSize,394 flexShrink: 0,395 }}396 >397 <div398 style={{399 position: "absolute",400 inset: 0,401 display: "flex",402 alignItems: "center",403 justifyContent: "center",404 borderRadius: "100%",405 border: `1px solid ${t.iconBtnBorder}`,406 opacity: 1 - morph,407 scale: `${1 - 0.1 * morph}`,408 }}409 >410 <WaveformIcon size={22} color={t.fg} />411 </div>412 <div413 style={{414 position: "absolute",415 inset: 0,416 display: "flex",417 alignItems: "center",418 justifyContent: "center",419 borderRadius: 10,420 background: accentColor,421 opacity: morph,422 scale: `${0.8 + 0.2 * morph}`,423 }}424 >425 <SendIcon size={22} />426 </div>427 </div>428 </div>429 </div>430 </div>431 </div>432 </AbsoluteFill>433 );434}







