Spaces:
Runtime error
Runtime error
Download components/ControlsPanel.tsx from richuj/tile-room-visualizer: direct link, hf CLI and curl.
- Browser
- Download file 1.82 kB
-
https://huggingface.co/spaces/richuj/tile-room-visualizer/resolve/main/components/ControlsPanel.tsx
- Command line
-
hf download hf://spaces/richuj/tile-room-visualizer/components/ControlsPanel.tsx
-
curl -L -o ControlsPanel.tsx https://huggingface.co/spaces/richuj/tile-room-visualizer/resolve/main/components/ControlsPanel.tsx
1.82 kB
| "use client"; | |
| import type { VisualizerControls } from "@/lib/types"; | |
| type ControlsPanelProps = { | |
| controls: VisualizerControls; | |
| onChange: (controls: VisualizerControls) => void; | |
| }; | |
| const controlFields = [ | |
| { key: "scale", label: "Tile Scale", min: 0.25, max: 2.5, step: 0.05 }, | |
| { key: "opacity", label: "Blend Opacity", min: 0.1, max: 1, step: 0.01 }, | |
| { key: "rotation", label: "Rotation", min: -90, max: 90, step: 1 }, | |
| ] satisfies Array<{ | |
| key: keyof VisualizerControls; | |
| label: string; | |
| min: number; | |
| max: number; | |
| step: number; | |
| }>; | |
| export function ControlsPanel({ controls, onChange }: ControlsPanelProps) { | |
| return ( | |
| <section className="panel-section"> | |
| <div className="section-heading"> | |
| <h2>Adjustments</h2> | |
| </div> | |
| <div className="controls-stack"> | |
| {controlFields.map((field) => ( | |
| <label className="range-field" key={field.key}> | |
| <div className="range-header"> | |
| <span className="range-label">{field.label}</span> | |
| <span className="range-value"> | |
| {formatValue(field.key, controls[field.key])} | |
| </span> | |
| </div> | |
| <input | |
| max={field.max} | |
| min={field.min} | |
| onChange={(event) => | |
| onChange({ | |
| ...controls, | |
| [field.key]: Number(event.target.value), | |
| }) | |
| } | |
| step={field.step} | |
| type="range" | |
| value={controls[field.key]} | |
| /> | |
| </label> | |
| ))} | |
| </div> | |
| </section> | |
| ); | |
| } | |
| function formatValue(key: keyof VisualizerControls, value: number) { | |
| if (key === "opacity") return `${Math.round(value * 100)}%`; | |
| if (key === "rotation") return `${value}°`; | |
| return `${value.toFixed(2)}×`; | |
| } | |