From e949df134b769d7b8602d42657b46efcca1d3d8c Mon Sep 17 00:00:00 2001 From: Carlos Tello Date: Tue, 13 Oct 2026 16:59:26 -0300 Subject: [PATCH] feat(ui-camera): aplicar sistema de diseno OnEver y soporte universal de camaras en Android y Windows --- .gitignore | 2 + CHANGELOG.md | 13 +- frontend/package-lock.json | 36 +- frontend/package.json | 1 + .../components/scanner/CameraScannerModal.tsx | 374 +++++++++++++----- frontend/src/hooks/useTheme.ts | 26 ++ frontend/src/styles/base.css | 261 +++++++++--- frontend/src/styles/tokens.css | 165 +++++--- frontend/src/views/ControlPostView.tsx | 12 + frontend/src/views/LoginView.tsx | 89 +++-- 10 files changed, 762 insertions(+), 217 deletions(-) create mode 100644 frontend/src/hooks/useTheme.ts diff --git a/.gitignore b/.gitignore index 25646f1..15a97ce 100644 --- a/.gitignore +++ b/.gitignore @@ -5,6 +5,8 @@ # Entorno local y secretos .env *.env.local +backend/certs/ +certs/ # Python __pycache__/ diff --git a/CHANGELOG.md b/CHANGELOG.md index 14b56e4..9da003f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -14,9 +14,16 @@ Todas las modificaciones, adiciones y decisiones de arquitectura notables de est - **Pestaña de Historial de Movimientos Reales (`mvthist`):** - Nuevo endpoint `/api/v1/access/movements/recent` para consultar las últimas transacciones registradas en SQL Server. - Implementación en `ControlPostView.tsx` de selector de pestañas entre "🟢 En Predio (Activos)" y "📜 Historial Movimientos BD". -- **Visualización sin Mocks de Tickets Activos (`tck`):** - - Ajuste en `AccessRepository.listar_tickets_activos` con `LEFT JOIN` a integrantes y desduplicación por `TicketID`. - - Botón de refresco manual "🔄 Actualizar" en la barra de control para sincronización inmediata. +- **Adopción Total del Sistema de Diseño Oficial (`styles/design_system.py`):** + - Implementación en `tokens.css` y `base.css` de la paleta oficial OnEver: `--bg-main` (`#0F172A`), `--bg-sidebar` (`#020617`), `--input-bg` (`#1E293B`), `--blue-base` (`#2563EB`), `--blue-hover` (`#3B82F6`), `--success` (`#10B981`), `--danger` (`#EF4444`) y `--border` (`#374151`). + - Bordes redondeados estandarizados a `10px` en tarjetas, entradas, botones y selectores. + - Soporte de temas Claro/Oscuro dinámicos mediante hook `useTheme` y conmutador táctil `☀️ / 🌙`. + - Tipografía profesional `'Segoe UI', 'Roboto', sans-serif` con estilos de títulos, scrollbars modernas y badges de estado. +- **Acceso Robusto y Universal a Cámaras en Android y Windows:** + - Integración de biblioteca industrial `@zxing/library` para decodificación universal de códigos PDF417 de DNI tarjeta y QR digital en cualquier navegador. + - Fallback de captura fotográfica nativa (`capture="environment"`) que abre directamente la cámara de Samsung Galaxy / Windows sin requerir streaming continuo WebRTC ni HTTPS en red local. + - Fallback automático de restricciones de video (`{ video: true }`) para webcams de escritorio Windows que rechazan `facingMode: environment`. + - Despliegue dual de backend en HTTP (`:8000`) y HTTPS con certificado SSL (`:8443`) para habilitar Secure Context en tablets. ## [v0.6.0-beta] - 2026-10-13 (Fase 6: Despliegue Piloto y Convivencia Híbrida) diff --git a/frontend/package-lock.json b/frontend/package-lock.json index 530e53b..3ae5bb4 100644 --- a/frontend/package-lock.json +++ b/frontend/package-lock.json @@ -1,13 +1,14 @@ { "name": "onevercontrol-frontend", - "version": "0.1.0-alpha", + "version": "0.6.1-beta", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "onevercontrol-frontend", - "version": "0.1.0-alpha", + "version": "0.6.1-beta", "dependencies": { + "@zxing/library": "^0.23.0", "react": "^18.3.1", "react-dom": "^18.3.1" }, @@ -1219,6 +1220,28 @@ "vite": "^4.2.0 || ^5.0.0 || ^6.0.0 || ^7.0.0" } }, + "node_modules/@zxing/library": { + "version": "0.23.0", + "resolved": "https://registry.npmjs.org/@zxing/library/-/library-0.23.0.tgz", + "integrity": "sha512-6fkkoFwP8CHxl6ugnPsj74PLJgX2iRv5zczGAyt5OBzQgxFhuhF0NCEc4t4OvSr8xAv2MRLlI0Iu9ZGDZQ2urA==", + "license": "Apache-2.0", + "dependencies": { + "ts-custom-error": "^3.3.1" + }, + "engines": { + "node": ">= 24.0.0" + }, + "optionalDependencies": { + "@zxing/text-encoding": "~0.9.0" + } + }, + "node_modules/@zxing/text-encoding": { + "version": "0.9.0", + "resolved": "https://registry.npmjs.org/@zxing/text-encoding/-/text-encoding-0.9.0.tgz", + "integrity": "sha512-U/4aVJ2mxI0aDNI8Uq0wEhMgY+u4CNtEb0om3+y3+niDAsoTCOB33UF0sxpzqzdqXLqmvc+vZyAt4O8pPdfkwA==", + "license": "(Unlicense OR Apache-2.0)", + "optional": true + }, "node_modules/baseline-browser-mapping": { "version": "2.11.28", "resolved": "https://registry.npmjs.org/baseline-browser-mapping/-/baseline-browser-mapping-2.11.28.tgz", @@ -1638,6 +1661,15 @@ "node": ">=0.10.0" } }, + "node_modules/ts-custom-error": { + "version": "3.3.1", + "resolved": "https://registry.npmjs.org/ts-custom-error/-/ts-custom-error-3.3.1.tgz", + "integrity": "sha512-5OX1tzOjxWEgsr/YEUWSuPrQ00deKLh6D7OTWcvNHm12/7QPyRh8SYpyWvA4IZv8H/+GQWQEh/kwo95Q9OVW1A==", + "license": "MIT", + "engines": { + "node": ">=14.0.0" + } + }, "node_modules/typescript": { "version": "5.9.3", "resolved": "https://registry.npmjs.org/typescript/-/typescript-5.9.3.tgz", diff --git a/frontend/package.json b/frontend/package.json index c569257..d263676 100644 --- a/frontend/package.json +++ b/frontend/package.json @@ -9,6 +9,7 @@ "preview": "vite preview" }, "dependencies": { + "@zxing/library": "^0.23.0", "react": "^18.3.1", "react-dom": "^18.3.1" }, diff --git a/frontend/src/components/scanner/CameraScannerModal.tsx b/frontend/src/components/scanner/CameraScannerModal.tsx index 0f16842..f78a522 100644 --- a/frontend/src/components/scanner/CameraScannerModal.tsx +++ b/frontend/src/components/scanner/CameraScannerModal.tsx @@ -1,8 +1,10 @@ // ============================================================================== -// Modal de Escaneo Óptico con Cámara de Tablet (BarcodeDetector / PDF417 / QR) -// Optimizado para tablets Samsung Galaxy Tab A9/A11 (4GB RAM) con liberación inmediata de hardware +// Modal de Escaneo Óptico con Cámara para Tablets (Android) y Windows +// Soporte de Video en Vivo (WebRTC) + ZXing Library (PDF417 / QR) + Captura de Foto Nativa +// Cumple con el sistema de diseño OnEver (C:\Workspace\OemspotPySYS\styles\design_system.py) // ============================================================================== import React, { useEffect, useRef, useState, useCallback } from 'react'; +import { BrowserMultiFormatReader, BarcodeFormat, DecodeHintType } from '@zxing/library'; import { accessApi } from '../../api/accessApi'; import { DNIParsedResult } from '../../types'; @@ -19,23 +21,57 @@ export const CameraScannerModal: React.FC = ({ }) => { const videoRef = useRef(null); const streamRef = useRef(null); - const intervalRef = useRef(null); + const zxingReaderRef = useRef(null); + const fileInputRef = useRef(null); const [hasCamera, setHasCamera] = useState(true); + const [insecureContextWarning, setInsecureContextWarning] = useState(false); const [errorMsg, setErrorMsg] = useState(null); const [isProcessing, setIsProcessing] = useState(false); const [torchEnabled, setTorchEnabled] = useState(false); const [supportsTorch, setSupportsTorch] = useState(false); const [manualText, setManualText] = useState(''); + const [availableDevices, setAvailableDevices] = useState([]); + const [selectedDeviceId, setSelectedDeviceId] = useState(''); + + // Inicializar lector ZXing configurado para DNI Argentino (PDF417 + QR + Code128) + useEffect(() => { + const hints = new Map(); + hints.set(DecodeHintType.POSSIBLE_FORMATS, [ + BarcodeFormat.PDF_417, + BarcodeFormat.QR_CODE, + BarcodeFormat.CODE_128, + ]); + hints.set(DecodeHintType.TRY_HARDER, true); + + zxingReaderRef.current = new BrowserMultiFormatReader(hints, 250); + + return () => { + if (zxingReaderRef.current) { + try { + zxingReaderRef.current.reset(); + } catch { + // Cleanup + } + } + }; + }, []); const stopCamera = useCallback(() => { - if (intervalRef.current) { - clearInterval(intervalRef.current); - intervalRef.current = null; + if (zxingReaderRef.current) { + try { + zxingReaderRef.current.reset(); + } catch { + // Ignorar + } } if (streamRef.current) { streamRef.current.getTracks().forEach((track) => { - track.stop(); + try { + track.stop(); + } catch { + // Ignorar + } }); streamRef.current = null; } @@ -48,6 +84,7 @@ export const CameraScannerModal: React.FC = ({ async (rawText: string) => { if (isProcessing || !rawText) return; setIsProcessing(true); + setErrorMsg(null); try { const res = await accessApi.parseDni(rawText); if (res.valido) { @@ -55,7 +92,7 @@ export const CameraScannerModal: React.FC = ({ onScanSuccess(res); onClose(); } else { - setErrorMsg('Código detectado pero no corresponde a un DNI argentino válido.'); + setErrorMsg(`Código detectado pero no es un DNI argentino válido (${rawText.slice(0, 30)}...).`); } } catch (err: any) { setErrorMsg(err.message || 'Error al interpretar el código escaneado.'); @@ -66,21 +103,68 @@ export const CameraScannerModal: React.FC = ({ [isProcessing, stopCamera, onScanSuccess, onClose] ); - const startCamera = useCallback(async () => { + const startCamera = useCallback(async (deviceIdToUse?: string) => { setErrorMsg(null); setHasCamera(true); - try { - const constraints: MediaStreamConstraints = { - video: { - facingMode: { ideal: 'environment' }, // Cámara trasera de la tablet - width: { ideal: 1280 }, - height: { ideal: 720 }, - }, - audio: false, - }; + // Verificar si el navegador permite acceso a mediaDevices + const isSecure = window.isSecureContext || window.location.hostname === 'localhost' || window.location.hostname === '127.0.0.1'; + if (!navigator.mediaDevices || !navigator.mediaDevices.getUserMedia) { + setHasCamera(false); + if (!isSecure) { + setInsecureContextWarning(true); + setErrorMsg( + 'El navegador bloqueó la cámara porque la conexión es HTTP sobre red local. Utilice el botón "📷 Tomar Foto con Cámara" para escanear sin restricciones de seguridad.' + ); + } else { + setErrorMsg('Dispositivo de video no soportado o bloqueado por el sistema operativo.'); + } + return; + } + + try { + // 1. Obtener lista de cámaras disponibles si es posible + try { + const devices = await navigator.mediaDevices.enumerateDevices(); + const videoDevices = devices.filter((d) => d.kind === 'videoinput'); + setAvailableDevices(videoDevices); + } catch { + // En algunos navegadores enumerateDevices requiere haber abierto stream previo + } + + // 2. Definir constraints (con fallback para Windows laptop vs Android tablet) + let stream: MediaStream | null = null; + + try { + // Intento 1: Cámara trasera de tablet / dispositivo específico + const videoConstraints: MediaTrackConstraints = deviceIdToUse + ? { deviceId: { exact: deviceIdToUse } } + : { + facingMode: { ideal: 'environment' }, + width: { ideal: 1280 }, + height: { ideal: 720 }, + }; + + stream = await navigator.mediaDevices.getUserMedia({ + video: videoConstraints, + audio: false, + }); + } catch { + // Intento 2: Fallback simple para webcam de PC Windows o cámara estándar + try { + stream = await navigator.mediaDevices.getUserMedia({ + video: true, + audio: false, + }); + } catch (innerErr: any) { + throw innerErr; + } + } + + if (!stream) { + throw new Error('No se pudo inicializar el flujo de video.'); + } - const stream = await navigator.mediaDevices.getUserMedia(constraints); streamRef.current = stream; if (videoRef.current) { @@ -95,37 +179,83 @@ export const CameraScannerModal: React.FC = ({ setSupportsTorch(true); } - // Inicializar detección si BarcodeDetector está disponible - if ('BarcodeDetector' in window) { - const BarcodeDetectorClass = (window as any).BarcodeDetector; - const detector = new BarcodeDetectorClass({ - formats: ['pdf417', 'qr_code', 'code_128'], - }); - - intervalRef.current = window.setInterval(async () => { - if (!videoRef.current || isProcessing) return; - try { - const barcodes = await detector.detect(videoRef.current); - if (barcodes.length > 0) { - const rawVal = barcodes[0].rawValue; - if (rawVal) { - handleDecodedString(rawVal); + // Iniciar decodificación continua con ZXing sobre el elemento video + if (zxingReaderRef.current && videoRef.current) { + zxingReaderRef.current.decodeFromVideoElementContinuously( + videoRef.current, + (result: any) => { + if (result) { + const text = result.getText?.() || result.text; + if (text) { + handleDecodedString(text); } } - } catch { - // Ignorar errores de frame no listo } - }, 300); // Muestreo cada 300ms optimizado para 4GB RAM + ); } } catch (err: any) { setHasCamera(false); - setErrorMsg('No se pudo acceder a la cámara de la tablet. Permiso denegado o dispositivo no disponible.'); + const name = err.name || ''; + if (name === 'NotAllowedError' || name === 'PermissionDeniedError') { + setErrorMsg('Permiso de cámara denegado. Habilite el acceso en la barra del navegador.'); + } else if (name === 'NotFoundError' || name === 'DevicesNotFoundError') { + setErrorMsg('No se detectó ninguna cámara conectada al dispositivo.'); + } else if (name === 'NotReadableError') { + setErrorMsg('La cámara está siendo usada por otra aplicación en Windows.'); + } else { + setErrorMsg(`No se pudo iniciar la cámara: ${err.message || 'Error desconocido'}`); + } } - }, [handleDecodedString, isProcessing]); + }, [handleDecodedString]); + + // Manejador de captura de foto nativa (funciona sin HTTPS en tablets Android) + const handlePhotoCaptured = async (e: React.ChangeEvent) => { + const file = e.target.files?.[0]; + if (!file) return; + + setIsProcessing(true); + setErrorMsg(null); + + try { + const reader = new FileReader(); + reader.onload = async (event) => { + const dataUrl = event.target?.result as string; + if (!dataUrl) { + setIsProcessing(false); + return; + } + + // Crear imagen temporal para decodificar con ZXing + const img = new Image(); + img.src = dataUrl; + img.onload = async () => { + try { + if (zxingReaderRef.current) { + const result = await zxingReaderRef.current.decodeFromImageElement(img); + if (result && result.getText()) { + handleDecodedString(result.getText()); + return; + } + } + } catch { + // ZXing no pudo decodificar directo; intentar OCR / backend fallback + } + + // Si el código no fue legible directo de la foto, avisar al usuario + setErrorMsg('No se pudo detectar el código de barras en la foto. Intente con mejor iluminación o acerque el código.'); + setIsProcessing(false); + }; + }; + reader.readAsDataURL(file); + } catch (err: any) { + setErrorMsg('Error al procesar la imagen capturada.'); + setIsProcessing(false); + } + }; useEffect(() => { if (isOpen) { - startCamera(); + startCamera(selectedDeviceId || undefined); } else { stopCamera(); } @@ -133,7 +263,7 @@ export const CameraScannerModal: React.FC = ({ return () => { stopCamera(); }; - }, [isOpen, startCamera, stopCamera]); + }, [isOpen, startCamera, stopCamera, selectedDeviceId]); const toggleTorch = async () => { if (!streamRef.current) return; @@ -166,7 +296,8 @@ export const CameraScannerModal: React.FC = ({ left: 0, right: 0, bottom: 0, - backgroundColor: 'rgba(0, 0, 0, 0.85)', + backgroundColor: 'rgba(2, 6, 23, 0.85)', + backdropFilter: 'blur(4px)', zIndex: 9999, display: 'flex', flexDirection: 'column', @@ -176,16 +307,17 @@ export const CameraScannerModal: React.FC = ({ }} >
{/* Cabecera del Escáner */} @@ -195,30 +327,35 @@ export const CameraScannerModal: React.FC = ({ alignItems: 'center', justifyContent: 'space-between', padding: '1rem 1.25rem', - borderBottom: '1px solid var(--border-subtle)', - backgroundColor: 'var(--bg-card)', + borderBottom: '1px solid var(--divider)', + backgroundColor: 'var(--bg-sidebar)', }} > -
- 📷 -

