Spaces:
Running
Running
feat(metrology): magnetic wall edge snapping, ortho locking, draggable HUD panels, and collapsible sidebar
e96faf6 Download src/components/Header.jsx from FuturoEPT/simuladorcnc: direct link, hf CLI and curl.
- Browser
- Download file 10.8 kB
-
https://huggingface.co/spaces/FuturoEPT/simuladorcnc/resolve/main/src/components/Header.jsx
- Command line
-
hf download hf://spaces/FuturoEPT/simuladorcnc/src/components/Header.jsx
-
curl -L -o Header.jsx https://huggingface.co/spaces/FuturoEPT/simuladorcnc/resolve/main/src/components/Header.jsx
10.8 kB
| import React, { useState, useRef, useEffect } from 'react'; | |
| import { | |
| Ruler, | |
| GraduationCap, | |
| Award, | |
| Eye, | |
| EyeOff, | |
| Layers, | |
| Box, | |
| Check, | |
| ChevronDown, | |
| Sparkles, | |
| FileText, | |
| Columns | |
| } from 'lucide-react'; | |
| export default function Header({ | |
| showTurretHead, | |
| onToggleHead, | |
| currentView, | |
| onSelectView, | |
| onOpenDrawing, | |
| onOpenTutorial, | |
| onOpenGrader, | |
| showDRO = true, | |
| onToggleDRO, | |
| showActiveBlock = true, | |
| onToggleActiveBlock, | |
| showLegend = true, | |
| onToggleLegend, | |
| isCaliperOpen = false, | |
| onToggleCaliper, | |
| isSidebarOpen = true, | |
| onToggleSidebar | |
| }) { | |
| const [isPanelsMenuOpen, setIsPanelsMenuOpen] = useState(false); | |
| const menuRef = useRef(null); | |
| useEffect(() => { | |
| const handleClickOutside = (e) => { | |
| if (menuRef.current && !menuRef.current.contains(e.target)) { | |
| setIsPanelsMenuOpen(false); | |
| } | |
| }; | |
| document.addEventListener('mousedown', handleClickOutside); | |
| return () => document.removeEventListener('mousedown', handleClickOutside); | |
| }, []); | |
| const views = [ | |
| { key: 'iso', label: 'Iso 3D' }, | |
| { key: 'closeup', label: 'Peça' }, | |
| { key: 'top', label: 'XY Topo' }, | |
| { key: 'front', label: 'XZ Frente' }, | |
| { key: 'side', label: 'YZ Perfil' } | |
| ]; | |
| return ( | |
| <header className="h-14 px-4 bg-slate-900/95 backdrop-blur-md border-b border-slate-800/80 flex items-center justify-between z-30 shrink-0 gap-3"> | |
| {/* BRAND & TITLE */} | |
| <div className="flex items-center gap-3 shrink-0"> | |
| <div className="px-2 py-0.5 bg-gradient-to-r from-red-600 to-rose-600 text-white font-extrabold tracking-wider text-[11px] rounded-md shadow-sm border border-red-500/30"> | |
| CALVI CNC | |
| </div> | |
| <div> | |
| <div className="flex items-center gap-2"> | |
| <h1 className="text-sm font-semibold tracking-tight text-slate-100"> | |
| Simulador CNC 3 Eixos | |
| </h1> | |
| <span className="text-[10px] px-1.5 py-0.5 rounded-full bg-slate-800 text-slate-300 border border-slate-700/60 font-medium hidden md:inline-block"> | |
| Torno & Fresadora ISO | |
| </span> | |
| </div> | |
| <p className="text-[10px] text-slate-400 hidden sm:block"> | |
| Laboratório Virtual • Treinamento & Desafio Prático | |
| </p> | |
| </div> | |
| </div> | |
| {/* CENTER: 4 PEDAGOGICAL ACTIONS (GOOGLE PILL STYLE) */} | |
| <div className="flex items-center gap-1.5 bg-slate-950/70 p-1 rounded-full border border-slate-800 shadow-inner"> | |
| <button | |
| type="button" | |
| onClick={onOpenDrawing} | |
| className="text-xs px-3 py-1.5 rounded-full font-semibold transition-all bg-sky-500/10 hover:bg-sky-500/20 text-sky-300 border border-sky-500/30 flex items-center gap-1.5 shadow-sm active:scale-95" | |
| title="Ver o desenho técnico da peça com cotas e raios" | |
| > | |
| <FileText size={14} className="text-sky-400" /> | |
| <span>Desenho Técnico</span> | |
| </button> | |
| <button | |
| type="button" | |
| onClick={onToggleCaliper} | |
| className={`text-xs px-3 py-1.5 rounded-full font-semibold transition-all flex items-center gap-1.5 shadow-sm active:scale-95 ${ | |
| isCaliperOpen | |
| ? 'bg-emerald-500 text-slate-950 font-bold border border-emerald-400 shadow-emerald-500/30 animate-pulse' | |
| : 'bg-emerald-500/10 hover:bg-emerald-500/20 text-emerald-300 border border-emerald-500/30' | |
| }`} | |
| title="Ativar Paquímetro Digital Virtual para medir distâncias e profundidades na peça" | |
| > | |
| <Ruler size={14} className={isCaliperOpen ? 'text-slate-950' : 'text-emerald-400'} /> | |
| <span>Paquímetro</span> | |
| {isCaliperOpen && <span className="w-1.5 h-1.5 rounded-full bg-slate-950 inline-block animate-ping" />} | |
| </button> | |
| <button | |
| type="button" | |
| onClick={onOpenTutorial} | |
| className="text-xs px-3 py-1.5 rounded-full font-semibold transition-all bg-purple-500/10 hover:bg-purple-500/20 text-purple-300 border border-purple-500/30 flex items-center gap-1.5 shadow-sm active:scale-95" | |
| title="Abrir aula e treinamento de comandos G-Code" | |
| > | |
| <GraduationCap size={15} className="text-purple-400" /> | |
| <span>Aula G-Code</span> | |
| </button> | |
| <button | |
| type="button" | |
| onClick={onOpenGrader} | |
| className="text-xs px-3.5 py-1.5 rounded-full font-bold transition-all bg-gradient-to-r from-amber-500 to-amber-600 hover:from-amber-400 hover:to-amber-500 text-slate-950 flex items-center gap-1.5 shadow-md active:scale-95" | |
| title="Avaliar código do desafio com notas e dicas pedagógicas" | |
| > | |
| <Award size={15} className="text-slate-950" /> | |
| <span>Validar Desafio</span> | |
| </button> | |
| </div> | |
| {/* RIGHT: HUD PANELS TOGGLE & CAMERA VIEWS */} | |
| <div className="flex items-center gap-2 shrink-0"> | |
| {/* MENU EXIBIR PAINÉIS FLUTUANTES */} | |
| <div className="relative" ref={menuRef}> | |
| <button | |
| type="button" | |
| onClick={() => setIsPanelsMenuOpen((prev) => !prev)} | |
| className={`text-xs px-2.5 py-1.5 rounded-lg border font-medium transition-all flex items-center gap-1.5 ${ | |
| isPanelsMenuOpen | |
| ? 'bg-blue-600 text-white border-blue-500 shadow' | |
| : 'bg-slate-800/90 text-slate-300 border-slate-700/80 hover:bg-slate-750 hover:text-white' | |
| }`} | |
| title="Configurar quais painéis flutuantes e elementos 3D são exibidos" | |
| > | |
| <Layers size={14} /> | |
| <span className="hidden sm:inline">Painéis</span> | |
| <ChevronDown size={12} className={`transition-transform duration-150 ${isPanelsMenuOpen ? 'rotate-180' : ''}`} /> | |
| </button> | |
| {isPanelsMenuOpen && ( | |
| <div className="absolute right-0 mt-2 w-56 bg-slate-900 border border-slate-700/90 rounded-xl shadow-2xl p-2 z-50 animate-fade-in flex flex-col gap-1 text-xs"> | |
| <span className="px-2 py-1 text-[10px] font-bold uppercase tracking-wider text-slate-400"> | |
| Exibir na Simulação 3D | |
| </span> | |
| <button | |
| type="button" | |
| onClick={() => onToggleCaliper && onToggleCaliper()} | |
| className="flex items-center justify-between px-2.5 py-1.5 rounded-lg hover:bg-slate-800 text-slate-200 transition-colors text-left" | |
| > | |
| <span>Paquímetro Digital (Caliper)</span> | |
| {isCaliperOpen ? <Check size={14} className="text-emerald-400" /> : <span className="text-slate-600">—</span>} | |
| </button> | |
| <button | |
| type="button" | |
| onClick={() => onToggleDRO && onToggleDRO()} | |
| className="flex items-center justify-between px-2.5 py-1.5 rounded-lg hover:bg-slate-800 text-slate-200 transition-colors text-left" | |
| > | |
| <span>Painel DRO (X/Y/Z)</span> | |
| {showDRO ? <Check size={14} className="text-emerald-400" /> : <span className="text-slate-600">—</span>} | |
| </button> | |
| <button | |
| type="button" | |
| onClick={() => onToggleActiveBlock && onToggleActiveBlock()} | |
| className="flex items-center justify-between px-2.5 py-1.5 rounded-lg hover:bg-slate-800 text-slate-200 transition-colors text-left" | |
| > | |
| <span>Inspetor de Bloco ISO</span> | |
| {showActiveBlock ? <Check size={14} className="text-emerald-400" /> : <span className="text-slate-600">—</span>} | |
| </button> | |
| <button | |
| type="button" | |
| onClick={() => onToggleLegend && onToggleLegend()} | |
| className="flex items-center justify-between px-2.5 py-1.5 rounded-lg hover:bg-slate-800 text-slate-200 transition-colors text-left" | |
| > | |
| <span>Legenda de Percurso</span> | |
| {showLegend ? <Check size={14} className="text-emerald-400" /> : <span className="text-slate-600">—</span>} | |
| </button> | |
| <div className="my-1 border-t border-slate-800" /> | |
| <button | |
| type="button" | |
| onClick={() => onToggleSidebar && onToggleSidebar()} | |
| className="flex items-center justify-between px-2.5 py-1.5 rounded-lg hover:bg-slate-800 text-slate-200 transition-colors text-left" | |
| > | |
| <span>Editor & Controles Laterais</span> | |
| {isSidebarOpen ? <Check size={14} className="text-emerald-400" /> : <span className="text-slate-600">—</span>} | |
| </button> | |
| <button | |
| type="button" | |
| onClick={onToggleHead} | |
| className="flex items-center justify-between px-2.5 py-1.5 rounded-lg hover:bg-slate-800 text-slate-200 transition-colors text-left" | |
| > | |
| <span>Cabeçote Tridimensional</span> | |
| {showTurretHead ? <Check size={14} className="text-emerald-400" /> : <span className="text-amber-400 font-mono text-[11px]">Raio-X</span>} | |
| </button> | |
| </div> | |
| )} | |
| </div> | |
| {/* BOTÃO TOGGLE DO PAINEL LATERAL (MAXIMIZAR SIMULAÇÃO 3D) */} | |
| {onToggleSidebar && ( | |
| <button | |
| type="button" | |
| onClick={onToggleSidebar} | |
| className={`text-xs px-2.5 py-1.5 rounded-lg border font-medium transition-all flex items-center gap-1.5 ${ | |
| !isSidebarOpen | |
| ? 'bg-blue-600/30 text-blue-300 border-blue-500/50 shadow-sm' | |
| : 'bg-slate-800/90 text-slate-300 border-slate-700/80 hover:bg-slate-750 hover:text-white' | |
| }`} | |
| title={isSidebarOpen ? "Ocultar editor lateral para maximizar visão 3D" : "Restaurar editor de projetos e magazine"} | |
| > | |
| <Columns size={13} /> | |
| <span className="hidden xl:inline">{isSidebarOpen ? 'Ocultar Editor' : 'Exibir Editor'}</span> | |
| </button> | |
| )} | |
| {/* VISTAS DA CÂMERA */} | |
| <div className="flex items-center bg-slate-950/80 p-0.5 rounded-lg border border-slate-800 text-xs"> | |
| {views.map((v) => ( | |
| <button | |
| key={v.key} | |
| type="button" | |
| onClick={() => onSelectView(v.key)} | |
| className={`px-2 py-1 rounded-md transition-all text-[11px] font-medium ${ | |
| currentView === v.key | |
| ? 'bg-blue-600 text-white font-bold shadow-sm' | |
| : 'text-slate-400 hover:text-slate-200 hover:bg-slate-800' | |
| }`} | |
| > | |
| {v.label} | |
| </button> | |
| ))} | |
| </div> | |
| </div> | |
| </header> | |
| ); | |
| } | |