Skip to content

armgit / Cap

Public Imported from GitHub
0

Open source Loom alternative. Beautiful, shareable screen recordings.

refactor(web): drop lint suppressions from homepage demos

Richie McIlroycba6822bea80
diff --git a/apps/web/components/pages/HomeTwo/Hero.tsx b/apps/web/components/pages/HomeTwo/Hero.tsx
index d5b129419..32388f4ac 100644
--- a/apps/web/components/pages/HomeTwo/Hero.tsx
+++ b/apps/web/components/pages/HomeTwo/Hero.tsx
@@ -35,22 +35,20 @@ const PhoneStage = () => {
className="rounded-[22px] p-2.5"
style={meshStyle(MODE_THEME.instant)}
>
- <Fit w={PHONE_STAGE.w} h={PHONE_STAGE.h} className="mx-auto" eager>
+ <Fit w={PHONE_STAGE.w} h={PHONE_STAGE.h} className="mx-auto">
<div
className="relative overflow-hidden rounded-[14px] bg-black"
style={{ width: PHONE_STAGE.w, height: PHONE_STAGE.h }}
>
- {/* A 960px copy (40 KB): the stage is scaled to phone width, so the
- 1920px variant next/image picked on dense screens was wasted. */}
- {/* biome-ignore lint/performance/noImgElement: pre-sized static asset */}
- <img
+ {/* The stage is scaled down to phone width, so a pre-sized 960px
+ copy beats the 1920px variant next/image picks on dense screens. */}
+ <Image
src="/backgrounds/landing/sf-960.webp"
alt=""
- width={960}
- height={540}
- decoding="async"
+ fill
+ unoptimized
draggable={false}
- className="absolute inset-0 size-full object-cover"
+ className="object-cover"
/>
<MenuBar recording={false} onSwitchOs={noop} />
<div className="absolute z-20" style={{ left: 48, top: 30 }}>
diff --git a/apps/web/components/pages/HomeTwo/scenes/engine.tsx b/apps/web/components/pages/HomeTwo/scenes/engine.tsx
index d499142a5..a24681688 100644
--- a/apps/web/components/pages/HomeTwo/scenes/engine.tsx
+++ b/apps/web/components/pages/HomeTwo/scenes/engine.tsx
@@ -360,7 +360,6 @@ export const Scaled = ({
style,
inert: isInert,
grow,
- eager,
children,
}: {
w: number;
@@ -369,11 +368,6 @@ export const Scaled = ({
style?: React.CSSProperties;
inert?: boolean;
grow?: boolean;
- /**
- * Above the fold: size and reveal the content with a tiny inline script
- * as the HTML parses, instead of waiting for hydration to measure it.
- */
- eager?: boolean;
children: ReactNode;
}) => {
const boxRef = useRef<HTMLDivElement | null>(null);
@@ -391,17 +385,13 @@ export const Scaled = ({
}, [w, grow]);
const s = scale ?? 1;
- const box = (
+ return (
<div
ref={boxRef}
aria-hidden="true"
inert={isInert}
- data-fit-w={eager ? w : undefined}
- data-fit-grow={eager && grow ? "" : undefined}
- suppressHydrationWarning={eager}
className={classNames(
- "relative w-full select-none",
- !eager && "transition-opacity duration-500",
+ "relative w-full select-none transition-opacity duration-500",
scale === null ? "opacity-0" : "opacity-100",
isInert && "pointer-events-none",
className,
@@ -413,7 +403,6 @@ export const Scaled = ({
}}
>
<div
- suppressHydrationWarning={eager}
className="absolute left-0 top-0"
style={{
width: w,
@@ -426,28 +415,14 @@ export const Scaled = ({
</div>
</div>
);
- if (!eager) return box;
- return (
- <>
- {box}
- <script
- // biome-ignore lint/security/noDangerouslySetInnerHtml: static sizing snippet, no user input
- dangerouslySetInnerHTML={{ __html: EAGER_FIT_SCRIPT }}
- />
- </>
- );
};
-/** Runs right after its box is parsed: same maths as the layout effect. */
-const EAGER_FIT_SCRIPT = `(function(s){var b=s&&s.previousElementSibling;if(!b)return;var w=+b.getAttribute("data-fit-w");var c=b.clientWidth;var k=b.hasAttribute("data-fit-grow")?c/w:Math.min(1,c/w);var i=b.firstElementChild;if(i)i.style.transform="scale("+k+")";b.style.opacity="1";})(document.currentScript)`;
-
export const Fit = ({
w,
h,
className,
still,
grow,
- eager,
children,
}: {
w: number;
@@ -455,7 +430,6 @@ export const Fit = ({
className?: string;
still?: boolean;
grow?: boolean;
- eager?: boolean;
children: ReactNode;
}) => (
<SceneMediaProvider value={{ still: Boolean(still) }}>
@@ -464,7 +438,6 @@ export const Fit = ({
h={h}
inert
grow={grow}
- eager={eager}
className={classNames(htGeist.variable, className)}
style={{
fontFamily:
diff --git a/apps/web/components/pages/HomeTwo/showcase/instant.tsx b/apps/web/components/pages/HomeTwo/showcase/instant.tsx
index c5dba81c9..a43d77f39 100644
--- a/apps/web/components/pages/HomeTwo/showcase/instant.tsx
+++ b/apps/web/components/pages/HomeTwo/showcase/instant.tsx
@@ -37,10 +37,8 @@ const SCREEN = { w: 800, h: 478 } as const;
const SCREEN_LEFT = (CANVAS.w - SCREEN.w) / 2;
const SCREEN_TOP = 26;
-/** Height of the Windows taskbar along the bottom of the desktop. */
const TASKBAR = 40;
-/** How far the desktop's usable area stops short of the bottom edge. */
const useFloor = () => (useIsWindowsDemo() ? TASKBAR : 0);
const Taskbar = () => (
@@ -144,11 +142,11 @@ const formatClock = (ms: number) => {
const CHUNK_MS = 2000;
const CHUNKS = 10;
+const CHUNK_SLOTS = Array.from({ length: CHUNKS }, (_, i) => ({
+ id: `chunk-${i}`,
+ index: i,
+}));
-/**
- * The share link, live while you are still talking: its video length keeps
- * pace with the recorder's timer, two seconds at a time.
- */
const LiveLink = ({
elapsed,
playing,
@@ -174,13 +172,12 @@ const LiveLink = ({
</span>
</div>
<div className="flex gap-[3px] px-3 pt-2.5">
- {Array.from({ length: CHUNKS }, (_, i) => {
- const done = i < landed;
- const sending = i === landed;
+ {CHUNK_SLOTS.map(({ id, index }) => {
+ const done = index < landed;
+ const sending = index === landed;
return (
<span
- // biome-ignore lint/suspicious/noArrayIndexKey: fixed row of chunk slots
- key={i}
+ key={id}
className="h-1.5 flex-1 rounded-full transition-colors duration-300"
style={{
background: done ? "#3B82F6" : sending ? "#BFDBFE" : "#EEF1F5",
@@ -201,7 +198,6 @@ const LiveLink = ({
const RECORD_SCALE = 0.78;
-// Record: the recorder counts up and the share link fills in alongside it.
const RecordView = ({ t, playing }: { t: number; playing: boolean }) => {
const elapsed = 8000 + t;
const cursor = {
@@ -252,7 +248,6 @@ const RecordView = ({ t, playing }: { t: number; playing: boolean }) => {
);
};
-/** "Link copied", as a macOS banner (top right) or a Windows toast. */
const Notification = ({ k }: { k: number }) => {
const windows = useIsWindowsDemo();
if (windows) {
@@ -404,7 +399,6 @@ const ChatWindow = ({
);
};
-// Stop: click stop, the link lands on the clipboard, paste it into chat.
const ShareView = ({ t, playing }: { t: number; playing: boolean }) => {
const toolbarX = SCREEN.w / 2 - 110;
const floor = useFloor();
diff --git a/apps/web/components/pages/HomeTwo/showcase/ownership.tsx b/apps/web/components/pages/HomeTwo/showcase/ownership.tsx
index 1e85906d9..d9893f013 100644
--- a/apps/web/components/pages/HomeTwo/showcase/ownership.tsx
+++ b/apps/web/components/pages/HomeTwo/showcase/ownership.tsx
@@ -1,6 +1,7 @@
"use client";
import { Check, Server } from "lucide-react";
+import Image from "next/image";
import type { ReactNode } from "react";
import { CapLogoMark } from "../demo/capIcons";
import { copyOf, STORAGE_COPY } from "./copy";
@@ -59,13 +60,15 @@ const DESTINATIONS: Destination[] = [
path: "My Drive / Cap",
note: "A folder your team already uses",
icon: (
- // biome-ignore lint/performance/noImgElement: tiny static svg
- <img src="/logos/google-drive.svg" alt="" className="size-7" />
- ),
- tab: (
- // biome-ignore lint/performance/noImgElement: tiny static svg
- <img src="/logos/google-drive.svg" alt="" />
+ <Image
+ src="/logos/google-drive.svg"
+ alt=""
+ width={28}
+ height={28}
+ className="size-7"
+ />
),
+ tab: <Image src="/logos/google-drive.svg" alt="" width={16} height={16} />,
lead: copyOf(STORAGE_COPY, "drive").lead,
body: copyOf(STORAGE_COPY, "drive").body,
},
@@ -86,7 +89,6 @@ const FILE = { x: 96, y: 96, w: 312, h: 236 };
const DEST = { x: 632, y: 132, w: 312, h: 164 };
const ACCENT = TONES.storage.accent;
-/** A soft dot grid, so the stage reads as a canvas rather than empty space. */
const DOTS = {
backgroundImage:
"radial-gradient(circle at 1px 1px, rgba(17,17,17,0.09) 1px, transparent 0)",
diff --git a/apps/web/components/pages/HomeTwo/showcase/studio.tsx b/apps/web/components/pages/HomeTwo/showcase/studio.tsx
index 30c46f529..d3de0d2ab 100644
--- a/apps/web/components/pages/HomeTwo/showcase/studio.tsx
+++ b/apps/web/components/pages/HomeTwo/showcase/studio.tsx
@@ -33,7 +33,6 @@ import {
Webcam,
} from "./subjects";
-/** The exported video, centred on the stage above the tabs. */
const FRAME = { w: 744, h: 465 } as const;
const FRAME_LEFT = (CANVAS.w - FRAME.w) / 2;
const FRAME_TOP = 36;
@@ -59,7 +58,6 @@ const Frame = ({
</div>
);
-/** Where the recording sits inside the frame for a given padding (px). */
const fitRecording = (pad: number) => {
const scale = Math.min(
(FRAME.w - pad * 2) / INVOICE.w,
@@ -117,7 +115,6 @@ const Recording = ({
);
};
-/** Maps a point on the invoice page to frame coordinates. */
const toFrame = (pad: number, x: number, y: number) => {
const box = fitRecording(pad);
return { x: box.left + x * box.scale, y: box.top + y * box.scale };
@@ -336,7 +333,6 @@ const ScenesView = ({
);
};
-/** Little diagrams of each layout for the picker. */
const LayoutGlyph = ({ kind }: { kind: number }) => (
<svg aria-hidden="true" viewBox="0 0 24 18" className="h-[15px] w-5">
<rect
@@ -399,7 +395,6 @@ const LayoutGlyph = ({ kind }: { kind: number }) => (
</svg>
);
-// Short phrases, like the editor splits them, so a caption never wraps.
const LINES = [
"So this is the new invoice flow.",
"Pick the client,",
@@ -423,8 +418,6 @@ const timeline = (() => {
})();
const CAPTIONS_END = (timeline.at(-1)?.at(-1)?.start ?? 0) + 1600;
-// Captions in the editor's default style: bold white on a near-black box,
-// bottom centre, each word bouncing in as it is spoken.
const CaptionsView = ({ t, playing }: { t: number; playing: boolean }) => {
const lineIndex = Math.max(
0,
@@ -483,14 +476,16 @@ const Mosaic = ({ w, h }: { w: number; h: number }) => {
const tones = ["#C9CDD4", "#E3E6EA", "#AEB3BC", "#D6D9DE", "#9CA2AC"];
return (
<div className="absolute inset-0 flex flex-wrap">
- {Array.from({ length: rows * cols }, (_, n) => (
+ {Array.from({ length: rows * cols }, (_, n) => ({
+ id: `cell-${n}`,
+ tone: tones[(((n * 2654435761) >>> 0) % 97) % tones.length],
+ })).map((cell) => (
<span
- // biome-ignore lint/suspicious/noArrayIndexKey: static grid
- key={n}
+ key={cell.id}
style={{
width: size,
height: size,
- background: tones[(((n * 2654435761) >>> 0) % 97) % tones.length],
+ background: cell.tone,
}}
/>
))}
@@ -506,7 +501,6 @@ const BlurView = ({ t }: { t: number; playing: boolean }) => {
const modeIndex = t < 3200 ? 0 : t < 5200 ? 1 : 2;
const mode = MASK_MODES[modeIndex] ?? "Blur";
const blurAmount = seg(t, 1400, 1900) * 7;
- // Mask rect in frame coordinates.
const x = box.left + (email.x - 6) * box.scale;
const y = box.top + (email.y - 6) * box.scale;
const fullW = (email.w + 12) * box.scale;