{"name":"code-card","entry":"component","title":"CodeCard","description":"Dark code card that types each line in place at a steady character rate, one line after another.","category":"Motion","capabilities":["replay","player"],"needsRemotion":true,"registryDependencies":["@jbm/card","@jbm/tokens"],"install":"npx shadcn@latest add @jbm/code-card","installName":"code-card","page":"https://jbm-ui.bns.studio/c/code-card","registryItem":"https://jbm-ui.bns.studio/r/code-card.json","sourcePath":"registry/jbm/motion/code-card.tsx","files":[{"source":"registry/jbm/motion/code-card.tsx","target":"src/jbm/motion/code-card.tsx","import":"@/jbm/motion/code-card","type":"registry:component"},{"source":"registry/jbm/motion/code-card-timing.js","target":"src/jbm/motion/code-card-timing.js","import":"@/jbm/motion/code-card-timing.js","type":"registry:component"},{"source":"registry/jbm/motion/code-card-timing.d.ts","target":"src/jbm/motion/code-card-timing.d.ts","import":"@/jbm/motion/code-card-timing","type":"registry:component"}],"endpoints":{"markdown":"https://jbm-ui.bns.studio/catalog/code-card.md","json":"https://jbm-ui.bns.studio/catalog/code-card.json"},"snippet":"import { CodeCard } from \"@/jbm/motion/code-card\"\n\n<CodeCard title=\"hello.ts\" charsPerSecond={32} lines={[\n  { t: \"const idea = \\\"simple\\\"\", at: 0.2 },\n  { t: \"render(idea)\", at: 0.7, color: \"#FF8A6A\" },\n]} />","api":[{"export":"CodeCard","kind":"component","summary":"Fixed-size dark Card with three window dots, an optional mono title, and mono code lines. Each line starts typing at its `at` cue or when the previous line finishes, whichever is later, at `charsPerSecond`; empty rows keep their line height so the layout never jumps.","props":[{"name":"lines","type":"CodeLine[]","required":true,"default":null,"description":"Code lines in order: `t` is the text (whitespace preserved, no wrapping), `at` is the earliest start in seconds relative to the enclosing Sequence, and optional `color` overrides the cream text color."},{"name":"w","type":"number","required":false,"default":"900","description":"Card width in stage pixels."},{"name":"h","type":"number","required":false,"default":"520","description":"Card height in stage pixels; content beyond it is clipped."},{"name":"size","type":"number","required":false,"default":"24","description":"Code font size in stage pixels; lines are 1.55 × size tall."},{"name":"title","type":"string","required":false,"default":null,"description":"Optional mono file name beside the window dots."},{"name":"charsPerSecond","type":"number","required":false,"default":"32","description":"Typing rate in characters per second; must be positive and finite or the schedule throws."}],"passthrough":[]},{"export":"codeTypingSchedule","kind":"function","summary":"Builds the sequential typing schedule CodeCard uses, in frames. Use it in the host to budget scene duration: the last entry's `end` plus one terminal frame.","params":[{"name":"lines","type":"{ t: string; at: number }[]","required":true,"default":null,"description":"The same `{ t, at }` lines passed to CodeCard; `at` in seconds."},{"name":"fps","type":"number","required":true,"default":null,"description":"Composition frames per second."},{"name":"charsPerSecond","type":"number","required":false,"default":null,"description":"Typing rate; throws a RangeError unless positive and finite."}],"returns":"One `{ characters, start, end }` per line: the line split into characters (code points) and its start and end frames."},{"export":"typedCode","kind":"function","summary":"The visible prefix of one scheduled line at a given frame.","params":[{"name":"line","type":"CodeTypingLine","required":true,"default":null,"description":"One entry from codeTypingSchedule."},{"name":"frame","type":"number","required":true,"default":null,"description":"Current frame relative to the enclosing Sequence."},{"name":"fps","type":"number","required":true,"default":null,"description":"Composition frames per second."},{"name":"charsPerSecond","type":"number","required":false,"default":null,"description":"Typing rate; must match the value used for the schedule."}],"returns":"The typed text so far: empty before `start`, the full line from `end` on."}],"stage":{"mode":"declared","landscape":{"width":900,"height":520},"vertical":{"width":900,"height":520},"basis":"The card is border-box with width `w` (900) and height `h` (520) at the defaults, regardless of content. Scene specs pass w = min(usable width, 1200) and h 480 in landscape, the usable width (936) and h 520 in vertical, and the available height in illustration layouts. Long lines do not wrap; they clip at the card edge."},"examples":[{"title":"Type a short file","code":"import { CodeCard } from \"@/jbm/motion/code-card\"\n\n<CodeCard title=\"hello.ts\" charsPerSecond={32} lines={[\n  { t: \"const idea = \\\"simple\\\"\", at: 0.2 },\n  { t: \"render(idea)\", at: 0.7, color: \"#FF8A6A\" },\n]} />"},{"title":"Budget the scene length","code":"import { codeTypingSchedule } from \"@/jbm/motion/code-card-timing\"\n\nconst fps = 30\nconst schedule = codeTypingSchedule(lines, fps, 32)\nconst durationInFrames = (schedule.at(-1)?.end ?? 0) + 1"}],"qa":["Step to the first frame (empty rows at full height), mid-typing (a partially typed line, earlier lines complete), and the last frame (every line complete).","Give two lines overlapping `at` cues: the second waits for the first to finish instead of typing in parallel.","Check the longest line and the line count fit inside `w` × `h` at the chosen `size`; overflow is clipped, not wrapped.","Inspect the dark surface border and shadow at display scale (docs/surface-depth.md)."],"related":[{"name":"card","relation":"installs"},{"name":"tokens","relation":"installs"},{"name":"scene-spec","relation":"installed-by"}],"galleryPreview":{"about":"Cue times are seconds on the gallery preview's timeline, which renders the demo below; the Usage examples may use other timings. Map a cue to your own props by its place in the demo.","fps":30,"durationInFrames":69,"lastFrame":68,"strip":"https://jbm-ui.bns.studio/c/code-card?view=strip","frames":[{"label":"Begin","frame":0,"at":0},{"label":"First line typed","frame":27,"at":0.9,"note":"The first line is complete and the second has not started."},{"label":"Second line typed","frame":54,"at":1.8,"note":"Two lines are complete; the vermilion third line is next."},{"label":"End","frame":68,"at":2.267}],"demo":[{"component":"CodeCard","props":{"w":620,"h":280,"title":"hello.ts","lines":[{"t":"const idea = \"simple\";","at":0.2},{"t":"const story = explain(idea);","at":0.7},{"t":"render(story);","at":1.2,"color":"#FF8A6A"}]}}],"code":"<CodeCard w={620} h={280} title=\"hello.ts\" lines={[{ t: \"const idea = \\\"simple\\\";\", at: 0.2 }, { t: \"const story = explain(idea);\", at: 0.7 }, { t: \"render(story);\", at: 1.2, color: \"#FF8A6A\" }]} />"},"docs":[{"title":"Scene spec guide","url":"https://jbm-ui.bns.studio/docs/scene-spec.md"}],"setup":{"namespace":"@jbm","componentsJson":{"registries":{"@jbm":"https://jbm-ui.bns.studio/r/{name}.json"}},"command":"npx shadcn@latest add @jbm/<name>","target":"src/jbm/","importAlias":"@/jbm/…","tsconfigPaths":{"@/*":["./src/*"]}},"rules":["Install through the @jbm namespace: each registry item JSON (/r/<name>.json) carries its files' contents and each guide is served at /docs/<slug>.md, so agents never need the source repository (it is public on GitHub for people browsing the code).","Files install to src/jbm/ and import as @/jbm/…, which needs the @/* → ./src/* path alias in tsconfig.json.","Items marked needsRemotion require the remotion package and must render inside a Remotion composition or Player; every other item works in any React page.","Use one vermilion accent per composition; accent2 is for annotations only and soft is for dark surfaces only.","Stages are 1920×1080 landscape and 1080×1920 vertical with declared safe areas; each item's stage field declares its size in stage pixels, and scenes compose from YAML-shaped specs with @jbm/scene-spec."],"links":{"catalog":"https://jbm-ui.bns.studio/catalog.json","llms":"https://jbm-ui.bns.studio/llms.txt"}}