Skip to content

Open-source AI podcast clipper. Generate vertical clips with face tracking and burned-in captions. CLI, MCP server, web app.

Polish every pack's pages so nothing drifts or collides (#256)

Nika Siradze06e18077706b
diff --git a/remotion/src/components/Scene.tsx b/remotion/src/components/Scene.tsx
index 8446ac6..a5e9340 100644
--- a/remotion/src/components/Scene.tsx
+++ b/remotion/src/components/Scene.tsx
@@ -6,7 +6,7 @@ import { FONT } from "../types";
import { context, muted, track } from "./brand";
import type { Brand } from "./brand";
import {
- emphasisRuns, GAP_SIZE, MEDIA_HEIGHT, MIN_FIT, SCENE_WIDTH, TYPE_SIZE, sceneHeight, stepType,
+ emphasisRuns, GAP_SIZE, MEDIA_HEIGHT, MIN_FIT, SCENE_WIDTH, TYPE_SIZE, sceneHeight, STEP_RISE, stepType, stepsStacked,
sizeOf,
} from "../scene";
import type { Align, Block, Gap, Layout, Size, Tone } from "../scene";
@@ -276,6 +276,52 @@ const Piece: React.FC<{ block: Block; paint: Paint }> = ({ block, paint }) => {
);
}
+ if (block.type === "steps" && stepsStacked(block.points)) {
+ const last = block.points.length - 1;
+ const type = stepType(block.points, paint.width / unit);
+ return (
+ <div style={{ display: "flex", flexDirection: "column", alignItems: "stretch" }}>
+ {block.points.map((point, i) => (
+ <div key={i} style={{ display: "flex", alignItems: "stretch", gap: 30 * unit, paddingBottom: i < last ? STEP_RISE * unit : 0 }}>
+ <div style={{ flex: "none", width: MARK.dot * unit, display: "flex", flexDirection: "column", alignItems: "center" }}>
+ <div
+ style={{
+ flex: "none",
+ width: MARK.dot * unit,
+ height: MARK.dot * unit,
+ borderRadius: "50%",
+ backgroundColor: i === last ? accent : context(brand.ink),
+ marginTop: type.value * 0.32 * unit,
+ }}
+ />
+ {i < last && (
+ <div
+ style={{
+ flex: 1,
+ width: MARK.rule * unit,
+ marginTop: 10 * unit,
+ marginBottom: -(STEP_RISE + type.value * 0.32 - 10) * unit,
+ background: i + 1 === last ? accent : context(brand.ink),
+ }}
+ />
+ )}
+ </div>
+ <div>
+ <div style={{ fontFamily: paint.font, fontSize: type.value * unit, fontWeight: 700, color: brand.ink, lineHeight: 1.05 }}>
+ {point.value}
+ </div>
+ {point.note && (
+ <div style={{ fontFamily: paint.font, fontSize: type.note * unit, color: muted(brand.ink), marginTop: 6 * unit, lineHeight: 1.3 }}>
+ {point.note}
+ </div>
+ )}
+ </div>
+ </div>
+ ))}
+ </div>
+ );
+ }
+
if (block.type === "steps") {
const last = block.points.length - 1;
const type = stepType(block.points, paint.width / unit);
diff --git a/remotion/src/scene.test.ts b/remotion/src/scene.test.ts
index ede8fdf..fee8ff7 100644
--- a/remotion/src/scene.test.ts
+++ b/remotion/src/scene.test.ts
@@ -83,3 +83,13 @@ describe("the card in front at a moment", () => {
});
});
+
+describe("a stacked timeline of steps", () => {
+ const steps = (note: string) => [{ type: "steps", points: [{ value: "Product", note }, { value: "Distribution", note }] }] as Block[];
+
+ it("grows when a note wraps", () => {
+ const short = sceneHeight(steps("First-time founders"), "stack", "group");
+ const long = sceneHeight(steps("Founders who already shipped one company and now worry about distribution first"), "stack", "group");
+ expect(long).toBeGreaterThan(short);
+ });
+});
diff --git a/remotion/src/scene.ts b/remotion/src/scene.ts
index 4ed5886..730496a 100644
--- a/remotion/src/scene.ts
+++ b/remotion/src/scene.ts
@@ -170,19 +170,31 @@ const BAR_ROW = 26 + 8 + 34 * 1.3;
const CHAR_WIDTH = 0.64;
+export const STEP_RISE = 44;
+
+export const stepsStacked = (points: StepPoint[]) => points.length <= 3;
+
export const stepType = (points: StepPoint[], width = SCENE_WIDTH) => {
- const slot = (width - Math.max(0, points.length - 1) * 120) / Math.max(1, points.length);
+ const stacked = stepsStacked(points);
+ const slot = stacked
+ ? width - 56
+ : (width - Math.max(0, points.length - 1) * 120) / Math.max(1, points.length);
const fits = (text: string | undefined, size: number) => !text || text.length * size * CHAR_WIDTH <= slot;
const value = [TYPE_SIZE.xl, TYPE_SIZE.lg, TYPE_SIZE.md, TYPE_SIZE.sm]
.find((size) => points.every((point) => fits(point.value, size))) ?? TYPE_SIZE.xs;
- const note = [TYPE_SIZE.sm, TYPE_SIZE.xs]
+ const note = (stacked ? [TYPE_SIZE.md, TYPE_SIZE.sm, TYPE_SIZE.xs] : [TYPE_SIZE.sm, TYPE_SIZE.xs])
.find((size) => points.every((point) => fits(point.note, size))) ?? TYPE_SIZE.xs;
return { value, note };
};
const stepRow = (points: StepPoint[], width: number) => {
const type = stepType(points, width);
- return 26 + type.value + type.note * 2.6 + 24;
+ if (!stepsStacked(points)) return 26 + type.value + type.note * 2.6 + 24;
+ const text = width - 56;
+ return points.reduce((sum, point, i) =>
+ sum + (i ? STEP_RISE : 0)
+ + lines(point.value, type.value, text, CHAR_WIDTH) * type.value * 1.05
+ + (point.note ? lines(point.note, type.note, text, CHAR_WIDTH) * type.note * 1.3 + 6 : 0), 0);
};
const CHIP_ROW = 132;
diff --git a/remotion/src/style/materials.tsx b/remotion/src/style/materials.tsx
index 3c3307f..3915359 100644
--- a/remotion/src/style/materials.tsx
+++ b/remotion/src/style/materials.tsx
@@ -122,7 +122,7 @@ export const Label: React.FC<{
const size = base * (theme.type.label.size ?? 1);
if (theme.surface === "none") {
return (
- <div style={{ display: "inline-block", ...fontOf(theme.type.label, size), fontWeight: 700, lineHeight: 1,
+ <div style={{ display: "inline-block", ...fontOf({ ...theme.type.label, size: 1 }, size), fontWeight: 700, lineHeight: 1,
color: ink ?? theme.color.accent, ...style }}>
{children}
</div>
@@ -139,7 +139,7 @@ export const Label: React.FC<{
style={{ display: "inline-block", ...style }}
>
<div style={{
- ...fontOf(theme.type.label, size), fontWeight: 700, lineHeight: 1,
+ ...fontOf({ ...theme.type.label, size: 1 }, size), fontWeight: 700, lineHeight: 1,
color: ink ?? theme.color.onLabel,
padding: `${size * pad}px ${size * 0.38}px ${size * (pad - 0.06)}px`,
}}>
diff --git a/remotion/src/style/pages.tsx b/remotion/src/style/pages.tsx
index b6551ed..39406e4 100644
--- a/remotion/src/style/pages.tsx
+++ b/remotion/src/style/pages.tsx
@@ -149,7 +149,7 @@ const StatPage: React.FC<PageProps<"stat"> & { length: number }> = ({ card, them
]}>
{theme.surface === "paper" && (
<Reveal theme={theme} role="media" f={f} at={sheetAt} fps={fps}
- style={{ left: -40 * s, top: 500 * s, width: 1000 * s, height: 1500 * s, ...tilt(theme, -1.2) }}>
+ style={{ left: -40 * s, top: 500 * s, width: 1000 * s, height: 800 * s, ...tilt(theme, -1.2) }}>
<Paper theme={theme} seed={11} color={theme.color.sheet} scale={s} style={{ width: "100%", height: "100%" }} />
<Tape theme={theme} seed={1} scale={s} width={260} style={{ left: 760 * s, top: -24 * s, transform: "rotate(32deg)" }} />
</Reveal>
@@ -200,25 +200,27 @@ const HeadlinePage: React.FC<PageProps<"headline"> & { length: number }> = ({ ca
]}>
{theme.surface === "paper" && (
<Paper theme={theme} seed={21} color={theme.color.sheet} scale={s} strength={0.4}
- style={{ position: "absolute", left: 160 * s, top: 760 * s, width: 1000 * s, height: 1300 * s, ...tilt(theme, 2) }} />
+ style={{ position: "absolute", left: 160 * s, top: 640 * s, width: 1000 * s, height: 640 * s, ...tilt(theme, 2) }} />
)}
{card.eyebrow && (
<Reveal theme={theme} role="label" f={f} at={eyebrowAt} fps={fps} style={{ left: 80 * s, top: 250 * s, ...tilt(theme, -2) }}>
<Label theme={theme} seed={22} scale={s} size={(theme.surface === "none" ? 64 : 50) * s}>{card.eyebrow}</Label>
</Reveal>
)}
- <Reveal theme={theme} role="title" f={f} at={leadAt} fps={fps} style={{ left: 40 * s, top: 340 * s, width: 990 * s, ...tilt(theme, -0.8) }}>
- <Paper theme={theme} seed={23} color={theme.color.sheet} scale={s}>
- <div style={{ ...fontOf(theme.type.display, 128 * s), color: theme.color.ink, padding: `${50 * s}px ${60 * s}px ${64 * s}px` }}>
- <RevealText theme={theme} role="title" f={f} at={leadAt} text={card.lead} mark={mark} markAt={markAt} s={s} />
- </div>
- </Paper>
- </Reveal>
- {card.sub && (
- <Reveal theme={theme} role="strip" f={f} at={subAt} fps={fps} style={{ left: 120 * s, top: 1150 * s, ...tilt(theme, 1) }}>
- <Strip theme={theme} seed={24} s={s} size={50}>{card.sub}</Strip>
+ <div style={{ position: "absolute", left: 40 * s, top: 340 * s, width: 990 * s, display: "flex", flexDirection: "column", alignItems: "flex-start", gap: 48 * s }}>
+ <Reveal theme={theme} role="title" f={f} at={leadAt} fps={fps} style={{ position: "relative", width: "100%", ...tilt(theme, -0.8) }}>
+ <Paper theme={theme} seed={23} color={theme.color.sheet} scale={s}>
+ <div style={{ ...fontOf(theme.type.display, 128 * s), color: theme.color.ink, padding: `${50 * s}px ${60 * s}px ${64 * s}px` }}>
+ <RevealText theme={theme} role="title" f={f} at={leadAt} text={card.lead} mark={mark} markAt={markAt} s={s} />
+ </div>
+ </Paper>
</Reveal>
- )}
+ {card.sub && (
+ <Reveal theme={theme} role="strip" f={f} at={subAt} fps={fps} style={{ position: "relative", marginLeft: 80 * s, maxWidth: 860 * s, ...tilt(theme, 1) }}>
+ <Strip theme={theme} seed={24} s={s} size={50}>{card.sub}</Strip>
+ </Reveal>
+ )}
+ </div>
</Page>
);
};
@@ -236,13 +238,13 @@ const EntityPage: React.FC<PageProps<"entity"> & { length: number }> = ({ card,
{src && <Reveal theme={theme} role="media" f={f} at={mediaAt} fps={fps} style={{ left: 120 * s, top: 170 * s, width: 840 * s, ...tilt(theme, 1.3) }}>
<Paper theme={theme} seed={31} color="#E8E4D8" scale={s} strength={0.3}>
<div style={{ padding: theme.surface === "paper" ? 22 * s : 0 }}>
- {src && <Img src={src} style={{ width: 796 * s, height: 1035 * s, display: "block", objectFit: "cover" }} />}
+ {src && <Img src={src} style={{ width: 796 * s, height: (theme.surface === "none" ? 780 : 1035) * s, display: "block", objectFit: "cover" }} />}
</div>
</Paper>
<Tape theme={theme} seed={3} scale={s} width={250} style={{ left: -60 * s, top: 0, transform: "rotate(-28deg)" }} />
<Tape theme={theme} seed={1} scale={s} width={250} style={{ left: 680 * s, top: 20 * s, transform: "rotate(24deg)" }} />
</Reveal>}
- <div style={{ position: "absolute", left: 50 * s, right: 50 * s, top: (src ? (theme.surface === "none" ? 1250 : 1030) : 560) * s, display: "flex", flexDirection: "column", alignItems: "flex-start", gap: 36 * s }}>
+ <div style={{ position: "absolute", left: 50 * s, right: 50 * s, top: (src ? (theme.surface === "none" ? 990 : 1030) : 560) * s, display: "flex", flexDirection: "column", alignItems: "flex-start", gap: 36 * s }}>
<Reveal theme={theme} role="figure" f={f} at={nameAt} fps={fps} style={{ position: "relative", ...tilt(theme, -2) }}>
<Label theme={theme} seed={32} scale={s} size={(src ? 150 : 190) * s} ink={theme.color.figure} pad={0.18}>
<RevealText theme={theme} role="figure" f={f} at={nameAt} text={card.name} s={s} />
@@ -265,14 +267,14 @@ const BulletsPage: React.FC<PageProps<"bullets"> & { length: number }> = ({ card
const items = card.items.slice(0, 3).map(() => next("item"));
const lift = title ? 0 : 220;
const stocks = [theme.color.sheet, theme.color.stripAlt, theme.color.strip];
- const lefts = [50, 110, 70];
+ const lefts = theme.surface === "paper" ? [50, 110, 70] : [50, 50, 50];
return (
<Page theme={theme} s={s} f={f} length={length} inset={inset} k={k}
punch={{ at: items[0] ?? 0, zoom: 1.08, x: 480, y: 600 }}
shots={[{ at: 0, zoom: 1.3, x: 380, y: 290 }, { at: items[0] ?? 0, zoom: 1.3, x: 380, y: 290 }, { at: (items[0] ?? 0) + 12, zoom: 1, x: 540, y: 960 }]}>
{theme.surface === "paper" && (
<Paper theme={theme} seed={40} color={theme.color.stripAlt} scale={s} texture="kraft"
- style={{ position: "absolute", left: 300 * s, top: 420 * s, width: 900 * s, height: 1600 * s, ...tilt(theme, 3) }} />
+ style={{ position: "absolute", left: 300 * s, top: 420 * s, width: 900 * s, height: 860 * s, ...tilt(theme, 3) }} />
)}
{title && (
<Reveal theme={theme} role="title" f={f} at={titleAt} fps={fps} style={{ left: 50 * s, top: 200 * s, ...tilt(theme, -1) }}>
@@ -310,9 +312,10 @@ const QuotePage: React.FC<PageProps<"quote"> & { length: number }> = ({ card, th
shots={[{ at: 0, zoom: 1.15, x: 520, y: 620 }, { at: byAt - 4, zoom: 1.15, x: 520, y: 620 }, { at: byAt + 10, zoom: 1, x: 540, y: 960 }]}>
{theme.surface === "paper" && (
<Paper theme={theme} seed={60} color={theme.color.strip} scale={s} texture="kraft"
- style={{ position: "absolute", left: -80 * s, top: 700 * s, width: 820 * s, height: 1400 * s, ...tilt(theme, -3) }} />
+ style={{ position: "absolute", left: -80 * s, top: 700 * s, width: 820 * s, height: 600 * s, ...tilt(theme, -3) }} />
)}
- <Reveal theme={theme} role="title" f={f} at={textAt} fps={fps} style={{ left: 60 * s, top: 300 * s, width: 960 * s, ...tilt(theme, 1) }}>
+ <div style={{ position: "absolute", left: 60 * s, top: 300 * s, width: 960 * s, display: "flex", flexDirection: "column", alignItems: "flex-start", gap: 40 * s }}>
+ <Reveal theme={theme} role="title" f={f} at={textAt} fps={fps} style={{ position: "relative", width: "100%", ...tilt(theme, 1) }}>
<Paper theme={theme} seed={61} color={theme.color.sheet} scale={s}>
<div style={{ padding: `${40 * s}px ${70 * s}px ${90 * s}px` }}>
<div style={{ ...fontOf(theme.type.display, 300 * s), color: theme.color.accent, height: 170 * s, lineHeight: 1 }}>“</div>
@@ -324,10 +327,11 @@ const QuotePage: React.FC<PageProps<"quote"> & { length: number }> = ({ card, th
<Tape theme={theme} seed={2} scale={s} width={280} style={{ left: 340 * s, top: -30 * s, transform: "rotate(-4deg)" }} />
</Reveal>
{card.attribution && (
- <Reveal theme={theme} role="label" f={f} at={byAt} fps={fps} style={{ left: 120 * s, top: 1110 * s, ...tilt(theme, -2) }}>
+ <Reveal theme={theme} role="label" f={f} at={byAt} fps={fps} style={{ position: "relative", marginLeft: 60 * s, ...tilt(theme, -2) }}>
<Label theme={theme} seed={62} scale={s} size={64 * s}>{card.attribution}</Label>
</Reveal>
)}
+ </div>
</Page>
);
};
@@ -362,7 +366,7 @@ const CompareRows: React.FC<PageProps<"compare"> & { length: number }> = ({ card
<div style={{ display: "flex", alignItems: "center", gap: 18 * s }}>
<div style={{ width: `${Math.max(10, (row.value / top) * 70)}%` }}>
<Bar theme={theme} seed={82 + i} s={s} height={76}
- color={row.subject ? theme.color.accent : theme.surface === "none" ? theme.color.muted : theme.color.stripAlt} />
+ color={row.subject ? theme.color.accent : theme.color.muted} />
</div>
<div style={{ ...fontOf(theme.type.label, 76 * s), fontWeight: 700,
color: row.subject && theme.surface === "none" ? theme.color.accent : theme.color.ink }}>
diff --git a/remotion/src/style/theme.ts b/remotion/src/style/theme.ts
index 765678e..cea134f 100644
--- a/remotion/src/style/theme.ts
+++ b/remotion/src/style/theme.ts
@@ -345,7 +345,7 @@ const terminal: Theme = {
figure: "#3DDC84",
},
type: {
- display: face("Courier Prime", 400, { tracking: -1, lineHeight: 1.08 }),
+ display: face("Courier Prime", 400, { tracking: -1.5, lineHeight: 1.08, size: 0.78 }),
label: face("Courier Prime", 400, { tracking: 0, lineHeight: 1.2 }),
mono: face("Courier Prime", 400, { lineHeight: 1.45 }),
caption: 56,
@@ -414,7 +414,7 @@ export const fontOf = (f: Face, size: number): React.CSSProperties => ({
fontFamily: f.family,
fontWeight: f.weight,
fontStyle: f.italic ? "italic" : "normal",
- fontSize: size,
- letterSpacing: (f.tracking ?? 0) * (size / 60),
+ fontSize: size * (f.size ?? 1),
+ letterSpacing: (f.tracking ?? 0) * ((size * (f.size ?? 1)) / 60),
lineHeight: f.lineHeight ?? 1.2,
});