Skip to content

armgit / Cap

Public Imported from GitHub
0

Open source Loom alternative. Beautiful, shareable screen recordings.

perf: defer studio demo visuals until visible

Richie McIlroy7f8b37c2758a
diff --git a/apps/web/components/pages/HomeTwo/studio/StudioFeatures.tsx b/apps/web/components/pages/HomeTwo/studio/StudioFeatures.tsx
index b82431c15..91b48d8a6 100644
--- a/apps/web/components/pages/HomeTwo/studio/StudioFeatures.tsx
+++ b/apps/web/components/pages/HomeTwo/studio/StudioFeatures.tsx
@@ -13,8 +13,7 @@ import {
meshStyle,
} from "../theme";
import { useInView, useReducedMotion } from "../visibility";
-import { CARDS_A } from "./cardsA";
-import { CARDS_B } from "./cardsB";
+import { CARDS_A, CARDS_B } from "./catalog";
import { CANVAS, type StudioCard } from "./shared";
const ORDER = [
diff --git a/apps/web/components/pages/HomeTwo/studio/cardsA.tsx b/apps/web/components/pages/HomeTwo/studio/cardsA.tsx
index f0206bff8..a6571e326 100644
--- a/apps/web/components/pages/HomeTwo/studio/cardsA.tsx
+++ b/apps/web/components/pages/HomeTwo/studio/cardsA.tsx
@@ -23,7 +23,6 @@ import {
Chip,
RECORDED,
RecordedWindow,
- type StudioCard,
useLoop,
} from "./shared";
@@ -79,7 +78,7 @@ const maskUiAt = (t: number) => ({
: null,
});
-const BlurVisual = ({ playing }: { playing: boolean }) => {
+export const BlurVisual = ({ playing }: { playing: boolean }) => {
const rootRef = useRef<HTMLDivElement | null>(null);
const boxRef = useRef<HTMLDivElement | null>(null);
const [ui, setUi] = useSceneState(maskUiAt(0));
@@ -364,7 +363,7 @@ const sceneAt = (t: number): SceneKey =>
SCENE_MODES[Math.min(SCENE_MODES.length - 1, Math.floor(t / SCENE_SLOT))]
?.key ?? "default";
-const ScenesVisual = ({ playing }: { playing: boolean }) => {
+export const ScenesVisual = ({ playing }: { playing: boolean }) => {
const playheadRef = useRef<HTMLDivElement | null>(null);
const [scene, setScene] = useSceneState<SceneKey>("default");
const scrollRef = useRef<HTMLDivElement | null>(null);
@@ -464,7 +463,7 @@ const textPresetAt = (t: number) =>
? "Lower Third · Slide up"
: null;
-const TextVisual = ({ playing }: { playing: boolean }) => {
+export const TextVisual = ({ playing }: { playing: boolean }) => {
const lowerRef = useRef<HTMLDivElement | null>(null);
const statRef = useRef<HTMLDivElement | null>(null);
const typeRef = useRef<HTMLDivElement | null>(null);
@@ -579,7 +578,7 @@ const zoomScaleAt = (t: number) =>
easeInOut(span(t, ZOOM_IN.start, ZOOM_IN.end)) -
easeInOut(span(t, ZOOM_OUT.start, ZOOM_OUT.end));
-const ZoomVisual = ({ playing }: { playing: boolean }) => {
+export const ZoomVisual = ({ playing }: { playing: boolean }) => {
const rootRef = useRef<HTMLDivElement | null>(null);
const zoomRef = useRef<HTMLDivElement | null>(null);
const ringRef = useRef<HTMLSpanElement | null>(null);
@@ -699,7 +698,7 @@ const captionAt = (t: number) => {
};
};
-const CaptionsVisual = ({ playing }: { playing: boolean }) => {
+export const CaptionsVisual = ({ playing }: { playing: boolean }) => {
const rootRef = useRef<HTMLDivElement | null>(null);
const clockRef = useRef<HTMLSpanElement | null>(null);
const [ui, setUi] = useSceneState(captionAt(0));
@@ -794,38 +793,3 @@ const CaptionsVisual = ({ playing }: { playing: boolean }) => {
</div>
);
};
-
-export const CARDS_A: StudioCard[] = [
- {
- key: "mask",
- title: "Blur what is private",
- body: "Drop a mask over a password, an email, or a face and choose blur or pixelate. Or flip it to a highlight that dims everything else.",
- span: 2,
- Visual: BlurVisual,
- },
- {
- key: "scenes",
- title: "Scenes for screen and camera",
- body: "Switch any stretch of the timeline to camera only, hide camera, split screen, or floating cards, each with its own transition.",
- span: 2,
- Visual: ScenesVisual,
- },
- {
- key: "text",
- title: "Text that animates",
- body: "Titles, lower thirds, big stats, and typewriter callouts as stackable tracks, with fade, slide, pop, or typewriter in and out.",
- Visual: TextVisual,
- },
- {
- key: "zoom",
- title: "Automatic zoom",
- body: "Generate zooms from your recorded clicks, or draw your own from 1x to 4.5x with a fixed focal point.",
- Visual: ZoomVisual,
- },
- {
- key: "captions",
- title: "Captions, generated locally",
- body: "Transcribe on your machine in 19 languages, fix the words, style them, and burn them in with the active word highlighted.",
- Visual: CaptionsVisual,
- },
-];
diff --git a/apps/web/components/pages/HomeTwo/studio/cardsB.tsx b/apps/web/components/pages/HomeTwo/studio/cardsB.tsx
index b13bcad03..fba77bafb 100644
--- a/apps/web/components/pages/HomeTwo/studio/cardsB.tsx
+++ b/apps/web/components/pages/HomeTwo/studio/cardsB.tsx
@@ -18,7 +18,6 @@ import {
Chip,
RECORDED,
RecordedWindow,
- type StudioCard,
useLoop,
} from "./shared";
@@ -67,7 +66,7 @@ const threeDPoseAt = (t: number) => {
};
};
-const ThreeDVisual = ({ playing }: { playing: boolean }) => {
+export const ThreeDVisual = ({ playing }: { playing: boolean }) => {
const groupRef = useRef<HTMLDivElement | null>(null);
const depthRef = useRef<HTMLDivElement | null>(null);
const vignetteRef = useRef<HTMLDivElement | null>(null);
@@ -205,7 +204,7 @@ const canvasScaleAt = (t: number) => {
return { s, r };
};
-const CanvasVisual = ({ playing }: { playing: boolean }) => {
+export const CanvasVisual = ({ playing }: { playing: boolean }) => {
const groupRef = useRef<HTMLDivElement | null>(null);
const clipRef = useRef<HTMLDivElement | null>(null);
const [ui, setUi] = useSceneState(canvasUiAt(0));
@@ -446,7 +445,7 @@ const gradeAt = (t: number) => {
return current;
};
-const GradesVisual = ({ playing }: { playing: boolean }) => {
+export const GradesVisual = ({ playing }: { playing: boolean }) => {
const rootRef = useRef<HTMLDivElement | null>(null);
const [ui, setUi] = useSceneState({ grade: NONE_GRADE.name });
const cursor = useCursor(rootRef);
@@ -611,7 +610,7 @@ const CLIPS_PATH: Way[] = [
{ t: CLIPS_DURATION, x: 470, y: 150 },
];
-const ClipsVisual = ({ playing }: { playing: boolean }) => {
+export const ClipsVisual = ({ playing }: { playing: boolean }) => {
const rootRef = useRef<HTMLDivElement | null>(null);
const clipARef = useRef<HTMLDivElement | null>(null);
const clipBRef = useRef<HTMLDivElement | null>(null);
@@ -850,32 +849,3 @@ const ClipsVisual = ({ playing }: { playing: boolean }) => {
</div>
);
};
-
-/* --------------------------------------------------------------- export -- */
-
-export const CARDS_B: StudioCard[] = [
- {
- key: "three-d",
- title: "3D camera moves",
- body: "Tilt the frame into perspective and glide, sweep, or pull back across it with focus blur.",
- Visual: ThreeDVisual,
- },
- {
- key: "canvas",
- title: "Any canvas, one recording",
- body: "Wallpapers, gradients, or your own image, then padding, corners, shadows, and a macOS, Windows, browser, or MacBook frame.",
- Visual: CanvasVisual,
- },
- {
- key: "grades",
- title: "Color grades",
- body: "Cinematic, Noir, Vintage, Frost, Golden, Midnight, Vivid, or Dreamy, then dial exposure, contrast, and vignette.",
- Visual: GradesVisual,
- },
- {
- key: "clips",
- title: "Clips, speed, and music",
- body: "Trim, split, reorder, speed up to 8x, crossfade between clips, and lay a track from the built in library underneath.",
- Visual: ClipsVisual,
- },
-];
diff --git a/apps/web/components/pages/HomeTwo/studio/catalog.ts b/apps/web/components/pages/HomeTwo/studio/catalog.ts
new file mode 100644
index 000000000..ef5d8234e
--- /dev/null
+++ b/apps/web/components/pages/HomeTwo/studio/catalog.ts
@@ -0,0 +1,84 @@
+"use client";
+
+import dynamic from "next/dynamic";
+import type { StudioCard } from "./shared";
+
+export const CARDS_A: StudioCard[] = [
+ {
+ key: "mask",
+ title: "Blur what is private",
+ body: "Drop a mask over a password, an email, or a face and choose blur or pixelate. Or flip it to a highlight that dims everything else.",
+ span: 2,
+ Visual: dynamic(() =>
+ import("./cardsA").then((module) => module.BlurVisual),
+ ),
+ },
+ {
+ key: "scenes",
+ title: "Scenes for screen and camera",
+ body: "Switch any stretch of the timeline to camera only, hide camera, split screen, or floating cards, each with its own transition.",
+ span: 2,
+ Visual: dynamic(() =>
+ import("./cardsA").then((module) => module.ScenesVisual),
+ ),
+ },
+ {
+ key: "text",
+ title: "Text that animates",
+ body: "Titles, lower thirds, big stats, and typewriter callouts as stackable tracks, with fade, slide, pop, or typewriter in and out.",
+ Visual: dynamic(() =>
+ import("./cardsA").then((module) => module.TextVisual),
+ ),
+ },
+ {
+ key: "zoom",
+ title: "Automatic zoom",
+ body: "Generate zooms from your recorded clicks, or draw your own from 1x to 4.5x with a fixed focal point.",
+ Visual: dynamic(() =>
+ import("./cardsA").then((module) => module.ZoomVisual),
+ ),
+ },
+ {
+ key: "captions",
+ title: "Captions, generated locally",
+ body: "Transcribe on your machine in 19 languages, fix the words, style them, and burn them in with the active word highlighted.",
+ Visual: dynamic(() =>
+ import("./cardsA").then((module) => module.CaptionsVisual),
+ ),
+ },
+];
+
+export const CARDS_B: StudioCard[] = [
+ {
+ key: "three-d",
+ title: "3D camera moves",
+ body: "Tilt the frame into perspective and glide, sweep, or pull back across it with focus blur.",
+ Visual: dynamic(() =>
+ import("./cardsB").then((module) => module.ThreeDVisual),
+ ),
+ },
+ {
+ key: "canvas",
+ title: "Any canvas, one recording",
+ body: "Wallpapers, gradients, or your own image, then padding, corners, shadows, and a macOS, Windows, browser, or MacBook frame.",
+ Visual: dynamic(() =>
+ import("./cardsB").then((module) => module.CanvasVisual),
+ ),
+ },
+ {
+ key: "grades",
+ title: "Color grades",
+ body: "Cinematic, Noir, Vintage, Frost, Golden, Midnight, Vivid, or Dreamy, then dial exposure, contrast, and vignette.",
+ Visual: dynamic(() =>
+ import("./cardsB").then((module) => module.GradesVisual),
+ ),
+ },
+ {
+ key: "clips",
+ title: "Clips, speed, and music",
+ body: "Trim, split, reorder, speed up to 8x, crossfade between clips, and lay a track from the built in library underneath.",
+ Visual: dynamic(() =>
+ import("./cardsB").then((module) => module.ClipsVisual),
+ ),
+ },
+];