Clip timeline
Trim a field recording from either end and see the length of the selected clip.
Installation
Use a React 19 project with shadcn configured. Render the installed components inside the Cyber root, and import your global stylesheet in the app entry point.
bunx --bun shadcn@latest add https://www.cyberspec.dev/r/clip-timeline.json
Usage
import { Cyber } from "@/components/ui/cyber"
import Recipe from "@/components/recipes/clip-timeline"
export default function App() {
return (
<Cyber>
<Recipe />
</Cyber>
)
}
Source
"use client"
import "./recipe-layout.css"
import { useState } from "react"
import { Readout } from "@/components/ui/readout"
import { Slider } from "@/components/ui/slider"
const duration = 60
const samples = Array.from({ length: duration }, (_, i) => 12 + 88 * Math.abs(Math.sin(i * 0.43) * Math.cos(i * 0.19)))
export default function ClipTimeline() {
const [range, setRange] = useState([8, 42])
const [start, end] = range
return (
<div className="sink-stack">
<div className="sink-between"><strong>Night train.wav</strong><span className="sink-label">1:00</span></div>
<div aria-hidden="true" style={{ display: "flex", alignItems: "center", gap: 1, height: 64, paddingBlock: 6, backgroundColor: "var(--cy-panel)", borderBlock: "1px solid var(--cy-line-deco)" }}>
{samples.map((height, i) => <span key={i} style={{ flex: "1 1 0", height: `${height}%`, backgroundColor: i >= start && i < end ? "var(--cy-signal)" : "var(--cy-line-ctl)" }} />)}
</div>
<Slider label="Trim points" thumbLabels={["Clip start", "Clip end"]} value={range} onValueChange={setRange} min={0} max={duration} ticks={12} format={(value) => `${value}s`} />
<Readout label="Selected duration" value={end - start} unit="s" size="sm" />
</div>
)
}