Skip to content

Open source CapCut alternative.

TypeScript

feat(site): show the Spotify vision compare slider in the CTA

David Le5f478c4f459b
diff --git a/site/src/app/_components/landing/DonkeyVisionCTA.tsx b/site/src/app/_components/landing/DonkeyVisionCTA.tsx
index c7cdeb54..3b7c524b 100644
--- a/site/src/app/_components/landing/DonkeyVisionCTA.tsx
+++ b/site/src/app/_components/landing/DonkeyVisionCTA.tsx
@@ -1,26 +1,14 @@
"use client";
-import { Boxes, Crosshair, Gauge } from "lucide-react";
-
import {
Headline,
PillButton,
} from "@/app/_components/landing/LandingPrimitives";
+import { VisionCompareSlider } from "@/app/donkeyvision/VisionCompareSlider";
+import { VISION_DATASETS } from "@/app/donkeyvision/visionData";
-const points = [
- {
- icon: Boxes,
- text: "Detect interactable elements from screenshots.",
- },
- {
- icon: Crosshair,
- text: "Ground requests like find the play button or find the next button.",
- },
- {
- icon: Gauge,
- text: "Built for low-latency agent loops.",
- },
-];
+const spotify =
+ VISION_DATASETS.find((d) => d.key === "spotify") ?? VISION_DATASETS[0];
export function DonkeyVisionCTA() {
return (
@@ -29,9 +17,7 @@ export function DonkeyVisionCTA() {
<div className="absolute inset-0 translate-x-2 translate-y-2 rounded-2xl bg-[#A8D5E8]" />
<div className="relative grid gap-8 rounded-2xl border-2 border-[#0F0E0D] bg-[#0F0E0D] p-8 text-white md:grid-cols-[minmax(0,1fr)_minmax(320px,0.56fr)] md:p-12">
<div className="min-w-0">
- <Headline size="lg">
- Building computer-use agents?
- </Headline>
+ <Headline size="lg">Building computer-use agents?</Headline>
<p className="mt-6 max-w-2xl text-lg leading-8 text-white/75">
Give your agent a fast, structured map of any software screenshot.
Donkey Vision returns elements, boxes, labels, and target points so
@@ -44,24 +30,11 @@ export function DonkeyVisionCTA() {
</PillButton>
</div>
</div>
- <div className="grid content-center gap-4">
- {points.map((point) => {
- const Icon = point.icon;
-
- return (
- <div
- className="flex items-start gap-4 rounded-lg border-2 border-white/20 bg-white p-4 text-[#0F0E0D]"
- key={point.text}
- >
- <div className="flex h-11 w-11 shrink-0 items-center justify-center rounded-md border-2 border-[#0F0E0D] bg-[#F5D875]">
- <Icon size={20} aria-hidden="true" />
- </div>
- <p className="m-0 text-sm font-semibold leading-6">
- {point.text}
- </p>
- </div>
- );
- })}
+ <div className="grid content-center gap-3">
+ <VisionCompareSlider dataset={spotify} />
+ <p className="m-0 text-center text-xs font-medium text-white/60">
+ Drag to compare — raw screenshot vs. detected controls.
+ </p>
</div>
</div>
</div>
diff --git a/site/src/app/donkeyvision/VisionCompareSection.tsx b/site/src/app/donkeyvision/VisionCompareSection.tsx
index 401b744c..e8eef6e6 100644
--- a/site/src/app/donkeyvision/VisionCompareSection.tsx
+++ b/site/src/app/donkeyvision/VisionCompareSection.tsx
@@ -1,29 +1,16 @@
"use client";
-import { ChevronLeft, ChevronRight } from "lucide-react";
-import Image from "next/image";
-import { useCallback, useRef, useState } from "react";
+import { useState } from "react";
-import { VisionOverlay } from "@/app/donkeyvision/VisionOverlay";
+import { VisionCompareSlider } from "@/app/donkeyvision/VisionCompareSlider";
import { VISION_DATASETS } from "@/app/donkeyvision/visionData";
export function VisionCompareSection() {
const [activeKey, setActiveKey] = useState(VISION_DATASETS[0].key);
- const [pos, setPos] = useState(50);
- const frameRef = useRef<HTMLDivElement>(null);
- const dragging = useRef(false);
const active =
VISION_DATASETS.find((d) => d.key === activeKey) ?? VISION_DATASETS[0];
- const moveTo = useCallback((clientX: number) => {
- const frame = frameRef.current;
- if (!frame) return;
- const rect = frame.getBoundingClientRect();
- const ratio = (clientX - rect.left) / rect.width;
- setPos(Math.min(100, Math.max(0, ratio * 100)));
- }, []);
-
return (
<section
id="demo"
@@ -40,60 +27,7 @@ export function VisionCompareSection() {
</p>
<div className="relative mt-10">
- <div className="relative overflow-hidden rounded-lg border-2 border-[#0F0E0D] bg-[#FAF6EC]">
- <div className="flex items-center justify-between border-b-2 border-[#0F0E0D] bg-white px-4 py-[9px]">
- <div className="flex items-center gap-2">
- <span className="h-3 w-3 rounded-full border-2 border-[#0F0E0D] bg-[#EC7868]" />
- <span className="h-3 w-3 rounded-full border-2 border-[#0F0E0D] bg-[#F5D875]" />
- <span className="h-3 w-3 rounded-full border-2 border-[#0F0E0D] bg-[#B7E4C7]" />
- </div>
- <span className="text-[10px] font-semibold">{active.title}</span>
- </div>
-
- <div
- ref={frameRef}
- className="relative w-full touch-none select-none"
- style={{ aspectRatio: `${active.width} / ${active.height}` }}
- onPointerDown={(e) => {
- dragging.current = true;
- e.currentTarget.setPointerCapture(e.pointerId);
- moveTo(e.clientX);
- }}
- onPointerMove={(e) => {
- if (dragging.current) moveTo(e.clientX);
- }}
- onPointerUp={() => {
- dragging.current = false;
- }}
- >
- <Image
- src={active.image}
- alt={`${active.title} screenshot`}
- fill
- draggable={false}
- sizes="(max-width: 1100px) 100vw, 1100px"
- className="object-cover"
- />
- {/* Reveal the overlay only to the right of the handle. */}
- <div
- className="absolute inset-0"
- style={{ clipPath: `inset(0 0 0 ${pos}%)` }}
- >
- <VisionOverlay dataset={active} />
- </div>
-
- {/* Divider + handle. */}
- <div
- className="absolute inset-y-0 w-0.5 -translate-x-1/2 bg-[#007AFF]"
- style={{ left: `${pos}%` }}
- >
- <div className="absolute top-1/2 left-1/2 flex h-10 w-10 -translate-x-1/2 -translate-y-1/2 items-center justify-center rounded-full border-2 border-[#007AFF] bg-white">
- <ChevronLeft size={16} aria-hidden="true" />
- <ChevronRight size={16} aria-hidden="true" />
- </div>
- </div>
- </div>
- </div>
+ <VisionCompareSlider key={active.key} dataset={active} />
</div>
{/* Dataset buttons. */}
@@ -104,10 +38,7 @@ export function VisionCompareSection() {
<button
key={d.key}
type="button"
- onClick={() => {
- setActiveKey(d.key);
- setPos(50);
- }}
+ onClick={() => setActiveKey(d.key)}
aria-pressed={isActive}
className={`rounded-md border-2 border-[#0F0E0D] px-5 py-2.5 text-sm font-semibold transition-colors ${
isActive
diff --git a/site/src/app/donkeyvision/VisionCompareSlider.tsx b/site/src/app/donkeyvision/VisionCompareSlider.tsx
new file mode 100644
index 00000000..c8617aad
--- /dev/null
+++ b/site/src/app/donkeyvision/VisionCompareSlider.tsx
@@ -0,0 +1,84 @@
+"use client";
+
+import { ChevronLeft, ChevronRight } from "lucide-react";
+import Image from "next/image";
+import { useCallback, useRef, useState } from "react";
+
+import { VisionOverlay } from "@/app/donkeyvision/VisionOverlay";
+import type { VisionDataset } from "@/app/donkeyvision/visionData";
+
+// Drag-to-reveal compare widget: left is the raw screenshot, right is the same
+// pixels with detected controls boxed. Internal handle position resets whenever
+// the component remounts, so callers can pass a changing `key` to reset it.
+export function VisionCompareSlider({ dataset }: { dataset: VisionDataset }) {
+ const [pos, setPos] = useState(50);
+ const frameRef = useRef<HTMLDivElement>(null);
+ const dragging = useRef(false);
+
+ const moveTo = useCallback((clientX: number) => {
+ const frame = frameRef.current;
+ if (!frame) return;
+ const rect = frame.getBoundingClientRect();
+ const ratio = (clientX - rect.left) / rect.width;
+ setPos(Math.min(100, Math.max(0, ratio * 100)));
+ }, []);
+
+ return (
+ <div className="relative w-full max-w-full overflow-hidden rounded-lg border-2 border-[#0F0E0D] bg-[#FAF6EC]">
+ <div className="flex items-center justify-between border-b-2 border-[#0F0E0D] bg-white px-4 py-[9px]">
+ <div className="flex items-center gap-2">
+ <span className="h-3 w-3 rounded-full border-2 border-[#0F0E0D] bg-[#EC7868]" />
+ <span className="h-3 w-3 rounded-full border-2 border-[#0F0E0D] bg-[#F5D875]" />
+ <span className="h-3 w-3 rounded-full border-2 border-[#0F0E0D] bg-[#B7E4C7]" />
+ </div>
+ <span className="text-[10px] font-semibold text-[#0F0E0D]">
+ {dataset.title}
+ </span>
+ </div>
+
+ <div
+ ref={frameRef}
+ className="relative w-full touch-none select-none"
+ style={{ aspectRatio: `${dataset.width} / ${dataset.height}` }}
+ onPointerDown={(e) => {
+ dragging.current = true;
+ e.currentTarget.setPointerCapture(e.pointerId);
+ moveTo(e.clientX);
+ }}
+ onPointerMove={(e) => {
+ if (dragging.current) moveTo(e.clientX);
+ }}
+ onPointerUp={() => {
+ dragging.current = false;
+ }}
+ >
+ <Image
+ src={dataset.image}
+ alt={`${dataset.title} screenshot`}
+ fill
+ draggable={false}
+ sizes="(max-width: 1100px) 100vw, 1100px"
+ className="object-cover"
+ />
+ {/* Reveal the overlay only to the right of the handle. */}
+ <div
+ className="absolute inset-0"
+ style={{ clipPath: `inset(0 0 0 ${pos}%)` }}
+ >
+ <VisionOverlay dataset={dataset} />
+ </div>
+
+ {/* Divider + handle. */}
+ <div
+ className="absolute inset-y-0 w-0.5 -translate-x-1/2 bg-[#007AFF]"
+ style={{ left: `${pos}%` }}
+ >
+ <div className="absolute top-1/2 left-1/2 flex h-10 w-10 -translate-x-1/2 -translate-y-1/2 items-center justify-center rounded-full border-2 border-[#007AFF] bg-white">
+ <ChevronLeft size={16} aria-hidden="true" />
+ <ChevronRight size={16} aria-hidden="true" />
+ </div>
+ </div>
+ </div>
+ </div>
+ );
+}