diff --git a/docker-compose.yaml b/docker-compose.yaml index 637c876..4f36992 100644 --- a/docker-compose.yaml +++ b/docker-compose.yaml @@ -18,8 +18,14 @@ services: container_name: frontend ports: - "8071:5173" + # Montar solo fuentes de la app (no el Dockerfile ni ficheros de despliegue en /app) volumes: - - ./frontend:/app + - ./frontend/src:/app/src + - ./frontend/public:/app/public + - ./frontend/index.html:/app/index.html + - ./frontend/vite.config.js:/app/vite.config.js + - ./frontend/package.json:/app/package.json + - ./frontend/package-lock.json:/app/package-lock.json - /app/node_modules environment: - VITE_API_URL=/api diff --git a/frontend/src/components/layout/Header.jsx b/frontend/src/components/layout/Header.jsx index 2011ca7..6efe21e 100644 --- a/frontend/src/components/layout/Header.jsx +++ b/frontend/src/components/layout/Header.jsx @@ -1,72 +1,152 @@ import { useState } from 'react'; import { Link, useNavigate, useLocation } from 'react-router-dom'; -import { useAuth } from '../../context/AuthContext'; -import { FiLogIn, FiLogOut } from 'react-icons/fi'; +import { useAuth } from '../../context/AuthContext'; +import { FiLogIn, FiLogOut, FiEdit3, FiClock } from 'react-icons/fi'; + +function NavTab({ to, isActive, icon: Icon, children }) { + return ( + + + {children} + {isActive && ( + + )} + + ); +} + +function AccederButton({ isActive }) { + return ( + + + + + Acceder + + ); +} export default function Header() { const [isDropdownOpen, setIsDropdownOpen] = useState(false); const navigate = useNavigate(); const location = useLocation(); - const { user, logout, isAuthenticated } = useAuth(); + const { user, logout, isAuthenticated } = useAuth(); - const userInitial = user?.username ? user.username[0].toUpperCase() : "U"; + const userInitial = user?.username ? user.username[0].toUpperCase() : 'U'; const handleLogout = () => { - logout(); + logout(); setIsDropdownOpen(false); - navigate('/login'); + navigate('/login'); }; - const isActive = (path) => { - return location.pathname === path || (path === '/editor' && location.pathname === '/'); - }; + const isEditorActive = + location.pathname === '/editor' || location.pathname === '/'; + const isHistoryActive = location.pathname.startsWith('/history'); + const isLoginActive = location.pathname === '/login'; return ( -
-
- - - Deck of Cards Logo - +
+
+ + Deck of Cards Logo + Deck of Cards
-
- + {/* Misma navegación con o sin sesión: evita estilos distintos al loguearse */} +
+ {isAuthenticated ? (
- {isDropdownOpen && ( <> -
setIsDropdownOpen(false)}>
-
-
-

Usuario

-

{user?.username}

+
setIsDropdownOpen(false)} + aria-hidden + /> +
+
+

+ Usuario +

+

+ {user?.username} +

- -
@@ -74,19 +154,12 @@ export default function Header() { )}
) : ( -
- - - - Acceder - +
+
)}
); -} \ No newline at end of file +} diff --git a/frontend/src/index.css b/frontend/src/index.css index e63f41c..86ca1af 100644 --- a/frontend/src/index.css +++ b/frontend/src/index.css @@ -1,5 +1,8 @@ @import "tailwindcss"; +/* Solo escanear código fuente; evita que Tailwind/Vite procesen Dockerfile u otros archivos en /app */ +@source "./src/**/*.{js,jsx}"; + body { overflow-y: scroll; } \ No newline at end of file diff --git a/frontend/vite.config.js b/frontend/vite.config.js index b14feea..4ee34f7 100644 --- a/frontend/vite.config.js +++ b/frontend/vite.config.js @@ -8,9 +8,21 @@ export default defineConfig({ react(), tailwindcss(), ], + optimizeDeps: { + entries: ['index.html', 'src/**/*.{js,jsx}'], + }, server: { host: '0.0.0.0', allowedHosts: true, + watch: { + ignored: [ + '**/Dockerfile', + '**/.dockerignore', + '**/docker-compose*.yml', + '**/docker-compose*.yaml', + '**/README.md', + ], + }, proxy: { '/api': { target: process.env.BACKEND_URL || 'http://backend:8000',