feat(ui): glass layout, icon actions and new icon set (#21)
CD — Deployment / deploy (push) Successful in 33s

PR automatique de feat/ui-glass-layout-icons vers main.

---------

Co-authored-by: xEsiah <[email protected]>
Reviewed-on: #21
Reviewed-by: Esiah <[email protected]>
Co-authored-by: Gitea Actions <-[email protected]>
This commit was merged in pull request #21.
This commit is contained in:
Gitea Actions
2026-11-03 22:37:34 +00:00
committed by Esiah
co-authored by Esiah
parent 3542b33c89
commit 82cd712252
79 changed files with 1485 additions and 746 deletions
+76 -37
View File
@@ -1,9 +1,10 @@
import { useState } from "react";
import { createContext, useContext, useEffect, useState, type ReactNode } from "react";
import { NavLink, Outlet } from "react-router-dom";
import { Button, cn } from "../ui/index.js";
import { cn } from "../ui/index.js";
import { useSession } from "../lib/session.js";
import { useI18n } from "../lib/i18n.js";
import { Avatar } from "./Avatar.js";
import { ColorBendsBackdrop } from "./ColorBendsBackdrop.js";
import {
ActivityIcon,
CloseIcon,
@@ -18,6 +19,7 @@ import {
StarIcon,
TrashIcon,
} from "./icons.js";
import { IconAction } from "./IconAction.js";
interface NavItem {
to: string;
@@ -49,10 +51,27 @@ const navClass = ({ isActive }: { isActive: boolean }) =>
: "text-muted-foreground hover:bg-surface-hover hover:text-foreground",
);
type PageHeaderContextValue = {
header: ReactNode | null;
setHeader: (header: ReactNode | null) => void;
};
const PageHeaderContext = createContext<PageHeaderContextValue | null>(null);
export const usePageHeader = (header: ReactNode | null) => {
const ctx = useContext(PageHeaderContext);
useEffect(() => {
if (!ctx) return;
ctx.setHeader(header);
return () => ctx.setHeader(null);
}, [ctx, header]);
};
export const AppShell = () => {
const { user, logout } = useSession();
const { t } = useI18n();
const [menuOpen, setMenuOpen] = useState(false);
const [pageHeader, setPageHeader] = useState<ReactNode | null>(null);
if (!user) return null;
const isAdmin = user.role_slug === "admin";
@@ -88,24 +107,12 @@ export const AppShell = () => {
};
return (
<div className="flex h-dvh overflow-hidden bg-background">
<aside className="hidden w-60 shrink-0 flex-col gap-1 overflow-y-auto 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">
{t("Administration")}
</p>
{ADMIN_NAV.map(renderLink)}
</>
) : null}
<div className="mt-auto pt-3">{renderLink(ACCOUNT_NAV)}</div>
</aside>
<PageHeaderContext.Provider value={{ header: pageHeader, setHeader: setPageHeader }}>
<div className="relative grid h-dvh grid-cols-[auto_1fr] grid-rows-[auto_1fr] overflow-hidden bg-background">
<ColorBendsBackdrop variant="shell" />
<div className="flex min-w-0 flex-1 flex-col">
<header className="z-20 shrink-0 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">
<header className="relative z-50 col-span-2 row-start-1 border-b border-border/50 bg-surface/70 backdrop-blur-md">
<div className="flex w-full items-center justify-between gap-4 px-4 py-3">
<div className="flex items-center gap-3">
<button
type="button"
@@ -116,7 +123,7 @@ export const AppShell = () => {
>
{menuOpen ? <CloseIcon className="h-5 w-5" /> : <MenuIcon className="h-5 w-5" />}
</button>
<span className="lg:hidden">{brand}</span>
{brand}
</div>
<div className="flex items-center gap-3">
@@ -135,30 +142,62 @@ export const AppShell = () => {
hasAvatar={user.has_avatar}
avatarUpdatedAt={user.avatar_updated_at}
/>
<Button
variant="secondary"
size="sm"
iconLeading={<LogoutIcon className="h-3.5 w-3.5" />}
<IconAction
label={t("Déconnexion")}
icon={<LogoutIcon className="h-4 w-4" />}
onClick={() => void logout()}
>
<span className="hidden sm:inline">{t("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>
<div className="min-h-0 flex-1 overflow-y-auto">
<main className="mx-auto w-full max-w-5xl px-4 py-6">
<Outlet />
</main>
<aside className="relative z-40 col-start-1 row-start-2 hidden w-60 flex-col gap-1 overflow-y-auto border-r border-border/50 bg-surface/70 p-3 backdrop-blur-md lg:flex">
{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">
{t("Administration")}
</p>
{ADMIN_NAV.map(renderLink)}
</>
) : null}
<div className="mt-auto pt-3">{renderLink(ACCOUNT_NAV)}</div>
</aside>
{menuOpen ? (
<div className="lg:hidden">
<div className="fixed inset-0 z-40 bg-black/50 backdrop-blur-sm" onClick={() => setMenuOpen(false)} aria-hidden="true" />
<nav className="fixed inset-0 z-50 flex flex-col bg-background/95 backdrop-blur-lg transition-transform duration-300 sm:absolute sm:inset-y-0 sm:left-0 sm:w-72 sm:inset-x-auto">
<div className="flex items-center justify-between border-b border-border/50 px-4 py-3">
{brand}
<button
type="button"
className="text-muted-foreground"
aria-label={t("Fermer le menu")}
onClick={() => setMenuOpen(false)}
>
<CloseIcon className="h-5 w-5" />
</button>
</div>
<div className="flex flex-1 flex-col gap-1 overflow-y-auto p-3">
{allNav.map(renderLink)}
</div>
</nav>
</div>
) : null}
<div className="relative z-10 col-start-2 row-start-2 min-h-0 overflow-hidden">
<div className="h-full w-full bg-surface/30 backdrop-blur-lg">
<div className="flex h-full flex-col">
{pageHeader ? <div className="relative z-30 shrink-0">{pageHeader}</div> : null}
<main className="min-h-0 flex-1 overflow-y-auto overflow-x-hidden px-4 pb-6 pt-4 [scrollbar-gutter:stable]">
<Outlet />
</main>
</div>
</div>
</div>
</div>
</div>
</PageHeaderContext.Provider>
);
};
+20
View File
@@ -0,0 +1,20 @@
import { Outlet } from "react-router-dom";
import { ColorBendsBackdrop } from "./ColorBendsBackdrop.js";
/**
* Coque des ecrans d'authentification : fond carmin animé, puis une colonne
* centree qui contient la page courante. Le degrade garantit la lisibilite des
* cartes et des champs par-dessus le shader, dans les deux themes.
*/
export const AuthLayout = () => (
<main className="relative flex min-h-dvh items-center justify-center overflow-hidden bg-background px-4 py-10">
<ColorBendsBackdrop variant="auth" />
<div
aria-hidden="true"
className="pointer-events-none absolute inset-0 bg-gradient-to-b from-background/10 via-background/40 to-background/80 dark:from-background/25 dark:via-background/50 dark:to-background/85"
/>
<div className="relative z-10 flex w-full justify-center">
<Outlet />
</div>
</main>
);
+12
View File
@@ -0,0 +1,12 @@
.color-bends-container {
position: relative;
width: 100%;
height: 100%;
overflow: hidden;
}
.color-bends-container canvas {
display: block;
width: 100%;
height: 100%;
}
+438
View File
@@ -0,0 +1,438 @@
import { useEffect, useRef, type CSSProperties } from "react";
import {
Clock,
Mesh,
OrthographicCamera,
PlaneGeometry,
Scene,
ShaderMaterial,
SRGBColorSpace,
Vector2,
Vector3,
WebGLRenderer,
type IUniform,
} from "three";
import "./ColorBends.css";
/**
* Fond anime "ColorBends" (React Bits), porte en TypeScript pour le projet.
*
* Le rendu est un shader plein ecran : aucune image, aucun appel reseau. Le
* composant respecte `prefers-reduced-motion` en figeant le shader apres une
* premiere image, et libere le contexte WebGL au demontage.
*/
const MAX_COLORS = 8;
const frag = `
#define MAX_COLORS ${MAX_COLORS}
uniform vec2 uCanvas;
uniform float uTime;
uniform float uSpeed;
uniform vec2 uRot;
uniform int uColorCount;
uniform vec3 uColors[MAX_COLORS];
uniform int uTransparent;
uniform float uScale;
uniform float uFrequency;
uniform float uWarpStrength;
uniform vec2 uPointer;
uniform float uMouseInfluence;
uniform float uParallax;
uniform float uNoise;
uniform int uIterations;
uniform float uIntensity;
uniform float uBandWidth;
varying vec2 vUv;
void main() {
float t = uTime * uSpeed;
vec2 p = vUv * 2.0 - 1.0;
p += uPointer * uParallax * 0.1;
vec2 rp = vec2(p.x * uRot.x - p.y * uRot.y, p.x * uRot.y + p.y * uRot.x);
vec2 q = vec2(rp.x * (uCanvas.x / uCanvas.y), rp.y);
q /= max(uScale, 0.0001);
q /= 0.5 + 0.2 * dot(q, q);
q += 0.2 * cos(t) - 7.56;
vec2 toward = (uPointer - rp);
q += toward * uMouseInfluence * 0.2;
for (int j = 0; j < 5; j++) {
if (j >= uIterations - 1) break;
vec2 rr = sin(1.5 * (q.yx * uFrequency) + 2.0 * cos(q * uFrequency));
q += (rr - q) * 0.15;
}
vec3 col = vec3(0.0);
float a = 1.0;
if (uColorCount > 0) {
vec2 s = q;
vec3 sumCol = vec3(0.0);
float cover = 0.0;
for (int i = 0; i < MAX_COLORS; ++i) {
if (i >= uColorCount) break;
s -= 0.01;
vec2 r = sin(1.5 * (s.yx * uFrequency) + 2.0 * cos(s * uFrequency));
float m0 = length(r + sin(5.0 * r.y * uFrequency - 3.0 * t + float(i)) / 4.0);
float kBelow = clamp(uWarpStrength, 0.0, 1.0);
float kMix = pow(kBelow, 0.3);
float gain = 1.0 + max(uWarpStrength - 1.0, 0.0);
vec2 disp = (r - s) * kBelow;
vec2 warped = s + disp * gain;
float m1 = length(warped + sin(5.0 * warped.y * uFrequency - 3.0 * t + float(i)) / 4.0);
float m = mix(m0, m1, kMix);
float w = 1.0 - exp(-uBandWidth / exp(uBandWidth * m));
sumCol += uColors[i] * w;
cover = max(cover, w);
}
col = clamp(sumCol, 0.0, 1.0);
a = uTransparent > 0 ? cover : 1.0;
} else {
vec2 s = q;
for (int k = 0; k < 3; ++k) {
s -= 0.01;
vec2 r = sin(1.5 * (s.yx * uFrequency) + 2.0 * cos(s * uFrequency));
float m0 = length(r + sin(5.0 * r.y * uFrequency - 3.0 * t + float(k)) / 4.0);
float kBelow = clamp(uWarpStrength, 0.0, 1.0);
float kMix = pow(kBelow, 0.3);
float gain = 1.0 + max(uWarpStrength - 1.0, 0.0);
vec2 disp = (r - s) * kBelow;
vec2 warped = s + disp * gain;
float m1 = length(warped + sin(5.0 * warped.y * uFrequency - 3.0 * t + float(k)) / 4.0);
float m = mix(m0, m1, kMix);
col[k] = 1.0 - exp(-uBandWidth / exp(uBandWidth * m));
}
a = uTransparent > 0 ? max(max(col.r, col.g), col.b) : 1.0;
}
col *= uIntensity;
if (uNoise > 0.0001) {
float n = fract(sin(dot(gl_FragCoord.xy + vec2(uTime), vec2(12.9898, 78.233))) * 43758.5453123);
col += (n - 0.5) * uNoise;
col = clamp(col, 0.0, 1.0);
}
vec3 rgb = (uTransparent > 0) ? col * a : col;
gl_FragColor = vec4(rgb, a);
}
`;
const vert = `
varying vec2 vUv;
void main() {
vUv = uv;
gl_Position = vec4(position, 1.0);
}
`;
export interface ColorBendsProps {
className?: string;
style?: CSSProperties;
rotation?: number;
speed?: number;
colors?: string[];
transparent?: boolean;
autoRotate?: number;
scale?: number;
frequency?: number;
warpStrength?: number;
mouseInfluence?: number;
parallax?: number;
noise?: number;
iterations?: number;
intensity?: number;
bandWidth?: number;
}
interface ColorBendsUniforms {
uCanvas: IUniform<Vector2>;
uTime: IUniform<number>;
uSpeed: IUniform<number>;
uRot: IUniform<Vector2>;
uColorCount: IUniform<number>;
uColors: IUniform<Vector3[]>;
uTransparent: IUniform<number>;
uScale: IUniform<number>;
uFrequency: IUniform<number>;
uWarpStrength: IUniform<number>;
uPointer: IUniform<Vector2>;
uMouseInfluence: IUniform<number>;
uParallax: IUniform<number>;
uNoise: IUniform<number>;
uIterations: IUniform<number>;
uIntensity: IUniform<number>;
uBandWidth: IUniform<number>;
}
const toVec3 = (hex: string): Vector3 => {
const value = hex.replace("#", "").trim();
const channels =
value.length === 3
? [
parseInt(value.slice(0, 1).repeat(2), 16),
parseInt(value.slice(1, 2).repeat(2), 16),
parseInt(value.slice(2, 3).repeat(2), 16),
]
: [
parseInt(value.slice(0, 2), 16),
parseInt(value.slice(2, 4), 16),
parseInt(value.slice(4, 6), 16),
];
return new Vector3(channels[0]! / 255, channels[1]! / 255, channels[2]! / 255);
};
export default function ColorBends({
className,
style,
rotation = 90,
speed = 0.2,
colors = [],
transparent = true,
autoRotate = 0,
scale = 1,
frequency = 1,
warpStrength = 1,
mouseInfluence = 1,
parallax = 0.5,
noise = 0.15,
iterations = 1,
intensity = 1.5,
bandWidth = 6,
}: ColorBendsProps) {
const containerRef = useRef<HTMLDivElement>(null);
const rendererRef = useRef<WebGLRenderer | null>(null);
const rafRef = useRef<number | null>(null);
const renderOnceRef = useRef<(() => void) | null>(null);
const materialRef = useRef<ShaderMaterial | null>(null);
const resizeObserverRef = useRef<ResizeObserver | null>(null);
const rotationRef = useRef(rotation);
const autoRotateRef = useRef(autoRotate);
const pointerTargetRef = useRef(new Vector2(0, 0));
const pointerCurrentRef = useRef(new Vector2(0, 0));
const pointerSmoothRef = useRef(8);
useEffect(() => {
const container = containerRef.current;
if (!container) return;
let renderer: WebGLRenderer;
try {
renderer = new WebGLRenderer({
antialias: false,
powerPreference: "high-performance",
alpha: true,
});
} catch {
// Pas de WebGL (navigateur ancien, materiel bloque) : le fond reste
// simplement absent, l'ecran et le formulaire continuent de fonctionner.
return;
}
const scene = new Scene();
const camera = new OrthographicCamera(-1, 1, 1, -1, 0, 1);
const geometry = new PlaneGeometry(2, 2);
const uColors = Array.from({ length: MAX_COLORS }, () => new Vector3(0, 0, 0));
const material = new ShaderMaterial({
vertexShader: vert,
fragmentShader: frag,
uniforms: {
uCanvas: { value: new Vector2(1, 1) },
uTime: { value: 0 },
uSpeed: { value: speed },
uRot: { value: new Vector2(1, 0) },
uColorCount: { value: 0 },
uColors: { value: uColors },
uTransparent: { value: transparent ? 1 : 0 },
uScale: { value: scale },
uFrequency: { value: frequency },
uWarpStrength: { value: warpStrength },
uPointer: { value: new Vector2(0, 0) },
uMouseInfluence: { value: mouseInfluence },
uParallax: { value: parallax },
uNoise: { value: noise },
uIterations: { value: iterations },
uIntensity: { value: intensity },
uBandWidth: { value: bandWidth },
} satisfies ColorBendsUniforms,
premultipliedAlpha: true,
transparent: true,
});
materialRef.current = material;
const mesh = new Mesh(geometry, material);
scene.add(mesh);
rendererRef.current = renderer;
renderer.outputColorSpace = SRGBColorSpace;
renderer.setPixelRatio(Math.min(window.devicePixelRatio || 1, 2));
renderer.setClearColor(0x000000, transparent ? 0 : 1);
renderer.domElement.style.width = "100%";
renderer.domElement.style.height = "100%";
renderer.domElement.style.display = "block";
container.appendChild(renderer.domElement);
const clock = new Clock();
const motion = window.matchMedia("(prefers-reduced-motion: reduce)");
let reducedMotion = motion.matches;
const handleResize = () => {
const width = container.clientWidth || 1;
const height = container.clientHeight || 1;
renderer.setSize(width, height, false);
material.uniforms.uCanvas!.value.set(width, height);
if (reducedMotion) renderer.render(scene, camera);
};
const renderFrame = () => {
const delta = clock.getDelta();
const elapsed = clock.elapsedTime;
material.uniforms.uTime!.value = elapsed;
const degrees = (rotationRef.current % 360) + autoRotateRef.current * elapsed;
const radians = (degrees * Math.PI) / 180;
material.uniforms.uRot!.value.set(Math.cos(radians), Math.sin(radians));
const current = pointerCurrentRef.current;
current.lerp(pointerTargetRef.current, Math.min(1, delta * pointerSmoothRef.current));
material.uniforms.uPointer!.value.copy(current);
renderer.render(scene, camera);
};
renderOnceRef.current = renderFrame;
const stop = () => {
if (rafRef.current !== null) {
cancelAnimationFrame(rafRef.current);
rafRef.current = null;
}
};
const loop = () => {
renderFrame();
rafRef.current = requestAnimationFrame(loop);
};
const start = () => {
if (!reducedMotion && rafRef.current === null) {
clock.start();
rafRef.current = requestAnimationFrame(loop);
}
};
handleResize();
if (typeof ResizeObserver !== "undefined") {
const observer = new ResizeObserver(handleResize);
observer.observe(container);
resizeObserverRef.current = observer;
} else {
window.addEventListener("resize", handleResize);
}
const handleMotionChange = () => {
reducedMotion = motion.matches;
if (reducedMotion) {
stop();
renderFrame();
} else {
start();
}
};
motion.addEventListener("change", handleMotionChange);
if (reducedMotion) renderFrame();
else start();
return () => {
stop();
motion.removeEventListener("change", handleMotionChange);
if (resizeObserverRef.current) resizeObserverRef.current.disconnect();
else window.removeEventListener("resize", handleResize);
geometry.dispose();
material.dispose();
renderer.dispose();
renderer.forceContextLoss();
if (renderer.domElement.parentElement === container) {
container.removeChild(renderer.domElement);
}
materialRef.current = null;
rendererRef.current = null;
renderOnceRef.current = null;
resizeObserverRef.current = null;
};
// Les uniformes sont mis a jour par l'effet suivant ; ce premier montage ne
// depend donc que du conteneur et ne recree jamais le contexte WebGL.
// eslint-disable-next-line react-hooks/exhaustive-deps
}, []);
useEffect(() => {
const material = materialRef.current;
if (!material) return;
rotationRef.current = rotation;
autoRotateRef.current = autoRotate;
material.uniforms.uSpeed!.value = speed;
material.uniforms.uScale!.value = scale;
material.uniforms.uFrequency!.value = frequency;
material.uniforms.uWarpStrength!.value = warpStrength;
material.uniforms.uMouseInfluence!.value = mouseInfluence;
material.uniforms.uParallax!.value = parallax;
material.uniforms.uNoise!.value = noise;
material.uniforms.uIterations!.value = iterations;
material.uniforms.uIntensity!.value = intensity;
material.uniforms.uBandWidth!.value = bandWidth;
const parsed = colors.filter(Boolean).slice(0, MAX_COLORS).map(toVec3);
const target = material.uniforms.uColors!.value as Vector3[];
for (let index = 0; index < MAX_COLORS; index += 1) {
const vector = target[index]!;
if (index < parsed.length) vector.copy(parsed[index]!);
else vector.set(0, 0, 0);
}
material.uniforms.uColorCount!.value = parsed.length;
material.uniforms.uTransparent!.value = transparent ? 1 : 0;
if (rendererRef.current) rendererRef.current.setClearColor(0x000000, transparent ? 0 : 1);
// Sans boucle (prefers-reduced-motion), les uniformes viennent de changer :
// il faut une image de plus pour que la palette soit réellement appliquée.
if (rafRef.current === null) renderOnceRef.current?.();
}, [
rotation,
autoRotate,
speed,
scale,
frequency,
warpStrength,
mouseInfluence,
parallax,
noise,
iterations,
intensity,
bandWidth,
colors,
transparent,
]);
useEffect(() => {
const container = containerRef.current;
if (!container) return;
const handlePointerMove = (event: PointerEvent) => {
const rect = container.getBoundingClientRect();
const x = ((event.clientX - rect.left) / (rect.width || 1)) * 2 - 1;
const y = -(((event.clientY - rect.top) / (rect.height || 1)) * 2 - 1);
pointerTargetRef.current.set(x, y);
};
// Ecoute au niveau de la fenetre : le fond peut etre recouvert par la
// coque ou par une carte, et doit reagir quand meme au mouvement.
window.addEventListener("pointermove", handlePointerMove, { passive: true });
return () => {
window.removeEventListener("pointermove", handlePointerMove);
};
}, []);
return <div ref={containerRef} className={`color-bends-container ${className ?? ""}`} style={style} />;
}
@@ -0,0 +1,86 @@
import { lazy, Suspense } from "react";
import { COHAISE_BENDS } from "./colorBendsPalette.js";
import type { ColorBendsProps } from "./ColorBends.js";
const ColorBends = lazy(() => import("./ColorBends.js"));
type BackdropVariant = "auth" | "shell" | "chat";
type BackdropPreset = Omit<ColorBendsProps, "colors" | "transparent" | "className"> & {
className: string;
};
/**
* Fond carmin partage par les ecrans d'authentification, la coque connectee
* et le salon de discussion. Le composant WebGL reste charge a la demande :
* seuls les presets sont dans le bundle initial.
*/
const PRESETS: Record<BackdropVariant, BackdropPreset> = {
auth: {
className: "opacity-[0.55] dark:opacity-[0.7]",
rotation: 90,
speed: 0.18,
scale: 1,
frequency: 1,
warpStrength: 1,
mouseInfluence: 0.6,
parallax: 0.4,
noise: 0.08,
iterations: 2,
intensity: 1.15,
bandWidth: 5,
},
shell: {
className: "opacity-[0.85] dark:opacity-[0.9]",
rotation: 90,
speed: 0.18,
scale: 1,
frequency: 1,
warpStrength: 1,
mouseInfluence: 0.6,
parallax: 0.4,
noise: 0.08,
iterations: 2,
intensity: 1.3,
bandWidth: 5,
},
chat: {
className: "opacity-[0.3] dark:opacity-[0.42]",
rotation: 90,
speed: 0.1,
scale: 1.05,
frequency: 0.95,
warpStrength: 0.9,
mouseInfluence: 0.3,
parallax: 0.25,
noise: 0.05,
iterations: 1,
intensity: 0.8,
bandWidth: 4.5,
},
};
export const ColorBendsBackdrop = ({
variant,
className,
}: {
variant: BackdropVariant;
className?: string;
}) => {
const { className: presetClassName, ...preset } = PRESETS[variant];
return (
<div
aria-hidden="true"
className={`pointer-events-none absolute inset-0 z-0 ${className ?? ""}`}
>
<Suspense fallback={null}>
<ColorBends
{...preset}
colors={COHAISE_BENDS}
transparent
className={presetClassName}
/>
</Suspense>
</div>
);
};
+13 -11
View File
@@ -21,6 +21,7 @@ import { getLocale } from "../lib/locale.js";
import { useSession } from "../lib/session.js";
import { useConfirm } from "./confirm.js";
import { Avatar } from "./Avatar.js";
import { ColorBendsBackdrop } from "./ColorBendsBackdrop.js";
import { IconAction } from "./IconAction.js";
import { Alert, Badge, EmptyState } from "./feedback.js";
import {
@@ -359,8 +360,9 @@ export const FolderChat = ({ folder, onClose }: { folder: ChatFolder; onClose: (
);
return (
<div className="fixed inset-0 z-40 flex flex-col bg-background">
<div className="relative flex h-full min-h-0">
<div className="fixed inset-0 z-40 flex flex-col overflow-hidden bg-background">
<ColorBendsBackdrop variant="chat" />
<div className="relative z-10 flex h-full min-h-0">
<aside
className={cn(
"absolute inset-y-0 left-0 z-20 flex w-64 flex-col border-r border-border bg-surface transition-transform md:static md:z-auto md:translate-x-0",
@@ -437,7 +439,7 @@ export const FolderChat = ({ folder, onClose }: { folder: ChatFolder; onClose: (
type="button"
onClick={onClose}
aria-label={t("Fermer la discussion")}
className="rounded-sm text-muted-foreground transition-colors hover:text-foreground focus-visible:ring-ring focus-visible:ring-2 focus-visible:outline-none"
className="rounded-md p-1 text-muted-foreground transition-all hover:-translate-y-0.5 hover:bg-surface/60 hover:text-foreground hover:shadow-sm focus-visible:ring-ring focus-visible:ring-2 focus-visible:outline-none"
>
<CloseIcon className="h-5 w-5" />
</button>
@@ -672,15 +674,15 @@ export const FolderChat = ({ folder, onClose }: { folder: ChatFolder; onClose: (
aria-label={t("Votre message")}
className="max-h-40 min-h-[2.5rem] flex-1 resize-y rounded-sm border border-border-control bg-surface px-3 py-2 text-sm text-foreground placeholder:text-subtle-foreground focus-visible:border-border-strong focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 focus-visible:ring-offset-background focus-visible:outline-none"
/>
<Button
type="submit"
size="md"
<IconAction
label={t("Envoyer")}
icon={<SendIcon className="h-4 w-4" />}
isLoading={sending}
disabled={draft.trim().length === 0}
iconLeading={<SendIcon className="h-4 w-4" />}
>
<span className="hidden sm:inline">{t("Envoyer")}</span>
</Button>
onClick={(event) => {
event.preventDefault();
void send(event as any);
}}
/>
</form>
</section>
</div>
+2 -2
View File
@@ -23,8 +23,8 @@ export const IconAction = ({
disabled={isLoading}
onClick={onClick}
className={cn(
"relative inline-flex h-8 w-8 shrink-0 items-center justify-center rounded-sm text-muted-foreground transition-colors",
"hover:bg-surface-hover hover:text-foreground disabled:pointer-events-none disabled:opacity-50",
"group relative inline-flex h-8 w-8 shrink-0 items-center justify-center rounded-md text-muted-foreground transition-all",
"hover:-translate-y-0.5 hover:bg-surface/60 hover:text-foreground hover:shadow-sm backdrop-blur-sm disabled:pointer-events-none disabled:opacity-50",
tone === "danger" && "hover:text-destructive",
)}
>
@@ -0,0 +1,2 @@
/** Palette carmin de la marque, alignee sur `tokens.css`. */
export const COHAISE_BENDS = ["#b71c1c", "#c92a2a", "#8f1116", "#5e0a14"];
+32 -15
View File
@@ -10,7 +10,8 @@ import {
} from "../lib/api.js";
import { useI18n } from "../lib/i18n.js";
import { Alert, Modal } from "./feedback.js";
import { TrashIcon } from "./icons.js";
import { PlusIcon, TrashIcon } from "./icons.js";
import { IconAction } from "./IconAction.js";
const LEVELS = ["read", "write", "admin"] as const;
const LEVEL_LABEL: Record<string, string> = {
@@ -69,13 +70,21 @@ export const CreateFolderDialog = ({
onChange={(event) => setName(event.target.value)}
/>
{error ? <Alert>{error}</Alert> : null}
<div className="flex justify-end gap-2">
<Button variant="ghost" size="md" onClick={onClose}>
{t("Annuler")}
</Button>
<Button type="submit" size="md" isLoading={busy}>
{t("Créer")}
</Button>
<div className="flex justify-end gap-1">
<IconAction
label={t("Annuler")}
icon={<img src="/icons/close.png" alt="" className="h-4 w-4 object-contain" />}
onClick={onClose}
/>
<IconAction
label={t("Créer")}
icon={<PlusIcon className="h-4 w-4" />}
isLoading={busy}
onClick={(e) => {
e.preventDefault();
void submit(e as any);
}}
/>
</div>
</form>
</Modal>
@@ -234,13 +243,21 @@ export const MoveDialog = ({
</label>
)}
{error ? <Alert>{error}</Alert> : null}
<div className="flex justify-end gap-2">
<Button variant="ghost" size="md" onClick={onClose}>
{t("Annuler")}
</Button>
<Button type="submit" size="md" isLoading={busy} disabled={entries === null}>
{t("Déplacer")}
</Button>
<div className="flex justify-end gap-1">
<IconAction
label={t("Annuler")}
icon={<img src="/icons/close.png" alt="" className="h-4 w-4 object-contain" />}
onClick={onClose}
/>
<IconAction
label={t("Déplacer")}
icon={<img src="/icons/move.png" alt="" className="h-4 w-4 object-contain" />}
isLoading={busy}
onClick={(e) => {
e.preventDefault();
void submit(e as any);
}}
/>
</div>
</form>
</Modal>
+26 -18
View File
@@ -1,7 +1,8 @@
import { useEffect, type ReactNode } from "react";
import { useEffect, useMemo, type ReactNode } from "react";
import { cn } from "../ui/index.js";
import { useI18n } from "../lib/i18n.js";
import { CloseIcon } from "./icons.js";
import { usePageHeader } from "./AppShell.js";
export const Modal = ({
open,
@@ -52,7 +53,7 @@ export const Modal = ({
type="button"
onClick={onClose}
aria-label={t("Fermer")}
className="rounded-sm text-muted-foreground transition-colors hover:text-foreground focus-visible:ring-ring focus-visible:ring-2 focus-visible:outline-none"
className="rounded-md p-1 text-muted-foreground transition-all hover:-translate-y-0.5 hover:bg-surface/60 hover:text-foreground hover:shadow-sm focus-visible:ring-ring focus-visible:ring-2 focus-visible:outline-none"
>
<CloseIcon className="h-5 w-5" />
</button>
@@ -97,22 +98,29 @@ export const PageHeader = ({
description?: string;
actions?: ReactNode;
toolbar?: ReactNode;
}) => (
<header className="sticky top-0 z-10 -mx-4 flex flex-col gap-3 border-b border-border bg-background px-4 py-4">
<div className="flex flex-col gap-3 sm:flex-row sm:items-end sm:justify-between">
<div>
<h1 className="font-display text-base font-semibold uppercase tracking-label text-foreground">
{title}
</h1>
{description ? (
<p className="mt-1 max-w-2xl text-sm leading-relaxed text-muted-foreground">{description}</p>
) : null}
</div>
{actions ? <div className="flex flex-wrap items-center gap-2">{actions}</div> : null}
</div>
{toolbar ? <div className="flex flex-col gap-3">{toolbar}</div> : null}
</header>
);
}) => {
const header = useMemo(
() => (
<header className="flex flex-col gap-3 border-b border-border/50 bg-surface/70 px-4 py-4 backdrop-blur-md">
<div className="flex flex-col gap-3 sm:flex-row sm:items-end sm:justify-between">
<div>
<h1 className="font-display text-base font-semibold uppercase tracking-label text-foreground">
{title}
</h1>
{description ? (
<p className="mt-1 max-w-2xl text-sm leading-relaxed text-muted-foreground">{description}</p>
) : null}
</div>
{actions ? <div className="flex flex-wrap items-center gap-2">{actions}</div> : null}
</div>
{toolbar ? <div className="flex flex-col gap-3">{toolbar}</div> : null}
</header>
),
[title, description, actions, toolbar],
);
usePageHeader(header);
return null;
};
export const EmptyState = ({
icon,
+53 -126
View File
@@ -1,221 +1,148 @@
import type { SVGProps } from "react";
import type { ImgHTMLAttributes } from "react";
type IconProps = SVGProps<SVGSVGElement>;
type IconProps = Omit<ImgHTMLAttributes<HTMLImageElement>, "src" | "alt"> & {
filled?: boolean;
};
const base = (props: IconProps) => ({
viewBox: "0 0 24 24",
fill: "none",
stroke: "currentColor",
strokeWidth: 1.6,
strokeLinecap: "round" as const,
strokeLinejoin: "round" as const,
"aria-hidden": true,
...props,
});
const ImgIcon = ({
src,
className = "",
...props
}: { src: string } & IconProps) => (
<img
src={src}
alt=""
aria-hidden="true"
className={`inline-block h-4 w-4 object-contain ${className}`}
{...props}
/>
);
export const FolderIcon = (props: IconProps) => (
<svg {...base(props)}>
<path d="M3 7.5A1.5 1.5 0 0 1 4.5 6h4l2 2.5h7A1.5 1.5 0 0 1 19 10v7.5A1.5 1.5 0 0 1 17.5 19h-13A1.5 1.5 0 0 1 3 17.5Z" />
</svg>
<ImgIcon src="/icons/folder.png" {...props} />
);
export const FileIcon = (props: IconProps) => (
<svg {...base(props)}>
<path d="M6 3.5h7l5 5v12A1.5 1.5 0 0 1 16.5 22h-10A1.5 1.5 0 0 1 5 20.5v-16A1.5 1.5 0 0 1 6 3Z" />
<path d="M13 3.5v5h5" />
</svg>
<ImgIcon src="/icons/document.png" {...props} />
);
export const ImageIcon = (props: IconProps) => (
<svg {...base(props)}>
<rect x="3" y="4" width="18" height="16" rx="2" />
<circle cx="8.5" cy="9.5" r="1.5" />
<path d="m4 17 4.5-4.5a1.5 1.5 0 0 1 2.1 0L15 17m1.5-2 1.2-1.2a1.5 1.5 0 0 1 2.1 0L21 15" />
</svg>
<ImgIcon src="/icons/picture.png" {...props} />
);
export const PlayIcon = (props: IconProps) => (
<svg {...base(props)}>
<path d="M8 5.5v13l11-6.5Z" fill="currentColor" stroke="none" />
</svg>
<ImgIcon src="/icons/file.png" {...props} />
);
export const AudioIcon = (props: IconProps) => (
<svg {...base(props)}>
<path d="M9 17V5l10-2v12" />
<circle cx="6.5" cy="17.5" r="2.5" />
<circle cx="16.5" cy="15.5" r="2.5" />
</svg>
<ImgIcon src="/icons/file.png" {...props} />
);
export const ArchiveIcon = (props: IconProps) => (
<svg {...base(props)}>
<path d="M3 7.5A1.5 1.5 0 0 1 4.5 6h4l2 2.5h7A1.5 1.5 0 0 1 19 10v7.5A1.5 1.5 0 0 1 17.5 19h-13A1.5 1.5 0 0 1 3 17.5Z" />
<path d="M11 11.5h2m-2 3h2m-2 3h2" />
</svg>
<ImgIcon src="/icons/folder.png" {...props} />
);
export const UploadIcon = (props: IconProps) => (
<svg {...base(props)}>
<path d="M12 16V4m0 0L7.5 8.5M12 4l4.5 4.5M4 17v1.5A1.5 1.5 0 0 0 5.5 20h13a1.5 1.5 0 0 0 1.5-1.5V17" />
</svg>
<ImgIcon src="/icons/upload.png" {...props} />
);
export const DownloadIcon = (props: IconProps) => (
<svg {...base(props)}>
<path d="M12 4v12m0 0-4.5-4.5M12 16l4.5-4.5M4 17v1.5A1.5 1.5 0 0 0 5.5 20h13a1.5 1.5 0 0 0 1.5-1.5V17" />
</svg>
<ImgIcon src="/icons/download.png" {...props} />
);
export const PlusIcon = (props: IconProps) => (
<svg {...base(props)}>
<path d="M12 5v14M5 12h14" />
</svg>
<ImgIcon src="/icons/plus.png" {...props} />
);
export const TrashIcon = (props: IconProps) => (
<svg {...base(props)}>
<path d="M4 7h16M9 7V5.5A1.5 1.5 0 0 1 10.5 4h3A1.5 1.5 0 0 1 15 5.5V7m-8 0 .7 11.1A1.5 1.5 0 0 0 9.2 19.6h5.6a1.5 1.5 0 0 0 1.5-1.5L17 7" />
</svg>
<ImgIcon src="/icons/trash-can.png" {...props} />
);
export const RestoreIcon = (props: IconProps) => (
<svg {...base(props)}>
<path d="M4 12a8 8 0 1 0 2.3-5.6M4 4v4h4" />
</svg>
<ImgIcon src="/icons/synchronize.png" {...props} />
);
export const RefreshIcon = (props: IconProps) => (
<svg {...base(props)}>
<path d="M20 12a8 8 0 1 1-2.3-5.6M20 4v4h-4" />
</svg>
<ImgIcon src="/icons/synchronize.png" {...props} />
);
export const StarIcon = ({ filled, ...props }: IconProps & { filled?: boolean }) => (
<svg {...base(props)} fill={filled ? "currentColor" : "none"}>
<path d="m12 3.5 2.6 5.3 5.9.9-4.2 4.1 1 5.8L12 20.8l-5.3 2.8 1-5.8L3.5 14l5.9-.9Z" />
</svg>
export const StarIcon = (props: IconProps) => (
<ImgIcon src="/icons/favorite.png" {...props} />
);
export const SearchIcon = (props: IconProps) => (
<svg {...base(props)}>
<circle cx="11" cy="11" r="7" />
<path d="m20 20-3.5-3.5" />
</svg>
<ImgIcon src="/icons/search.png" {...props} />
);
export const UsersIcon = (props: IconProps) => (
<svg {...base(props)}>
<circle cx="9" cy="8" r="3.5" />
<path d="M3.5 20a5.5 5.5 0 0 1 11 0M16 5.5a3 3 0 0 1 0 6M16.5 20a5.5 1.5 0 0 0-2.2-4.3" />
</svg>
<ImgIcon src="/icons/accounts.png" {...props} />
);
export const SettingsIcon = (props: IconProps) => (
<svg {...base(props)}>
<circle cx="12" cy="12" r="3" />
<path d="M19.4 15a1.7 1.7 0 0 0 .3 1.9l.1.1a2 2 0 1 1-2.8 2.8l-.1-.1a1.7 1.7 0 0 0-2.9 1.2 2 2 0 1 1-4 0 1.7 1.7 0 0 0-2.9-1.2l-.1.1a2 2 0 1 1-2.8-2.8l.1-.1A1.7 1.7 0 0 0 2.6 15a2 2 0 1 1 0-4 1.7 1.7 0 0 0 1.2-2.9l-.1-.1a2 2 0 1 1 2.8-2.8l.1.1A1.7 1.7 0 0 0 9 4.6a2 2 0 1 1 4 0 1.7 1.7 0 0 0 2.9 1.2l.1-.1a2 2 0 1 1 2.8 2.8l-.1.1a1.7 1.7 0 0 0 1.2 2.9 2 2 0 1 1 0 4 1.7 1.7 0 0 0-1.5 1Z" />
</svg>
<ImgIcon src="/icons/personal-settings.png" {...props} />
);
export const LogoutIcon = (props: IconProps) => (
<svg {...base(props)}>
<path d="M15 4h2.5A1.5 1.5 0 0 1 19 5.5v13a1.5 1.5 0 0 1-1.5 1.5H15M10 8l-4 4 4 4M6 12h9" />
</svg>
<ImgIcon src="/icons/sign-out.png" {...props} />
);
export const ShieldIcon = (props: IconProps) => (
<svg {...base(props)}>
<path d="M12 3 5 6v5c0 4.3 3 8.2 7 9.5 4-1.3 7-5.2 7-9.5V6Z" />
<path d="m9 12 2 2 4-4" />
</svg>
<ImgIcon src="/icons/accounts.png" {...props} />
);
export const HardDriveIcon = (props: IconProps) => (
<svg {...base(props)}>
<rect x="3" y="4" width="18" height="16" rx="2" />
<path d="M3 14h18M7 17h.01M11 17h.01" />
</svg>
<ImgIcon src="/icons/storage.png" {...props} />
);
export const ActivityIcon = (props: IconProps) => (
<svg {...base(props)}>
<path d="M3 12h4l3 8 4-16 3 8h4" />
</svg>
<ImgIcon src="/icons/activity.png" {...props} />
);
export const SearchNavIcon = (props: IconProps) => (
<svg {...base(props)}>
<circle cx="11" cy="11" r="7" />
<path d="m20 20-3.5-3.5" />
</svg>
<ImgIcon src="/icons/search.png" {...props} />
);
export const ShareIcon = (props: IconProps) => (
<svg {...base(props)}>
<circle cx="18" cy="5" r="2.5" />
<circle cx="6" cy="12" r="2.5" />
<circle cx="18" cy="19" r="2.5" />
<path d="m8.2 10.8 7.6-4.6M8.2 13.2l7.6 4.6" />
</svg>
<ImgIcon src="/icons/share.png" {...props} />
);
export const MenuIcon = (props: IconProps) => (
<svg {...base(props)}>
<path d="M4 7h16M4 12h16M4 17h16" />
</svg>
<ImgIcon src="/icons/menu.png" {...props} />
);
export const CloseIcon = (props: IconProps) => (
<svg {...base(props)}>
<path d="M6 6l12 12M18 6 6 18" />
</svg>
<ImgIcon src="/icons/close.png" {...props} />
);
export const ArrowLeftIcon = (props: IconProps) => (
<svg {...base(props)}>
<path d="M19 12H5M11 18l-6-6 6-6" />
</svg>
<ImgIcon src="/icons/back.png" {...props} />
);
export const ArrowRightIcon = (props: IconProps) => (
<svg {...base(props)}>
<path d="M5 12h14M13 6l6 6-6 6" />
</svg>
<ImgIcon
src="/icons/back.png"
{...props}
style={{ transform: "rotate(180deg)", ...((props.style as any) || {}) }}
/>
);
export const PenIcon = (props: IconProps) => (
<svg {...base(props)}>
<path d="M4 20h4L18.5 9.5a2.1 2.1 0 0 0-3-3L5 17v3Z" />
<path d="m13.5 6.5 3 3" />
</svg>
<ImgIcon src="/icons/edit-pencil.png" {...props} />
);
/** Epingle : tete du pushpin en haut, pointe en bas. */
export const PinIcon = (props: IconProps) => (
<svg {...base(props)}>
<path d="M9 3.5h6l-.8 5.2 3.3 3.1H6.5l3.3-3.1Z" />
<path d="M12 11.8V20.5" />
</svg>
<ImgIcon src="/icons/file.png" {...props} />
);
export const MoveIcon = (props: IconProps) => (
<svg {...base(props)}>
<path d="M12 4v16M4 12h16" />
<path d="m9 7 3-3 3 3M9 17l3 3 3-3M7 9l-3 3 3 3M17 9l3 3-3 3" />
</svg>
<ImgIcon src="/icons/synchronize.png" {...props} />
);
export const ChatIcon = (props: IconProps) => (
<svg {...base(props)}>
<path d="M20 15.5a1.5 1.5 0 0 1-1.5 1.5H8l-4 3.5V6.5A1.5 1.5 0 0 1 5.5 5h13A1.5 1.5 0 0 1 20 6.5Z" />
<path d="M8 9.5h8M8 13h5" />
</svg>
<ImgIcon src="/icons/speech-bubble.png" {...props} />
);
export const SendIcon = (props: IconProps) => (
<svg {...base(props)}>
<path d="M4.5 12 20 4.5 15 20l-3.5-6.5L4.5 12Z" />
<path d="m11.5 13.5 4-4" />
</svg>
<ImgIcon src="/icons/send.png" {...props} />
);