Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 | 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x | 'use client'
import type { ReactNode } from 'react'
import * as Slider from '@radix-ui/react-slider'
import { useVisualDebugSafe } from '@/contexts/VisualDebugContext'
interface DebugSliderProps {
label: string
value: number
min: number
max: number
step?: number
onChange: (value: number) => void
/** Custom value formatter for display (e.g. toFixed(3) for floats) */
formatValue?: (value: number) => string
}
export function DebugSlider({
label,
value,
min,
max,
step = 1,
onChange,
formatValue,
}: DebugSliderProps) {
return (
<div data-element="debug-slider" style={{ display: 'flex', flexDirection: 'column', gap: 4 }}>
<div
style={{ display: 'flex', justifyContent: 'space-between', fontSize: 11, fontWeight: 500 }}
>
<span>{label}</span>
<span style={{ fontVariantNumeric: 'tabular-nums', opacity: 0.8 }}>
{formatValue ? formatValue(value) : value}
</span>
</div>
<Slider.Root
value={[value]}
min={min}
max={max}
step={step}
onValueChange={([v]) => onChange(v)}
style={{
position: 'relative',
display: 'flex',
alignItems: 'center',
width: '100%',
height: 16,
touchAction: 'none',
userSelect: 'none',
}}
>
<Slider.Track
style={{
position: 'relative',
flexGrow: 1,
height: 3,
borderRadius: 2,
background: 'rgba(255,255,255,0.2)',
}}
>
<Slider.Range
style={{
position: 'absolute',
height: '100%',
borderRadius: 2,
background: 'rgba(129,140,248,0.8)',
}}
/>
</Slider.Track>
<Slider.Thumb
style={{
display: 'block',
width: 14,
height: 14,
borderRadius: '50%',
background: '#818cf8',
border: '2px solid rgba(255,255,255,0.6)',
cursor: 'grab',
}}
/>
</Slider.Root>
</div>
)
}
interface DebugColorProps {
label: string
/** `#rrggbb` — a native color input accepts nothing else. */
value: string
onChange: (hex: string) => void
}
/** A labelled swatch. Shares the row shape of DebugCheckbox so the two stack
* evenly in a control panel; the hex rides alongside so the value stays
* readable without opening the picker. */
export function DebugColor({ label, value, onChange }: DebugColorProps) {
return (
<label
data-element="debug-color"
style={{
display: 'flex',
alignItems: 'center',
gap: 8,
fontSize: 11,
fontWeight: 500,
cursor: 'pointer',
userSelect: 'none',
}}
>
<input
type="color"
value={value}
onChange={(e) => onChange(e.target.value)}
style={{
width: 24,
height: 18,
padding: 0,
border: '1px solid rgba(0,0,0,0.2)',
borderRadius: 4,
background: 'none',
cursor: 'pointer',
}}
/>
{label}
<span style={{ marginLeft: 'auto', opacity: 0.55, fontVariantNumeric: 'tabular-nums' }}>
{value}
</span>
</label>
)
}
interface DebugCheckboxProps {
label: string
checked: boolean
onChange: (checked: boolean) => void
}
export function DebugCheckbox({ label, checked, onChange }: DebugCheckboxProps) {
return (
<label
data-element="debug-checkbox"
style={{
display: 'flex',
alignItems: 'center',
gap: 8,
fontSize: 11,
fontWeight: 500,
cursor: 'pointer',
userSelect: 'none',
}}
>
<input
type="checkbox"
checked={checked}
onChange={(e) => onChange(e.target.checked)}
style={{
accentColor: '#818cf8',
width: 14,
height: 14,
cursor: 'pointer',
}}
/>
{label}
</label>
)
}
interface ToyDebugPanelProps {
title: string
children: ReactNode
}
export function ToyDebugPanel({ title, children }: ToyDebugPanelProps) {
const { isVisualDebugEnabled } = useVisualDebugSafe()
if (!isVisualDebugEnabled) return null
return (
<div
data-component="toy-debug-panel"
style={{
position: 'fixed',
bottom: 16,
right: 16,
zIndex: 9999,
background: 'rgba(17,24,39,0.9)',
backdropFilter: 'blur(8px)',
borderRadius: 8,
padding: '12px 16px',
color: 'rgba(243,244,246,1)',
fontSize: 12,
minWidth: 200,
maxWidth: 280,
display: 'flex',
flexDirection: 'column',
gap: 10,
boxShadow: '0 4px 12px rgba(0,0,0,0.3)',
pointerEvents: 'auto',
}}
>
<div
data-element="debug-panel-title"
style={{
fontWeight: 700,
fontSize: 11,
textTransform: 'uppercase',
letterSpacing: '0.05em',
opacity: 0.6,
}}
>
{title} Debug
</div>
{children}
</div>
)
}
|