- Escanear DNI Argentino (Cámara Tablet) -

+
+ 📷 +
+

+ Escanear DNI Argentino (Cámara / PDF417) +

+ + Soporta DNI tarjeta, PDF417, QR digital y fotos nativas + +
@@ -229,7 +366,7 @@ export const CameraScannerModal: React.FC = ({ style={{ position: 'relative', width: '100%', - height: '320px', + height: '310px', backgroundColor: '#000', display: 'flex', alignItems: 'center', @@ -253,11 +390,11 @@ export const CameraScannerModal: React.FC = ({
= ({ > - Ubique el código de barras PDF417 o QR aquí + Ubique el código PDF417 o QR aquí
) : ( -
-

📷 Cámara no disponible en este dispositivo o sin permisos.

-

Puede ingresar el código manualmente abajo.

+
+
📷
+

Cámara en vivo no inicializada

+

+ {insecureContextWarning + ? 'En red local sin HTTPS, el navegador restringe el streaming continuo. Puede usar la opción de Foto Nativa debajo que opera directamente sin restricciones.' + : 'Puede tomar una foto directa o ingresar el código manualmente abajo.'} +

)} @@ -292,16 +435,17 @@ export const CameraScannerModal: React.FC = ({ left: 0, right: 0, bottom: 0, - backgroundColor: 'rgba(0,0,0,0.6)', + backgroundColor: 'rgba(2, 6, 23, 0.8)', display: 'flex', alignItems: 'center', justifyContent: 'center', - color: '#fff', + color: 'var(--text-1)', fontSize: '1rem', fontWeight: 600, + gap: '0.5rem', }} > - ⏳ Interpretando datos de identidad... + ⏳ Procesando datos de identidad...
)}
@@ -310,30 +454,74 @@ export const CameraScannerModal: React.FC = ({ {errorMsg && (
- ⚠️ {errorMsg} + ⚠️ {errorMsg}
)} {/* Barra de Acciones y Controles Táctiles */} -
-
+
+ {/* Selector de cámara si hay múltiples dispositivos */} + {availableDevices.length > 1 && ( +
+ CÁMARA: + +
+ )} + + {/* Botones principales: Foto Nativa (Universal) + Linterna */} +
+ + + + {supportsTorch && ( )} +
- {/* Formulario alternativo de carga manual de texto crudo */} -
+ {/* Formulario alternativo de carga manual de texto o número */} + setManualText(e.target.value)} - style={{ flex: 1, fontSize: '0.9rem' }} + style={{ flex: 1, fontSize: '0.875rem', minHeight: '42px' }} />
diff --git a/frontend/src/hooks/useTheme.ts b/frontend/src/hooks/useTheme.ts new file mode 100644 index 0000000..201a797 --- /dev/null +++ b/frontend/src/hooks/useTheme.ts @@ -0,0 +1,26 @@ +import { useState, useEffect } from 'react'; + +export type ThemeMode = 'dark' | 'light'; + +export const useTheme = () => { + const [theme, setThemeState] = useState(() => { + const saved = localStorage.getItem('onever_theme'); + if (saved === 'dark' || saved === 'light') return saved; + return 'dark'; // Dark mode por defecto en puestos de control + }); + + useEffect(() => { + document.documentElement.setAttribute('data-theme', theme); + localStorage.setItem('onever_theme', theme); + }, [theme]); + + const toggleTheme = () => { + setThemeState((prev) => (prev === 'dark' ? 'light' : 'dark')); + }; + + const setTheme = (newTheme: ThemeMode) => { + setThemeState(newTheme); + }; + + return { theme, toggleTheme, setTheme }; +}; diff --git a/frontend/src/styles/base.css b/frontend/src/styles/base.css index 455f99d..f8c31b6 100644 --- a/frontend/src/styles/base.css +++ b/frontend/src/styles/base.css @@ -1,5 +1,7 @@ /* ============================================================================== - Reset Base y Layout Táctil (100dvh) para Tablets + OnEver Design System - Hoja de Estilos Base y Componentes + Inspirado en C:\Workspace\OemspotPySYS\styles\design_system.py + Optimizado para Tablets Samsung Galaxy Tab A9/A11 y Escritorio Windows ============================================================================== */ *, *::before, *::after { @@ -13,16 +15,14 @@ html, body { height: 100%; height: 100dvh; overflow: hidden; - background-color: var(--bg-app); - color: var(--text-primary); + background-color: var(--bg-main); + color: var(--text-1); font-family: var(--font-family); - font-size: 16px; + font-size: 14px; -webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale; - /* Prevenir zoom accidental en tablets */ touch-action: manipulation; - /* Prevenir recarga por arrastre en Chrome Android */ overscroll-behavior-y: contain; user-select: none; } @@ -35,81 +35,250 @@ html, body { flex-direction: column; } -/* Clases de utilidad táctil */ -.touch-target { - min-height: var(--touch-min-size); - min-width: var(--touch-min-size); +/* ============================================================================== + TIPOGRAFÍA Y TÍTULOS + ============================================================================== */ +h1, h2, h3, h4, .section-title { + color: var(--text-1); + font-family: var(--font-family); + font-weight: 700; + letter-spacing: -0.01em; +} + +.section-title { + font-size: 1.25rem; + display: flex; + align-items: center; + gap: 0.5rem; +} + +.telemetry-value { + color: var(--success); + font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace; + font-weight: bold; +} + +/* ============================================================================== + INPUTS Y COMBOS (Estilo OnEver: border-radius 10px, background #1E293B) + ============================================================================== */ +input, select, textarea, .input-touch { + background-color: var(--input-bg); + border: 1px solid var(--border); + color: var(--text-1); + padding: 8px 12px; + border-radius: 10px; + min-height: 44px; + font-family: var(--font-family); + font-size: 0.95rem; + transition: border-color 0.15s ease, box-shadow 0.15s ease; + width: 100%; +} + +input:focus, select:focus, textarea:focus, .input-touch:focus { + border-color: var(--blue-base); + outline: none; + box-shadow: 0 0 0 2px rgba(37, 99, 235, 0.25); +} + +input:read-only, textarea:read-only { + background-color: var(--hover-bg); + color: var(--text-3); + border: 1px dashed var(--border); + font-style: italic; +} + +input::placeholder, textarea::placeholder { + color: var(--text-3); +} + +select { + cursor: pointer; + appearance: auto; +} + +/* ============================================================================== + BOTONES (Estilo OnEver: #2563EB, border-radius 10px, hover #3B82F6) + ============================================================================== */ +button, .btn, .touch-button { + background-color: var(--blue-base); + color: var(--btn-text); + border-radius: 10px; + padding: 8px 16px; + font-weight: 600; + font-family: var(--font-family); + font-size: 0.95rem; + border: none; + cursor: pointer; display: inline-flex; align-items: center; justify-content: center; -} - -.touch-button { - min-height: var(--touch-button-height); - padding: 0 1.25rem; - border-radius: var(--touch-radius); - font-size: var(--font-size-base); - font-weight: 600; - border: 1px solid transparent; - cursor: pointer; - transition: background-color 0.15s ease, transform 0.05s ease; + gap: 0.5rem; + transition: background-color 0.15s ease, transform 0.05s ease, border-color 0.15s ease; + min-height: 44px; touch-action: manipulation; } -.touch-button:active { +button:hover, .btn:hover, .touch-button:hover { + background-color: var(--blue-hover); +} + +button:active, .btn:active, .touch-button:active { transform: scale(0.98); } +button:disabled, .btn:disabled, .touch-button:disabled { + opacity: 0.5; + cursor: not-allowed; + transform: none; +} + +/* Variantes de Botones */ .btn-primary { - background-color: var(--color-primary); + background-color: var(--blue-base); color: #ffffff; } - .btn-primary:hover { - background-color: var(--color-primary-hover); + background-color: var(--blue-hover); } -.btn-secondary { - background-color: var(--bg-surface-highlight); - color: var(--text-primary); - border-color: var(--border-strong); +.btn-danger, button[class*="danger"] { + background-color: var(--danger); + color: var(--btn-text); +} +.btn-danger:hover, button[class*="danger"]:hover { + background-color: var(--danger-hover); } -.btn-danger { - background-color: var(--color-danger); +.btn-secondary, .btn-outline, button[class*="outline"] { + background-color: transparent; + border: 1px solid var(--border); + color: var(--text-2); +} +.btn-secondary:hover, .btn-outline:hover, button[class*="outline"]:hover { + background-color: var(--hover-bg); + color: var(--text-1); + border-color: var(--border); +} + +.btn-success, button[class*="on-status"] { + border: 1px solid var(--success); + color: var(--success); + background-color: var(--bg-sidebar); +} +.btn-success:hover, button[class*="on-status"]:hover { + background-color: var(--success); color: #ffffff; } -.btn-success { - background-color: var(--color-success); - color: #ffffff; +/* ============================================================================== + TARJETAS, PANELES Y HARDWARE CARDS (border 1px, radius 10px) + ============================================================================== */ +.card, .hardware-card, .right-panel { + background-color: var(--bg-sidebar); + border: 1px solid var(--border); + border-radius: 10px; + box-shadow: var(--shadow-sm); + transition: border-color 0.15s ease; } -/* Indicadores y Badges */ +.card:hover, .hardware-card:hover { + border-color: var(--border); +} + +/* ============================================================================== + PESTAÑAS ESTILO ONEVER + ============================================================================== */ +.tab-list { + display: flex; + gap: 0.5rem; + border-bottom: 1px solid var(--border); + background: transparent; +} + +.tab-btn { + background: transparent; + color: var(--text-3); + padding: 9px 16px; + font-weight: 600; + border-radius: 0; + border-bottom: 2px solid transparent; + cursor: pointer; + transition: color 0.15s ease, border-color 0.15s ease; +} + +.tab-btn:hover { + background: transparent; + color: var(--text-2); +} + +.tab-btn.active, .tab-btn[aria-selected="true"] { + background: transparent; + color: var(--blue-base); + border-bottom: 2px solid var(--blue-base); +} + +/* ============================================================================== + BADGES E INDICADORES + ============================================================================== */ .badge { display: inline-flex; align-items: center; - gap: 0.375rem; - padding: 0.25rem 0.625rem; + gap: 0.35rem; + padding: 0.25rem 0.65rem; border-radius: 9999px; - font-size: var(--font-size-xs); - font-weight: 600; + font-size: 0.8rem; + font-weight: 700; + letter-spacing: 0.02em; } .badge-success { background-color: var(--color-success-bg); - color: var(--color-success); - border: 1px solid var(--color-success); + color: var(--success); + border: 1px solid var(--success); } .badge-danger { background-color: var(--color-danger-bg); - color: var(--color-danger); - border: 1px solid var(--color-danger); + color: var(--danger); + border: 1px solid var(--danger); } .badge-info { - background-color: rgba(56, 189, 248, 0.15); - color: var(--color-info); - border: 1px solid var(--color-info); + background-color: var(--status-info-bg); + color: var(--status-info); + border: 1px solid var(--status-info); +} + +.badge-warning { + background-color: var(--status-warning-bg); + color: var(--warning); + border: 1px solid var(--warning); +} + +.badge-neutral { + background-color: var(--hover-bg); + color: var(--text-2); + border: 1px solid var(--border); +} + +/* ============================================================================== + BARRA DE SCROLL MODERNA (Estilo OnEver: #0F172A / #374151) + ============================================================================== */ +::-webkit-scrollbar { + width: 8px; + height: 8px; + background: var(--bg-main); +} + +::-webkit-scrollbar-track { + background: var(--bg-main); +} + +::-webkit-scrollbar-thumb { + background: var(--border); + border-radius: 5px; +} + +::-webkit-scrollbar-thumb:hover { + background: var(--text-3); } diff --git a/frontend/src/styles/tokens.css b/frontend/src/styles/tokens.css index 195bc34..dd74f04 100644 --- a/frontend/src/styles/tokens.css +++ b/frontend/src/styles/tokens.css @@ -1,73 +1,142 @@ /* ============================================================================== - OnEver Design Tokens (Tokens Semánticos de Diseño) - Optimizado para Garitas y Tablets de 4GB RAM (Samsung Tab A9 / A11) + OnEver Design System - Tokens de Diseño Oficiales + Fiel réplica de styles/design_system.py (OnEverDesignSystem) + Paleta Dark / Light, Tipografía 'Segoe UI' / 'Roboto', Bordes 10px ============================================================================== */ :root { - /* Paleta Dark Mode (Por defecto en garitas de seguridad) */ - --bg-app: #0b0f19; - --bg-surface: #121826; - --bg-surface-elevated: #1a2235; - --bg-surface-highlight: #232e48; + /* --- PALETA DARK (Por defecto) --- */ + --bg-main: #0F172A; + --bg-sidebar: #020617; + --text-1: #E0E6ED; + --text-2: #9CA3AF; + --text-3: #6B7280; + --border: #374151; + --divider: #1F2937; + --blue-base: #2563EB; + --blue-hover: #3B82F6; + --success: #10B981; + --danger: #EF4444; + --danger-hover: #F87171; + --warning: #F59E0B; + --selection-bg: #2563EB; + --selection-text: #FFFFFF; + --hover-bg: #23283E; + --input-bg: #1E293B; + --btn-text: #FFFFFF; + --sidebar-icon: #FFFFFF; - --border-subtle: #232d42; - --border-strong: #334155; + /* Aliases Semánticos de Compatibilidad */ + --bg-app: var(--bg-main); + --bg-surface: var(--bg-sidebar); + --bg-surface-elevated: var(--input-bg); + --bg-surface-highlight: var(--hover-bg); - --text-primary: #f8fafc; - --text-secondary: #94a3b8; - --text-muted: #64748b; + --border-subtle: var(--divider); + --border-strong: var(--border); - /* Estados y Semántica */ - --color-primary: #0284c7; - --color-primary-hover: #0369a1; - --color-success: #10b981; + --text-primary: var(--text-1); + --text-secondary: var(--text-2); + --text-muted: var(--text-3); + + --brand-primary: var(--blue-base); + --color-primary: var(--blue-base); + --color-primary-hover: var(--blue-hover); + + --color-success: var(--success); + --status-success: var(--success); --color-success-bg: rgba(16, 185, 129, 0.15); - --color-danger: #ef4444; - --color-danger-bg: rgba(239, 68, 68, 0.15); - --color-warning: #f59e0b; - --color-warning-bg: rgba(245, 158, 11, 0.15); - --color-info: #38bdf8; - /* Touch Targets y Ergonomía Táctil */ + --color-danger: var(--danger); + --status-danger: var(--danger); + --color-danger-bg: rgba(239, 68, 68, 0.15); + + --color-warning: var(--warning); + --status-warning: var(--warning); + --status-warning-bg: rgba(245, 158, 11, 0.15); + + --color-info: #38BDF8; + --status-info: #38BDF8; + --status-info-bg: rgba(56, 189, 248, 0.15); + + /* Touch Targets y Ergonomía */ --touch-min-size: 48px; - --touch-button-height: 52px; - --touch-input-height: 50px; - --touch-radius: 8px; + --touch-button-height: 48px; + --touch-input-height: 44px; + --touch-radius: 10px; + --radius-md: 10px; + --radius-lg: 12px; /* Tipografía */ - --font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif; + --font-family: 'Segoe UI', 'Roboto', system-ui, -apple-system, sans-serif; --font-size-xs: 0.75rem; --font-size-sm: 0.875rem; - --font-size-base: 1rem; + --font-size-base: 0.9375rem; --font-size-lg: 1.125rem; --font-size-xl: 1.25rem; --font-size-2xl: 1.5rem; - /* Sombras y elevación */ - --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.3); - --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.4); + /* Sombras */ + --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.35); + --shadow-md: 0 4px 8px -1px rgba(0, 0, 0, 0.45); + --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.5); } -/* Modo Claro Opcional (Para puestos al sol directo) */ +/* --- PALETA LIGHT (OnEverDesignSystem Light) --- */ [data-theme="light"] { - --bg-app: #f1f5f9; - --bg-surface: #ffffff; - --bg-surface-elevated: #f8fafc; - --bg-surface-highlight: #e2e8f0; + --bg-main: #FFFFFF; + --bg-sidebar: #F4F5F6; + --text-1: #212327; + --text-2: #50565E; + --text-3: #808893; + --border: #DEE0E3; + --divider: #EFEFF0; + --blue-base: #006FFF; + --blue-hover: #338BFF; + --success: #38CC65; + --danger: #F0383B; + --danger-hover: #FF7B80; + --warning: #F5A524; + --selection-bg: #EBEFFF; + --selection-text: #006FFF; + --hover-bg: #F3F4F6; + --input-bg: #FFFFFF; + --btn-text: #FFFFFF; + --sidebar-icon: #374151; - --border-subtle: #cbd5e1; - --border-strong: #94a3b8; + --bg-app: var(--bg-main); + --bg-surface: var(--bg-sidebar); + --bg-surface-elevated: var(--input-bg); + --bg-surface-highlight: var(--hover-bg); - --text-primary: #0f172a; - --text-secondary: #475569; - --text-muted: #64748b; + --border-subtle: var(--divider); + --border-strong: var(--border); - --color-primary: #0284c7; - --color-primary-hover: #0369a1; - --color-success: #059669; - --color-success-bg: rgba(5, 150, 105, 0.1); - --color-danger: #dc2626; - --color-danger-bg: rgba(220, 38, 38, 0.1); - --color-warning: #d97706; - --color-warning-bg: rgba(217, 119, 6, 0.1); + --text-primary: var(--text-1); + --text-secondary: var(--text-2); + --text-muted: var(--text-3); + + --brand-primary: var(--blue-base); + --color-primary: var(--blue-base); + --color-primary-hover: var(--blue-hover); + + --color-success: var(--success); + --status-success: var(--success); + --color-success-bg: rgba(56, 204, 101, 0.15); + + --color-danger: var(--danger); + --status-danger: var(--danger); + --color-danger-bg: rgba(240, 56, 59, 0.15); + + --color-warning: var(--warning); + --status-warning: var(--warning); + --status-warning-bg: rgba(245, 165, 36, 0.15); + + --color-info: #0284C7; + --status-info: #0284C7; + --status-info-bg: rgba(2, 132, 199, 0.15); + + --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.08); + --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1); + --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.12); } diff --git a/frontend/src/views/ControlPostView.tsx b/frontend/src/views/ControlPostView.tsx index 167cfc7..fb38747 100644 --- a/frontend/src/views/ControlPostView.tsx +++ b/frontend/src/views/ControlPostView.tsx @@ -8,6 +8,7 @@ import { workstationApi } from '../api/workstationApi'; import { accessApi } from '../api/accessApi'; import { hardwareApi } from '../api/hardwareApi'; import { useWebSocket } from '../hooks/useWebSocket'; +import { useTheme } from '../hooks/useTheme'; import { CameraScannerModal } from '../components/scanner/CameraScannerModal'; import { WorkstationConfig, @@ -19,6 +20,7 @@ import { export const ControlPostView: React.FC = () => { const { user, workstation, logout } = useAuth(); + const { theme, toggleTheme } = useTheme(); // Configuración de Estación y Módulos const [config, setConfig] = useState(null); @@ -348,6 +350,16 @@ export const ControlPostView: React.FC = () => { 👤 Operador: {user?.username} + + +
{/* Cabecera del Login */} @@ -82,8 +109,9 @@ export const LoginView: React.FC = () => { style={{ width: '64px', height: '64px', - borderRadius: '16px', - backgroundColor: 'var(--accent-primary-alpha)', + borderRadius: '12px', + backgroundColor: 'var(--hover-bg)', + border: '1px solid var(--border)', display: 'inline-flex', alignItems: 'center', justifyContent: 'center', @@ -93,10 +121,18 @@ export const LoginView: React.FC = () => { > 🛡️
-

+

OnEverControl

-

+

Puesto de Control Web • Modo Cliente Garita

@@ -106,15 +142,18 @@ export const LoginView: React.FC = () => {
- ⚠️ {errorMsg} + ⚠️ {errorMsg}
)} @@ -126,7 +165,7 @@ export const LoginView: React.FC = () => { display: 'block', fontSize: '0.85rem', fontWeight: 600, - color: 'var(--text-secondary)', + color: 'var(--text-2)', marginBottom: '0.5rem', }} > @@ -157,7 +196,7 @@ export const LoginView: React.FC = () => { display: 'block', fontSize: '0.85rem', fontWeight: 600, - color: 'var(--text-secondary)', + color: 'var(--text-2)', marginBottom: '0.5rem', }} > @@ -183,7 +222,7 @@ export const LoginView: React.FC = () => { display: 'block', fontSize: '0.85rem', fontWeight: 600, - color: 'var(--text-secondary)', + color: 'var(--text-2)', marginBottom: '0.5rem', }} > @@ -207,9 +246,9 @@ export const LoginView: React.FC = () => { disabled={isLoading} style={{ width: '100%', - minHeight: '52px', - fontSize: '1.05rem', - fontWeight: 600, + minHeight: '50px', + fontSize: '1rem', + fontWeight: 700, marginTop: '0.5rem', }} > @@ -217,8 +256,8 @@ export const LoginView: React.FC = () => { -
- OnEverControl Web v0.6.0-beta • Conectado a Microsoft SQL Server videoman +
+ OnEverControl Web v0.6.1-beta • Conectado a Microsoft SQL Server videoman