style frontend components
This commit is contained in:
parent
ab2970aa5a
commit
4023aa6f13
3 changed files with 134 additions and 8 deletions
|
|
@ -1,4 +1,6 @@
|
|||
import { Routes, Route, Navigate } from 'react-router-dom';
|
||||
import { useEffect, useState } from 'react';
|
||||
import { useApp } from './context/AppContext';
|
||||
import { ModalProvider } from './context/modals/useModal';
|
||||
import { ModalRoot } from './context/modals/ModalRoot';
|
||||
import { ToastProvider } from './context/toasts/useToast';
|
||||
|
|
@ -17,15 +19,34 @@ import { BoardDetail } from './pages/BoardDetail';
|
|||
import { CardDetail } from './pages/CardDetail';
|
||||
|
||||
const App = () => {
|
||||
const { token } = useApp();
|
||||
const [isAuthenticated, setIsAuthenticated] = useState<boolean | null>(null);
|
||||
|
||||
useEffect(() => {
|
||||
setIsAuthenticated(!!token);
|
||||
}, [token]);
|
||||
|
||||
if (isAuthenticated === null) {
|
||||
return null;
|
||||
}
|
||||
return (
|
||||
<LoaderProvider>
|
||||
<ToastProvider>
|
||||
<ModalProvider>
|
||||
<div className="min-h-screen bg-gray-900 text-gray-100">
|
||||
<Navbar />
|
||||
<main className="flex-1 p-8 max-w-7xl mx-auto w-full">
|
||||
<main className="flex-1 p-8 mx-auto w-full">
|
||||
<Routes>
|
||||
<Route path="/" element={<Navigate to="/boards" replace />} />
|
||||
<Route
|
||||
path="/"
|
||||
element={
|
||||
isAuthenticated ? (
|
||||
<Navigate to="/boards" replace />
|
||||
) : (
|
||||
<Navigate to="/home" replace />
|
||||
)
|
||||
}
|
||||
/>
|
||||
<Route path="/home" element={<Home />} />
|
||||
<Route path="/login" element={<Login />} />
|
||||
<Route path="/register" element={<Register />} />
|
||||
|
|
|
|||
|
|
@ -1,27 +1,64 @@
|
|||
import { Link } from 'react-router-dom';
|
||||
import { useState } from 'react';
|
||||
import { useApp } from '../context/AppContext';
|
||||
import { useAuth } from '../hooks/useAuth';
|
||||
import { TaskboardLogo } from './TaskboardLogo';
|
||||
|
||||
const MenuIcon = () => (
|
||||
<svg
|
||||
xmlns="http://www.w3.org/2000/svg"
|
||||
width="24"
|
||||
height="24"
|
||||
viewBox="0 0 24 24"
|
||||
fill="none"
|
||||
stroke="currentColor"
|
||||
strokeWidth="2"
|
||||
strokeLinecap="round"
|
||||
strokeLinejoin="round"
|
||||
>
|
||||
<line x1="3" y1="12" x2="21" y2="12"></line>
|
||||
<line x1="3" y1="6" x2="21" y2="6"></line>
|
||||
<line x1="3" y1="18" x2="21" y2="18"></line>
|
||||
</svg>
|
||||
);
|
||||
|
||||
const CloseIcon = () => (
|
||||
<svg
|
||||
xmlns="http://www.w3.org/2000/svg"
|
||||
width="24"
|
||||
height="24"
|
||||
viewBox="0 0 24 24"
|
||||
fill="none"
|
||||
stroke="currentColor"
|
||||
strokeWidth="2"
|
||||
strokeLinecap="round"
|
||||
strokeLinejoin="round"
|
||||
>
|
||||
<line x1="18" y1="6" x2="6" y2="18"></line>
|
||||
<line x1="6" y1="6" x2="18" y2="18"></line>
|
||||
</svg>
|
||||
);
|
||||
|
||||
export function Navbar() {
|
||||
const { user } = useApp();
|
||||
const { logout } = useAuth();
|
||||
const [mobileMenuOpen, setMobileMenuOpen] = useState(false);
|
||||
|
||||
return (
|
||||
<nav className="bg-gray-800 border-b border-gray-700 shadow-md">
|
||||
<div className="max-w-7xl mx-auto px-4 sm:px-6 lg:px-8">
|
||||
<div className="flex items-center justify-between h-16">
|
||||
<div className="flex items-center gap-3">
|
||||
<Link to="/boards" className="hover:opacity-80 transition-opacity">
|
||||
<div className="flex items-center">
|
||||
<Link to="/boards" className="hover:opacity-80 transition-opacity flex-shrink-0">
|
||||
<TaskboardLogo className="h-8 w-auto" />
|
||||
</Link>
|
||||
<Link
|
||||
to="/boards"
|
||||
className="text-xl font-bold text-white hover:text-blue-400 transition-colors"
|
||||
className="text-xl font-bold text-white hover:text-blue-400 transition-colors ml-2"
|
||||
>
|
||||
Taskboard
|
||||
</Link>
|
||||
<div className="ml-10 flex items-baseline space-x-4">
|
||||
<div className="hidden md:flex items-baseline ml-10 space-x-4">
|
||||
<Link
|
||||
to="/home"
|
||||
className="text-gray-300 hover:text-white px-3 py-2 rounded-md text-sm font-medium transition-colors"
|
||||
|
|
@ -39,7 +76,7 @@ export function Navbar() {
|
|||
)}
|
||||
</div>
|
||||
</div>
|
||||
<div className="flex items-center gap-3">
|
||||
<div className="hidden md:flex items-center gap-3">
|
||||
{user ? (
|
||||
<>
|
||||
<span className="text-gray-300 px-3 py-2">{user.username}</span>
|
||||
|
|
@ -67,8 +104,76 @@ export function Navbar() {
|
|||
</>
|
||||
)}
|
||||
</div>
|
||||
<div className="md:hidden flex items-center">
|
||||
<button
|
||||
onClick={() => setMobileMenuOpen(!mobileMenuOpen)}
|
||||
className="text-gray-300 hover:text-white p-2 rounded-md"
|
||||
aria-label="Toggle menu"
|
||||
>
|
||||
{mobileMenuOpen ? <CloseIcon /> : <MenuIcon />}
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{/* Mobile menu */}
|
||||
{mobileMenuOpen && (
|
||||
<div className="md:hidden bg-gray-800 border-t border-gray-700">
|
||||
<div className="px-2 pt-2 pb-3 space-y-1 sm:px-3">
|
||||
<Link
|
||||
to="/home"
|
||||
className="text-gray-300 hover:text-white block px-3 py-2 rounded-md text-base font-medium"
|
||||
onClick={() => setMobileMenuOpen(false)}
|
||||
>
|
||||
Home
|
||||
</Link>
|
||||
|
||||
{user && (
|
||||
<Link
|
||||
to="/boards"
|
||||
className="text-gray-300 hover:text-white block px-3 py-2 rounded-md text-base font-medium"
|
||||
onClick={() => setMobileMenuOpen(false)}
|
||||
>
|
||||
Boards
|
||||
</Link>
|
||||
)}
|
||||
|
||||
<div className="border-t border-gray-700 my-2"></div>
|
||||
|
||||
{user ? (
|
||||
<>
|
||||
<div className="px-3 py-2 text-gray-300 text-base font-medium">{user.username}</div>
|
||||
<button
|
||||
onClick={() => {
|
||||
logout();
|
||||
setMobileMenuOpen(false);
|
||||
}}
|
||||
className="text-gray-300 hover:text-white block w-full text-left px-3 py-2 rounded-md text-base font-medium"
|
||||
>
|
||||
Logout
|
||||
</button>
|
||||
</>
|
||||
) : (
|
||||
<>
|
||||
<Link
|
||||
to="/login"
|
||||
className="text-gray-300 hover:text-white block px-3 py-2 rounded-md text-base font-medium"
|
||||
onClick={() => setMobileMenuOpen(false)}
|
||||
>
|
||||
Login
|
||||
</Link>
|
||||
<Link
|
||||
to="/register"
|
||||
className="bg-blue-600 hover:bg-blue-700 text-white block px-3 py-2 rounded-md text-base font-medium"
|
||||
onClick={() => setMobileMenuOpen(false)}
|
||||
>
|
||||
Register
|
||||
</Link>
|
||||
</>
|
||||
)}
|
||||
</div>
|
||||
</div>
|
||||
)}
|
||||
</nav>
|
||||
);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@ import { TaskboardLogo } from '../components/TaskboardLogo';
|
|||
|
||||
export function Home() {
|
||||
return (
|
||||
<div className="space-y-12">
|
||||
<div className="space-y-12 flex-1 p-8 max-w-7xl mx-auto w-full">
|
||||
<div className="text-center py-12">
|
||||
<div className="flex justify-center mb-6">
|
||||
<TaskboardLogo className="h-16 w-auto" />
|
||||
|
|
|
|||
Loading…
Reference in a new issue