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 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 | import type { MutableRefObject, RefObject } from 'react' import type { ActiveTool, MacroPhase } from './types' import { ToolButton } from './ToolButton' interface MacroInfo { propId: number title: string } interface ToolDockProps { activeTool: ActiveTool setActiveTool: (t: ActiveTool) => void playgroundMode: boolean isComplete: boolean isMobile: boolean isToolDockActive: boolean setIsToolDockActive: (v: boolean) => void hasConstructionSteps: boolean hasDraggablePoints: boolean availableMacros: MacroInfo[] macroPhase: MacroPhase handleMacroToolClick: () => void startWiggle: (i: number) => void givenSetupActive: boolean activeToolRef: MutableRefObject<ActiveTool> toolDockRef: React.Ref<HTMLDivElement> /** Whether full solver mode is active (unlock icon) vs constrained (lock icon) */ solverMode?: boolean /** Toggle solver mode on/off */ onToggleSolverMode?: () => void } export function ToolDock({ activeTool, setActiveTool, playgroundMode, isComplete, isMobile, isToolDockActive, setIsToolDockActive, hasConstructionSteps, hasDraggablePoints, availableMacros, handleMacroToolClick, startWiggle, givenSetupActive, activeToolRef, toolDockRef, solverMode, onToggleSolverMode, }: ToolDockProps) { if (!hasConstructionSteps && !isComplete && !playgroundMode) return null return ( <div data-element="tool-selector" ref={toolDockRef} onMouseEnter={() => setIsToolDockActive(true)} onMouseLeave={() => setIsToolDockActive(false)} onTouchStart={() => setIsToolDockActive(true)} onTouchEnd={() => setIsToolDockActive(false)} onPointerDown={() => setIsToolDockActive(true)} onPointerUp={() => setIsToolDockActive(false)} style={{ position: 'absolute', display: 'flex', gap: 8, zIndex: 10, ...(isMobile ? { top: '50%', right: 12, transform: 'translateY(-50%)', flexDirection: 'column', padding: '8px 6px', borderRadius: 16, background: 'rgba(255, 255, 255, 0.85)', border: '1px solid rgba(203, 213, 225, 0.8)', boxShadow: '0 8px 20px rgba(0,0,0,0.12)', backdropFilter: 'blur(8px)', opacity: isToolDockActive ? 1 : 0.55, transition: 'opacity 0.2s ease', } : { bottom: 24, left: '50%', transform: 'translateX(-50%)', }), }} > {(playgroundMode || (isComplete && hasDraggablePoints)) && ( <ToolButton label="Move" icon={ <svg width="22" height="22" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="2" strokeLinecap="round" strokeLinejoin="round" > <path d="M18 11V6a2 2 0 0 0-2-2a2 2 0 0 0-2 2v1" /> <path d="M14 10V4a2 2 0 0 0-2-2a2 2 0 0 0-2 2v6" /> <path d="M10 10.5V6a2 2 0 0 0-2-2a2 2 0 0 0-2 2v8" /> <path d="M18 8a2 2 0 0 1 4 0v6a8 8 0 0 1-8 8h-2c-2.8 0-4.5-.86-5.99-2.34l-3.6-3.6a2 2 0 0 1 2.83-2.82L7 17" /> </svg> } active={activeTool === 'move'} onClick={() => setActiveTool('move')} size={isMobile ? 44 : 48} /> )} {!givenSetupActive && ( <ToolButton label="Compass" icon={ <svg width="22" height="22" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="2" strokeLinecap="round" strokeLinejoin="round" > <circle cx="12" cy="5" r="1" /> <path d="M12 6l-4 14" /> <path d="M12 6l4 14" /> <path d="M6 18a6 6 0 0 0 12 0" /> </svg> } active={activeTool === 'compass'} onClick={() => setActiveTool('compass')} size={isMobile ? 44 : 48} /> )} <ToolButton label="Straightedge" icon={ <svg width="22" height="22" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="2" strokeLinecap="round" strokeLinejoin="round" > <line x1="4" y1="20" x2="20" y2="4" /> </svg> } active={activeTool === 'straightedge'} onClick={() => setActiveTool('straightedge')} size={isMobile ? 44 : 48} /> {availableMacros.length > 0 && !givenSetupActive && ( <ToolButton label="Proposition" icon={ <svg width="22" height="22" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="2" strokeLinecap="round" strokeLinejoin="round" > {/* Two overlapping circles — evokes prior constructions */} <circle cx="9" cy="12" r="5" /> <circle cx="15" cy="12" r="5" /> </svg> } active={activeTool === 'macro'} onClick={handleMacroToolClick} size={isMobile ? 44 : 48} /> )} {playgroundMode && ( <ToolButton label="Point" icon={ <svg width="22" height="22" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="2" strokeLinecap="round" strokeLinejoin="round" > <circle cx="12" cy="12" r="3" fill="currentColor" stroke="none" /> <line x1="12" y1="2" x2="12" y2="6" /> <line x1="12" y1="18" x2="12" y2="22" /> <line x1="2" y1="12" x2="6" y2="12" /> <line x1="18" y1="12" x2="22" y2="12" /> </svg> } active={activeTool === 'point'} onClick={() => { setActiveTool('point') activeToolRef.current = 'point' }} size={isMobile ? 44 : 48} /> )} {playgroundMode && !givenSetupActive && ( <ToolButton label="Wiggle" icon={ <svg width="22" height="22" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="2" strokeLinecap="round" strokeLinejoin="round" > <path d="M2 12c1.5-3 3.5-3 5 0s3.5 3 5 0 3.5-3 5 0 3.5 3 5 0" /> </svg> } active={false} onClick={() => startWiggle(0)} size={isMobile ? 44 : 48} /> )} {isComplete && onToggleSolverMode && ( <ToolButton label={solverMode ? 'Free drag (Shift)' : 'Constrained drag'} icon={ solverMode ? ( <svg width="22" height="22" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="2" strokeLinecap="round" strokeLinejoin="round" > {/* Unlock icon — free solver mode */} <rect x="3" y="11" width="18" height="11" rx="2" ry="2" /> <path d="M7 11V7a5 5 0 0 1 9.9-1" /> </svg> ) : ( <svg width="22" height="22" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="2" strokeLinecap="round" strokeLinejoin="round" > {/* Lock icon — constrained mode (default) */} <rect x="3" y="11" width="18" height="11" rx="2" ry="2" /> <path d="M7 11V7a5 5 0 0 1 10 0v4" /> </svg> ) } active={solverMode ?? false} onClick={onToggleSolverMode} size={isMobile ? 44 : 48} /> )} </div> ) } |