feat: logo et favicon, confirmation modale, fil d'ariane, e-mails sombres (#4)
CD — Déploiement / deploy (push) Failing after 25s
CD — Déploiement / deploy (push) Failing after 25s
- logo embarque dans les e-mails (CID) et gabarit repense en mode sombre - favicon multi-tailles + icone PNG, logo a gauche du titre (app et auth) - modale de confirmation animee a la place de window.confirm - bouton retour et fil d'ariane dans l'explorateur --------- Co-authored-by: xEsiah <[email protected]> Reviewed-on: #4 Reviewed-by: Esiah <[email protected]> Co-authored-by: Gitea Actions <-[email protected]>
This commit was merged in pull request #4.
This commit is contained in:
@@ -0,0 +1,159 @@
|
||||
import { useState } from "react";
|
||||
import { NavLink, Outlet } from "react-router-dom";
|
||||
import { Button, cn } from "../ui/index.js";
|
||||
import { useSession } from "../lib/session.js";
|
||||
import {
|
||||
ActivityIcon,
|
||||
CloseIcon,
|
||||
FolderIcon,
|
||||
HardDriveIcon,
|
||||
ImageIcon,
|
||||
LogoutIcon,
|
||||
MenuIcon,
|
||||
SearchNavIcon,
|
||||
SettingsIcon,
|
||||
ShieldIcon,
|
||||
TrashIcon,
|
||||
} from "./icons.js";
|
||||
|
||||
interface NavItem {
|
||||
to: string;
|
||||
label: string;
|
||||
icon: typeof FolderIcon;
|
||||
}
|
||||
|
||||
const NAV: NavItem[] = [
|
||||
{ to: "/files", label: "Fichiers", icon: FolderIcon },
|
||||
{ to: "/search", label: "Recherche", icon: SearchNavIcon },
|
||||
{ to: "/gallery", label: "Galerie", icon: ImageIcon },
|
||||
{ to: "/trash", label: "Corbeille", icon: TrashIcon },
|
||||
];
|
||||
|
||||
const ADMIN_NAV: NavItem[] = [
|
||||
{ to: "/admin/comptes", label: "Comptes", icon: ShieldIcon },
|
||||
{ to: "/admin/stockage", label: "Stockage", icon: HardDriveIcon },
|
||||
{ to: "/admin/audit", label: "Journal", icon: ActivityIcon },
|
||||
];
|
||||
|
||||
const ACCOUNT_NAV: NavItem = { to: "/profile", label: "Mon compte", icon: SettingsIcon };
|
||||
|
||||
const initials = (first: string, last: string): string =>
|
||||
`${first.charAt(0)}${last.charAt(0)}`.toUpperCase() || "?";
|
||||
|
||||
const navClass = ({ isActive }: { isActive: boolean }) =>
|
||||
cn(
|
||||
"flex items-center gap-3 rounded-md px-3 py-2 text-sm font-medium transition-colors",
|
||||
isActive
|
||||
? "bg-accent/10 text-accent"
|
||||
: "text-muted-foreground hover:bg-surface-hover hover:text-foreground",
|
||||
);
|
||||
|
||||
export const AppShell = () => {
|
||||
const { user, logout } = useSession();
|
||||
const [menuOpen, setMenuOpen] = useState(false);
|
||||
if (!user) return null;
|
||||
|
||||
const isAdmin = user.role_slug === "admin";
|
||||
const allNav = [...NAV, ...(isAdmin ? ADMIN_NAV : []), ACCOUNT_NAV];
|
||||
|
||||
const brand = (
|
||||
<NavLink to="/files" className="flex items-center gap-2" onClick={() => setMenuOpen(false)}>
|
||||
<img
|
||||
src="/icon.png"
|
||||
alt=""
|
||||
className="h-7 w-7 shrink-0 rounded-md ring-1 ring-black/5"
|
||||
/>
|
||||
<span className="font-display text-xs font-semibold uppercase tracking-logo text-accent">
|
||||
CoHaiSe
|
||||
</span>
|
||||
<span className="text-border" aria-hidden="true">
|
||||
/
|
||||
</span>
|
||||
<span className="font-display text-xs font-semibold uppercase tracking-label text-foreground">
|
||||
Cloud
|
||||
</span>
|
||||
</NavLink>
|
||||
);
|
||||
|
||||
const renderLink = (item: NavItem) => {
|
||||
const Icon = item.icon;
|
||||
return (
|
||||
<NavLink key={item.to} to={item.to} className={navClass} onClick={() => setMenuOpen(false)}>
|
||||
<Icon className="h-4 w-4" />
|
||||
{item.label}
|
||||
</NavLink>
|
||||
);
|
||||
};
|
||||
|
||||
return (
|
||||
<div className="flex min-h-dvh bg-background">
|
||||
<aside className="hidden w-60 shrink-0 flex-col gap-1 border-r border-border bg-surface p-3 lg:flex">
|
||||
<div className="px-1 py-2">{brand}</div>
|
||||
{NAV.map(renderLink)}
|
||||
{isAdmin ? (
|
||||
<>
|
||||
<p className="mt-3 px-3 py-1 font-display text-[0.6875rem] font-semibold uppercase tracking-label text-subtle-foreground">
|
||||
Administration
|
||||
</p>
|
||||
{ADMIN_NAV.map(renderLink)}
|
||||
</>
|
||||
) : null}
|
||||
<div className="mt-auto pt-3">{renderLink(ACCOUNT_NAV)}</div>
|
||||
</aside>
|
||||
|
||||
<div className="flex min-w-0 flex-1 flex-col">
|
||||
<header className="sticky top-0 z-20 border-b border-border bg-surface">
|
||||
<div className="mx-auto flex w-full max-w-5xl items-center justify-between gap-4 px-4 py-3">
|
||||
<div className="flex items-center gap-3">
|
||||
<button
|
||||
type="button"
|
||||
className="text-muted-foreground lg:hidden"
|
||||
aria-label={menuOpen ? "Fermer le menu" : "Ouvrir le menu"}
|
||||
aria-expanded={menuOpen}
|
||||
onClick={() => setMenuOpen((value) => !value)}
|
||||
>
|
||||
{menuOpen ? <CloseIcon className="h-5 w-5" /> : <MenuIcon className="h-5 w-5" />}
|
||||
</button>
|
||||
<span className="lg:hidden">{brand}</span>
|
||||
</div>
|
||||
|
||||
<div className="flex items-center gap-3">
|
||||
<div className="hidden text-right sm:block">
|
||||
<p className="text-xs font-medium text-foreground">
|
||||
{user.first_name} {user.last_name}
|
||||
</p>
|
||||
<p className="text-[0.6875rem] uppercase tracking-label text-subtle-foreground">
|
||||
{user.role_name}
|
||||
</p>
|
||||
</div>
|
||||
<span
|
||||
className="flex h-9 w-9 shrink-0 items-center justify-center rounded-full border border-border bg-surface text-xs font-semibold text-foreground"
|
||||
aria-hidden="true"
|
||||
>
|
||||
{initials(user.first_name, user.last_name)}
|
||||
</span>
|
||||
<Button
|
||||
variant="secondary"
|
||||
size="sm"
|
||||
iconLeading={<LogoutIcon className="h-3.5 w-3.5" />}
|
||||
onClick={() => void logout()}
|
||||
>
|
||||
<span className="hidden sm:inline">Déconnexion</span>
|
||||
</Button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{menuOpen ? (
|
||||
<nav className="flex flex-col gap-1 border-t border-border px-3 py-2 lg:hidden">
|
||||
{allNav.map(renderLink)}
|
||||
</nav>
|
||||
) : null}
|
||||
</header>
|
||||
|
||||
<main className="mx-auto w-full max-w-5xl flex-1 px-4 py-6">
|
||||
<Outlet />
|
||||
</main>
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
};
|
||||
Reference in New Issue
Block a user