feat: ajout structure projet + config Node 20

This commit is contained in:
UltraLionFr
2025-12-07 00:11:21 +01:00
parent c728019f04
commit 25d49d04f0
60 changed files with 4260 additions and 157 deletions
+213
View File
@@ -0,0 +1,213 @@
"use client";
import { loginWithDiscord } from "@/app/login/actions";
import gsap from "gsap";
import { useEffect, useRef } from "react";
import { SiDiscord } from "react-icons/si";
interface LoginContentProps {
error?: string;
}
export function LoginContent({ error }: LoginContentProps) {
const containerRef = useRef<HTMLDivElement>(null);
const cardRef = useRef<HTMLElement>(null);
const dotsRef = useRef<HTMLDivElement>(null);
const titleRef = useRef<HTMLHeadingElement>(null);
const buttonRef = useRef<HTMLButtonElement>(null);
const errorRef = useRef<HTMLDivElement>(null);
const bgOrb1Ref = useRef<HTMLDivElement>(null);
const bgOrb2Ref = useRef<HTMLDivElement>(null);
const getErrorMessage = (code?: string) => {
if (!code) return null;
if (code === "unauthorized") {
return "Cet utilisateur Discord n'est pas autorisé.";
}
if (code === "oauth_failed") {
return "La connexion avec Discord a échoué. Réessaie.";
}
return "Une erreur est survenue.";
};
const errorMessage = getErrorMessage(error);
useEffect(() => {
const ctx = gsap.context(() => {
const tl = gsap.timeline({ defaults: { ease: "power3.out" } });
gsap.to(bgOrb1Ref.current, {
x: 50,
y: 30,
duration: 8,
repeat: -1,
yoyo: true,
ease: "sine.inOut",
});
gsap.to(bgOrb2Ref.current, {
x: -40,
y: -20,
duration: 6,
repeat: -1,
yoyo: true,
ease: "sine.inOut",
});
tl.fromTo(
cardRef.current,
{ opacity: 0, y: 40, scale: 0.95 },
{ opacity: 1, y: 0, scale: 1, duration: 0.8 }
);
tl.fromTo(
dotsRef.current?.children || [],
{ scale: 0, opacity: 0 },
{
scale: 1,
opacity: 1,
duration: 0.4,
stagger: 0.1,
ease: "back.out(1.7)",
},
"-=0.4"
);
tl.fromTo(
titleRef.current,
{ opacity: 0, clipPath: "inset(0 100% 0 0)" },
{ opacity: 1, clipPath: "inset(0 0% 0 0)", duration: 0.6 },
"-=0.2"
);
if (errorRef.current) {
tl.fromTo(
errorRef.current,
{ opacity: 0, x: -20 },
{ opacity: 1, x: 0, duration: 0.4 },
"-=0.2"
);
}
tl.fromTo(
buttonRef.current,
{ opacity: 0, y: 20 },
{ opacity: 1, y: 0, duration: 0.5 },
"-=0.2"
);
gsap.to(buttonRef.current, {
boxShadow: "0 0 20px rgba(99, 102, 241, 0.3)",
duration: 1.5,
repeat: -1,
yoyo: true,
ease: "sine.inOut",
});
}, containerRef);
return () => ctx.revert();
}, []);
const handleButtonHover = () => {
gsap.to(buttonRef.current, {
scale: 1.02,
duration: 0.3,
ease: "power2.out",
});
};
const handleButtonLeave = () => {
gsap.to(buttonRef.current, {
scale: 1,
duration: 0.3,
ease: "power2.out",
});
};
return (
<div
ref={containerRef}
className="min-h-screen bg-slate-950 text-slate-100 selection:bg-cyan-500/30"
>
{/* Effets de fond */}
<div className="fixed inset-0 overflow-hidden pointer-events-none">
<div
ref={bgOrb1Ref}
className="absolute top-0 left-1/4 w-96 h-96 bg-cyan-500/5 rounded-full blur-3xl"
/>
<div
ref={bgOrb2Ref}
className="absolute bottom-1/4 right-1/4 w-96 h-96 bg-violet-500/5 rounded-full blur-3xl"
/>
<div
className="absolute inset-0 opacity-[0.015]"
style={{
backgroundImage: `url("data:image/svg+xml,%3Csvg viewBox='0 0 256 256' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='noise'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23noise)'/%3E%3C/svg%3E")`,
}}
/>
</div>
{/* Contenu */}
<div className="relative z-10 flex items-center justify-center min-h-screen px-6">
<main
ref={cardRef}
className="w-full max-w-md bg-slate-900/80 border border-slate-700/50 rounded-xl p-8 shadow-lg backdrop-blur opacity-0"
>
{/* Header type terminal */}
<div className="flex items-center gap-2 mb-6 pb-3 border-b border-slate-700/50">
<div ref={dotsRef} className="flex gap-1.5">
<span className="w-3 h-3 rounded-full bg-rose-500/80" />
<span className="w-3 h-3 rounded-full bg-amber-500/80" />
<span className="w-3 h-3 rounded-full bg-emerald-500/80" />
</div>
<span className="text-slate-500 text-xs font-mono ml-2">
~/auth/login/
</span>
</div>
<section className="space-y-5">
<div className="space-y-2">
<h1
ref={titleRef}
className="text-3xl font-bold tracking-tight opacity-0"
>
<span className="bg-linear-to-r from-cyan-400 via-violet-400 to-fuchsia-400 bg-clip-text text-transparent">
Connexion
</span>
</h1>
</div>
{/* Message d'erreur éventuel */}
{errorMessage && (
<div
ref={errorRef}
className="rounded border border-rose-500/40 bg-rose-500/10 px-3 py-2 text-sm text-rose-200 opacity-0"
>
{errorMessage}
</div>
)}
{/* Bouton Discord */}
<form action={loginWithDiscord} className="pt-2">
<button
ref={buttonRef}
type="submit"
onMouseEnter={handleButtonHover}
onMouseLeave={handleButtonLeave}
className="group flex items-center justify-center gap-3 w-full px-4 py-3 rounded-lg
bg-indigo-500/20 hover:bg-indigo-500/30
border border-indigo-400/40 hover:border-indigo-300
text-indigo-100 transition-colors opacity-0 cursor-pointer"
>
<SiDiscord className="w-5 h-5 text-indigo-300 group-hover:text-indigo-100 transition-colors" />
<span className="font-mono text-sm">
Se connecter avec Discord
</span>
</button>
</form>
</section>
</main>
</div>
</div>
);
}
+92
View File
@@ -0,0 +1,92 @@
"use client";
import { BackgroundEffects } from "@/components/layout";
import {
CategoryFilters,
TutorialsGrid,
type Category,
} from "@/components/tutorials";
import { HeroSection } from "@/components/ui";
import type { Tutorial } from "@/lib/tutorials";
import gsap from "gsap";
import { useEffect, useRef } from "react";
interface HomeContentProps {
tutorials: Tutorial[];
categories: Category[];
allTutorialsCount: number;
}
export function HomeContent({
tutorials,
categories,
allTutorialsCount,
}: HomeContentProps) {
const containerRef = useRef<HTMLDivElement>(null);
const heroRef = useRef<HTMLDivElement>(null);
const filtersRef = useRef<HTMLDivElement>(null);
const gridRef = useRef<HTMLDivElement>(null);
useEffect(() => {
const ctx = gsap.context(() => {
const tl = gsap.timeline({ defaults: { ease: "power3.out" } });
// Hero section fade in + slide up
tl.fromTo(
heroRef.current,
{ y: 60, opacity: 0 },
{ y: 0, opacity: 1, duration: 0.8 }
);
// Filters stagger in
tl.fromTo(
filtersRef.current,
{ y: 30, opacity: 0 },
{ y: 0, opacity: 1, duration: 0.6 },
"-=0.4"
);
// Grid cards stagger in
const cards = gridRef.current?.querySelectorAll("article");
if (cards && cards.length > 0) {
tl.fromTo(
cards,
{ y: 50, opacity: 0, scale: 0.95 },
{
y: 0,
opacity: 1,
scale: 1,
duration: 0.6,
stagger: 0.15,
ease: "back.out(1.2)",
},
"-=0.3"
);
}
}, containerRef);
return () => ctx.revert();
}, [tutorials]);
return (
<div
ref={containerRef}
className="min-h-screen bg-slate-950 text-slate-100 selection:bg-cyan-500/30"
>
<BackgroundEffects />
<div className="relative z-10">
<div ref={heroRef} className="opacity-0">
<HeroSection
tutorialsCount={allTutorialsCount}
categoriesCount={categories.length}
/>
</div>
<div ref={filtersRef} className="opacity-0">
<CategoryFilters categories={categories} />
</div>
<div ref={gridRef}>
<TutorialsGrid tutorials={tutorials} />
</div>
</div>
</div>
);
}
+1
View File
@@ -0,0 +1 @@
export { HomeContent } from "./HomeContent";
+3
View File
@@ -0,0 +1,3 @@
export * from "./layout";
export * from "./tutorials";
export * from "./ui";
+14
View File
@@ -0,0 +1,14 @@
export function BackgroundEffects() {
return (
<div className="fixed inset-0 overflow-hidden pointer-events-none">
<div className="absolute top-0 left-1/4 w-96 h-96 bg-cyan-500/5 rounded-full blur-3xl" />
<div className="absolute bottom-1/4 right-1/4 w-96 h-96 bg-violet-500/5 rounded-full blur-3xl" />
<div
className="absolute inset-0 opacity-[0.015]"
style={{
backgroundImage: `url("data:image/svg+xml,%3Csvg viewBox='0 0 256 256' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='noise'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23noise)'/%3E%3C/svg%3E")`,
}}
/>
</div>
);
}
+197
View File
@@ -0,0 +1,197 @@
"use client";
import { siteConfig } from "@/config/site";
import {
GithubOutlined,
LinkedinOutlined,
XOutlined,
} from "@lineiconshq/free-icons";
import { Lineicons } from "@lineiconshq/react-lineicons";
import gsap from "gsap";
import { ScrollTrigger } from "gsap/ScrollTrigger";
import Link from "next/link";
import { useEffect, useRef } from "react";
gsap.registerPlugin(ScrollTrigger);
const socialIcons = {
github: GithubOutlined,
linkedin: LinkedinOutlined,
x: XOutlined,
} as const;
const navLinks = [
{ href: "/", label: "Accueil" },
{ href: "/tutos", label: "Tutoriels" },
{ href: "/dashboard", label: "Dashboard" },
];
export function Footer() {
const footerRef = useRef<HTMLElement>(null);
const contentRef = useRef<HTMLDivElement>(null);
const logoRef = useRef<HTMLDivElement>(null);
const linksRef = useRef<HTMLDivElement>(null);
const socialRef = useRef<HTMLDivElement>(null);
const bottomRef = useRef<HTMLDivElement>(null);
useEffect(() => {
const ctx = gsap.context(() => {
const tl = gsap.timeline({
scrollTrigger: {
trigger: footerRef.current,
start: "top 90%",
toggleActions: "play none none reverse",
},
});
tl.fromTo(
logoRef.current,
{ opacity: 0, y: 30 },
{ opacity: 1, y: 0, duration: 0.6, ease: "power2.out" }
);
tl.fromTo(
linksRef.current?.querySelectorAll("a") || [],
{ opacity: 0, y: 20 },
{
opacity: 1,
y: 0,
duration: 0.4,
stagger: 0.1,
ease: "power2.out",
},
"-=0.3"
);
tl.fromTo(
socialRef.current?.querySelectorAll("a") || [],
{ opacity: 0, scale: 0.8 },
{
opacity: 1,
scale: 1,
duration: 0.4,
stagger: 0.1,
ease: "back.out(1.7)",
},
"-=0.3"
);
tl.fromTo(
bottomRef.current,
{ opacity: 0 },
{ opacity: 1, duration: 0.5 },
"-=0.2"
);
}, footerRef);
return () => ctx.revert();
}, []);
const handleSocialHover = (e: React.MouseEvent, entering: boolean) => {
gsap.to(e.currentTarget, {
scale: entering ? 1.15 : 1,
y: entering ? -3 : 0,
duration: 0.25,
ease: "power2.out",
});
};
return (
<footer
ref={footerRef}
className="relative border-t border-slate-800/50 bg-slate-950"
>
{/* Gradient top border */}
<div className="absolute top-0 left-0 right-0 h-px bg-linear-to-r from-transparent via-cyan-500/50 to-transparent" />
<div ref={contentRef} className="max-w-6xl mx-auto px-6 py-12">
<div className="grid grid-cols-1 md:grid-cols-3 gap-10 md:gap-8">
{/* Logo & description */}
<div ref={logoRef} className="space-y-4">
<Link href="/" className="inline-block group">
<span className="text-xl font-bold text-slate-100 group-hover:text-cyan-400 transition-colors">
{siteConfig.name}
</span>
</Link>
<p className="text-sm text-slate-500 leading-relaxed">
Une collection de guides pratiques. Apprenez à votre
rythme avec des exemples concrets.
</p>
<p className="font-mono text-xs text-slate-600">
tutos.jessy-david.dev
</p>
</div>
{/* Navigation */}
<div ref={linksRef} className="space-y-4">
<h3 className="text-sm font-semibold uppercase tracking-wider text-slate-400">
Navigation
</h3>
<nav className="flex flex-col gap-2">
{navLinks.map((link) => (
<Link
key={link.href}
href={link.href}
className="group relative text-sm text-slate-500 hover:text-cyan-400 transition-colors w-fit"
>
{link.label}
<span className="absolute -bottom-0.5 left-0 h-px w-0 bg-linear-to-r from-cyan-400 to-cyan-500 transition-all duration-600 ease-out group-hover:w-full" />
</Link>
))}
</nav>
</div>
{/* Social */}
<div className="space-y-4">
<h3 className="text-sm font-semibold uppercase tracking-wider text-slate-400">
Suivez-moi
</h3>
<div
ref={socialRef}
className="flex items-center gap-3"
>
{Object.entries(siteConfig.socials).map(
([key, social]) => (
<Link
key={key}
href={social.url}
target="_blank"
rel="noopener noreferrer"
aria-label={social.label}
onMouseEnter={(e) =>
handleSocialHover(e, true)
}
onMouseLeave={(e) =>
handleSocialHover(e, false)
}
className="w-10 h-10 rounded-lg bg-slate-800/50 border border-slate-700/50 flex items-center justify-center text-slate-400 hover:text-cyan-400 hover:border-cyan-500/30 transition-colors"
>
<Lineicons
icon={
socialIcons[
key as keyof typeof socialIcons
]
}
size={20}
/>
</Link>
)
)}
</div>
</div>
</div>
{/* Bottom bar */}
<div
ref={bottomRef}
className="mt-12 pt-6 border-t border-slate-800/50 flex flex-col sm:flex-row items-center justify-between gap-4"
>
<p className="text-xs text-slate-600 font-mono">
&copy; {new Date().getFullYear()} {siteConfig.name}.
Tous droits réservés.
</p>
</div>
</div>
</footer>
);
}
+327
View File
@@ -0,0 +1,327 @@
"use client";
import { useGSAP } from "@gsap/react";
import {
Book1Outlined,
DashboardSquare1Outlined,
Home2Outlined,
} from "@lineiconshq/free-icons";
import { Lineicons } from "@lineiconshq/react-lineicons";
import gsap from "gsap";
import Image from "next/image";
import Link from "next/link";
import { usePathname } from "next/navigation";
import { useRef, useState } from "react";
// Constantes extraites du composant
const NAV_LINKS = [
{ href: "/", label: "Accueil", icon: Home2Outlined },
{ href: "/tutos", label: "Tous les tutos", icon: Book1Outlined },
{ href: "/dashboard", label: "Dashboard", icon: DashboardSquare1Outlined },
] as const;
// Types
type NavLinkType = (typeof NAV_LINKS)[number];
interface NavLinkProps {
link: NavLinkType;
isActive: boolean;
onClick?: () => void;
mobile?: boolean;
}
// Composant NavLink réutilisable
function NavLink({ link, isActive, onClick, mobile = false }: NavLinkProps) {
const baseClass = mobile
? "px-4 py-3 text-sm font-medium rounded-lg transition-colors flex items-center gap-3"
: "relative px-4 py-2 text-sm font-medium transition-colors flex items-center gap-2";
const activeClass = mobile
? "text-cyan-400 bg-cyan-500/10 border-l-2 border-cyan-400"
: "text-cyan-400 active";
const inactiveClass = mobile
? "text-slate-400 hover:text-slate-100 hover:bg-slate-800/50"
: "text-slate-400 hover:text-slate-100";
return (
<Link
href={link.href}
onClick={onClick}
className={`${baseClass} ${isActive ? activeClass : inactiveClass}`}
aria-current={isActive ? "page" : undefined}
>
<Lineicons icon={link.icon} size={mobile ? 20 : 18} />
{link.label}
</Link>
);
}
// Composant SkipLink pour l'accessibilité
function SkipLink() {
return (
<Link
href="#main-content"
className="sr-only focus:not-sr-only focus:absolute focus:top-4 focus:left-4 focus:z-100 focus:px-4 focus:py-2 focus:bg-cyan-500 focus:text-white focus:rounded-lg focus:outline-none"
>
Aller au contenu principal
</Link>
);
}
export function Header() {
const pathname = usePathname();
const headerRef = useRef<HTMLElement>(null);
const logoRef = useRef<HTMLDivElement>(null);
const navRef = useRef<HTMLElement>(null);
const indicatorRef = useRef<HTMLSpanElement>(null);
const mobileMenuRef = useRef<HTMLDivElement>(null);
const [mobileOpen, setMobileOpen] = useState(false);
const isActive = (href: string) => {
if (href === "/") return pathname === "/";
return pathname.startsWith(href);
};
// Animation d'entrée avec useGSAP
useGSAP(
() => {
const prefersReducedMotion = window.matchMedia(
"(prefers-reduced-motion: reduce)"
).matches;
if (prefersReducedMotion) return;
gsap.fromTo(
logoRef.current,
{ opacity: 0, x: -20 },
{ opacity: 1, x: 0, duration: 0.5, ease: "power2.out" }
);
const links = navRef.current?.querySelectorAll("a");
if (links) {
gsap.fromTo(
links,
{ opacity: 0, y: -10 },
{
opacity: 1,
y: 0,
duration: 0.4,
stagger: 0.08,
ease: "power2.out",
delay: 0.2,
}
);
}
},
{ scope: headerRef }
);
// Indicateur animé sur le lien actif
useGSAP(
() => {
if (!navRef.current || !indicatorRef.current) return;
const prefersReducedMotion = window.matchMedia(
"(prefers-reduced-motion: reduce)"
).matches;
const activeLink = navRef.current.querySelector(
"a.active"
) as HTMLElement;
if (activeLink) {
gsap.to(indicatorRef.current, {
x: activeLink.offsetLeft,
width: activeLink.offsetWidth,
duration: prefersReducedMotion ? 0 : 0.3,
ease: "power2.out",
});
}
},
{ scope: headerRef, dependencies: [pathname] }
);
// Animation menu mobile
useGSAP(
() => {
if (!mobileMenuRef.current) return;
const prefersReducedMotion = window.matchMedia(
"(prefers-reduced-motion: reduce)"
).matches;
if (mobileOpen) {
gsap.fromTo(
mobileMenuRef.current,
{ height: 0, opacity: 0 },
{
height: "auto",
opacity: 1,
duration: prefersReducedMotion ? 0 : 0.3,
ease: "power2.out",
}
);
if (!prefersReducedMotion) {
const links = mobileMenuRef.current.querySelectorAll("a");
gsap.fromTo(
links,
{ opacity: 0, x: -15 },
{
opacity: 1,
x: 0,
duration: 0.25,
stagger: 0.05,
delay: 0.1,
}
);
}
} else {
gsap.to(mobileMenuRef.current, {
height: 0,
opacity: 0,
duration: prefersReducedMotion ? 0 : 0.2,
ease: "power2.in",
});
}
},
{ scope: headerRef, dependencies: [mobileOpen] }
);
const handleLogoHover = (enter: boolean) => {
const prefersReducedMotion = window.matchMedia(
"(prefers-reduced-motion: reduce)"
).matches;
if (prefersReducedMotion) return;
const img = logoRef.current?.querySelector("img");
if (!img) return;
gsap.to(img, {
scale: enter ? 1.1 : 1,
duration: 0.25,
ease: "power2.out",
});
};
return (
<>
<SkipLink />
<header
ref={headerRef}
className="sticky top-0 z-50 border-b border-slate-800/50 bg-slate-950/90 backdrop-blur-md"
role="banner"
>
<div className="max-w-6xl mx-auto px-6 h-16 flex items-center justify-between">
{/* Logo */}
<div ref={logoRef}>
<Link
href="/"
onMouseEnter={() => handleLogoHover(true)}
onMouseLeave={() => handleLogoHover(false)}
className="flex items-center gap-3"
aria-label="Jessy David - Accueil"
>
<div className="relative w-10 h-10 rounded-lg overflow-hidden ring-1 ring-slate-700/50 hover:ring-cyan-500/50 transition-shadow">
<Image
src="/logo.webp"
alt=""
width={40}
height={40}
className="object-cover"
priority
/>
</div>
<div className="hidden sm:flex flex-col">
<span className="font-semibold text-slate-100 text-sm">
Jessy David
</span>
<span className="font-mono text-slate-500 text-xs">
tutos.jessy-david.dev
</span>
</div>
</Link>
</div>
{/* Desktop Nav */}
<nav
ref={navRef}
className="hidden md:flex items-center relative"
aria-label="Navigation principale"
>
{/* Indicateur animé */}
<span
ref={indicatorRef}
className="absolute bottom-0 h-0.5 bg-cyan-400 rounded-full pointer-events-none"
style={{ width: 0 }}
aria-hidden="true"
/>
{NAV_LINKS.map((link) => (
<NavLink
key={link.href}
link={link}
isActive={isActive(link.href)}
/>
))}
</nav>
{/* Mobile Button */}
<button
onClick={() => setMobileOpen((prev) => !prev)}
className="md:hidden w-10 h-10 flex flex-col items-center justify-center gap-1.5 rounded-lg bg-slate-800/50 border border-slate-700/50 text-slate-400 hover:text-cyan-400 hover:border-cyan-500/30 transition-colors"
aria-label={
mobileOpen ? "Fermer le menu" : "Ouvrir le menu"
}
aria-expanded={mobileOpen}
aria-controls="mobile-menu"
type="button"
>
<span
className={`block w-5 h-0.5 bg-current rounded-full transition-transform duration-200 ${
mobileOpen ? "rotate-45 translate-y-2" : ""
}`}
aria-hidden="true"
/>
<span
className={`block w-5 h-0.5 bg-current rounded-full transition-opacity duration-200 ${
mobileOpen ? "opacity-0" : ""
}`}
aria-hidden="true"
/>
<span
className={`block w-5 h-0.5 bg-current rounded-full transition-transform duration-200 ${
mobileOpen ? "-rotate-45 -translate-y-2" : ""
}`}
aria-hidden="true"
/>
</button>
</div>
{/* Mobile Menu */}
<div
id="mobile-menu"
ref={mobileMenuRef}
className="md:hidden overflow-hidden border-t border-slate-800/50"
style={{ height: 0, opacity: 0 }}
aria-hidden={!mobileOpen}
>
<nav
className="max-w-6xl mx-auto px-6 py-3 flex flex-col gap-1"
aria-label="Navigation mobile"
>
{NAV_LINKS.map((link) => (
<NavLink
key={link.href}
link={link}
isActive={isActive(link.href)}
onClick={() => setMobileOpen(false)}
mobile
/>
))}
</nav>
</div>
</header>
</>
);
}
+3
View File
@@ -0,0 +1,3 @@
export { BackgroundEffects } from "./BackgroundEffects";
export { Footer } from "./Footer";
export { Header } from "./Header";
+77
View File
@@ -0,0 +1,77 @@
"use client";
import { usePathname, useRouter, useSearchParams } from "next/navigation";
export interface Category {
id: string;
name: string;
color: string;
}
interface CategoryFiltersProps {
categories: Category[];
}
export function CategoryFilters({ categories }: CategoryFiltersProps) {
const router = useRouter();
const pathname = usePathname();
const searchParams = useSearchParams();
const activeCategory = searchParams.get("category");
const handleFilter = (categoryId: string | null) => {
const params = new URLSearchParams(searchParams);
if (categoryId) {
params.set("category", categoryId);
} else {
params.delete("category");
}
const query = params.toString();
router.push(query ? `${pathname}?${query}` : pathname);
};
return (
<section className="max-w-6xl mx-auto px-4 sm:px-6 pb-6 sm:pb-8">
{/* Scroll horizontal sur mobile, wrap sur desktop */}
<div className="flex gap-2 overflow-x-auto pb-2 sm:pb-0 sm:flex-wrap sm:overflow-visible scrollbar-none">
<button
onClick={() => handleFilter(null)}
className={`shrink-0 cursor-pointer px-3 sm:px-4 py-1.5 sm:py-2 rounded-full font-mono text-xs sm:text-sm transition-all border
${
!activeCategory
? "bg-cyan-500/20 text-cyan-400 border-cyan-500/30"
: "bg-slate-800/50 border-slate-700/50 text-slate-400 hover:border-slate-600/50"
}`}
type="button"
>
Tous
</button>
{categories.map((cat) => (
<button
key={cat.id}
onClick={() => handleFilter(cat.id)}
className={`shrink-0 cursor-pointer px-3 sm:px-4 py-1.5 sm:py-2 rounded-full font-mono text-xs sm:text-sm transition-all border
${
activeCategory === cat.id
? ""
: "bg-slate-800/50 border-slate-700/50 hover:border-slate-600/50"
}`}
style={{
color: cat.color,
backgroundColor:
activeCategory === cat.id
? `${cat.color}20`
: undefined,
borderColor:
activeCategory === cat.id
? `${cat.color}50`
: undefined,
}}
type="button"
>
{cat.name}
</button>
))}
</div>
</section>
);
}
+21
View File
@@ -0,0 +1,21 @@
import type { Tutorial } from "@/lib/tutorials";
const colors: Record<string, string> = {
Débutant: "bg-emerald-500/20 text-emerald-400 border-emerald-500/30",
Intermédiaire: "bg-amber-500/20 text-amber-400 border-amber-500/30",
Avancé: "bg-rose-500/20 text-rose-400 border-rose-500/30",
};
interface DifficultyBadgeProps {
level: Tutorial["difficulty"];
}
export function DifficultyBadge({ level }: DifficultyBadgeProps) {
return (
<span
className={`px-2 py-0.5 text-xs font-mono border rounded ${colors[level]}`}
>
{level}
</span>
);
}
+125
View File
@@ -0,0 +1,125 @@
import type { Tutorial } from "@/lib/tutorials";
import Link from "next/link";
import { DifficultyBadge } from "./DifficultyBadge";
interface TutorialCardProps {
tutorial: Tutorial;
}
export function TutorialCard({ tutorial }: TutorialCardProps) {
return (
<Link
href={`/tutos/${tutorial.slug}`}
className="group relative block h-full"
>
<div className="absolute -inset-px bg-linear-to-r from-cyan-500/20 via-violet-500/20 to-fuchsia-500/20 rounded-lg opacity-0 group-hover:opacity-100 transition-opacity duration-500 blur-sm" />
<article className="relative h-full flex flex-col bg-slate-900/80 border border-slate-700/50 rounded-lg p-6 hover:border-slate-600/50 transition-all duration-300">
{/* Terminal header */}
<div className="flex items-center gap-2 mb-4 pb-3 border-b border-slate-700/50">
<div className="flex gap-1.5">
<span className="w-3 h-3 rounded-full bg-rose-500/80" />
<span className="w-3 h-3 rounded-full bg-amber-500/80" />
<span className="w-3 h-3 rounded-full bg-emerald-500/80" />
</div>
<span className="text-slate-500 text-xs font-mono ml-2 truncate">
~/tutos/{tutorial.slug}
</span>
</div>
{/* Content */}
<div className="flex-1 flex flex-col space-y-3">
<div className="flex items-center gap-3 flex-wrap">
<span
className="font-mono text-sm px-2 py-0.5 rounded border"
style={{
backgroundColor: `${tutorial.category.color}20`,
borderColor: `${tutorial.category.color}40`,
color: tutorial.category.color,
}}
>
{tutorial.category.name}
</span>
<DifficultyBadge level={tutorial.difficulty} />
</div>
<h3 className="text-xl font-semibold text-slate-100 group-hover:text-cyan-300 transition-colors">
{tutorial.title}
</h3>
<p className="flex-1 text-slate-400 text-sm leading-relaxed line-clamp-3">
{tutorial.excerpt}
</p>
<div className="flex items-center gap-4 pt-2 text-xs text-slate-500 font-mono">
<span className="flex items-center gap-1">
<svg
className="w-4 h-4"
fill="none"
viewBox="0 0 24 24"
stroke="currentColor"
>
<path
strokeLinecap="round"
strokeLinejoin="round"
strokeWidth={1.5}
d="M8 7V3m8 4V3m-9 8h10M5 21h14a2 2 0 002-2V7a2 2 0 00-2-2H5a2 2 0 00-2 2v12a2 2 0 002 2z"
/>
</svg>
{new Date(tutorial.date).toLocaleDateString(
"fr-FR",
{
day: "numeric",
month: "short",
year: "numeric",
}
)}
</span>
{tutorial.readTime && (
<span className="flex items-center gap-1">
<svg
className="w-4 h-4"
fill="none"
viewBox="0 0 24 24"
stroke="currentColor"
>
<path
strokeLinecap="round"
strokeLinejoin="round"
strokeWidth={1.5}
d="M12 8v4l3 3m6-3a9 9 0 11-18 0 9 9 0 0118 0z"
/>
</svg>
{tutorial.readTime}
</span>
)}
</div>
</div>
{/* Hover prompt */}
<div className="mt-4 pt-3 border-t border-slate-700/50 opacity-0 group-hover:opacity-100 transition-all duration-300">
<div className="flex items-center justify-between mb-2">
<span className="text-slate-300 text-sm font-medium">
Commencer la lecture
</span>
<svg
className="w-5 h-5 text-cyan-400"
fill="none"
viewBox="0 0 24 24"
stroke="currentColor"
>
<path
strokeLinecap="round"
strokeLinejoin="round"
strokeWidth={2}
d="M14 5l7 7m0 0l-7 7m7-7H3"
/>
</svg>
</div>
<div className="h-0.5 bg-slate-700/50 rounded-full overflow-hidden">
<div className="h-full w-0 group-hover:w-full bg-linear-to-r from-cyan-500 to-violet-500 transition-all duration-700 ease-out"></div>
</div>
</div>
</article>
</Link>
);
}
+24
View File
@@ -0,0 +1,24 @@
import type { Tutorial } from "@/lib/tutorials";
import { TutorialCard } from "./TutorialCard";
interface TutorialsGridProps {
tutorials: Tutorial[];
}
export function TutorialsGrid({ tutorials }: TutorialsGridProps) {
return (
<section className="max-w-6xl mx-auto px-4 sm:px-6 pb-12 sm:pb-20">
{tutorials.length === 0 ? (
<p className="text-slate-500 text-sm font-mono text-center">
Aucun tutoriel pour l&apos;instant.
</p>
) : (
<div className="grid gap-4 sm:gap-6 grid-cols-1 sm:grid-cols-2 lg:grid-cols-3">
{tutorials.map((tutorial) => (
<TutorialCard key={tutorial.id} tutorial={tutorial} />
))}
</div>
)}
</section>
);
}
+4
View File
@@ -0,0 +1,4 @@
export { DifficultyBadge } from "./DifficultyBadge";
export { TutorialCard } from "./TutorialCard";
export { CategoryFilters, type Category } from "./CategoryFilters";
export { TutorialsGrid } from "./TutorialsGrid";
+159
View File
@@ -0,0 +1,159 @@
"use client";
import { gsap } from "gsap";
import { useEffect, useRef, useState } from "react";
interface HeroSectionProps {
tutorialsCount: number;
categoriesCount: number;
title?: string | null;
filtered?: boolean;
}
// Effet de décryptage
function useScrambleText(
text: string,
options: {
duration?: number;
delay?: number;
chars?: string;
} = {}
) {
const [displayText, setDisplayText] = useState("");
const {
duration = 1.5,
delay = 0.3,
chars = "!@#$%^&*()_+-=[]{}|;:,.<>?/~`0123456789",
} = options;
useEffect(() => {
const finalText = text;
const length = finalText.length;
let currentIndex = 0;
// Délai initial
const startTimeout = setTimeout(() => {
const scrambleInterval = setInterval(() => {
let result = "";
for (let i = 0; i < length; i++) {
if (i < currentIndex) {
result += finalText[i];
} else if (finalText[i] === " ") {
result += " ";
} else {
// Caractère aléatoire
result +=
chars[Math.floor(Math.random() * chars.length)];
}
}
setDisplayText(result);
}, 30);
// Animation gsap pour révéler progressivement
gsap.to(
{ value: 0 },
{
value: length,
duration,
ease: "power2.inOut",
onUpdate: function () {
currentIndex = Math.floor(this.targets()[0].value);
},
onComplete: () => {
clearInterval(scrambleInterval);
setDisplayText(finalText);
},
}
);
return () => clearInterval(scrambleInterval);
}, delay * 1000);
return () => clearTimeout(startTimeout);
}, [text, duration, delay, chars]);
return displayText;
}
export function HeroSection({
tutorialsCount,
categoriesCount,
title,
filtered = false,
}: HeroSectionProps) {
const commandText = filtered
? `ls --filter="${title}"`
: "cat hello_world.txt";
const scrambledText = useScrambleText(commandText, {
duration: 1.2,
delay: 0.5,
chars: "█▓▒░!@#$%&*<>[]{}|",
});
// Animation du curseur clignotant
const cursorRef = useRef<HTMLSpanElement>(null);
useEffect(() => {
if (cursorRef.current) {
gsap.to(cursorRef.current, {
opacity: 0,
duration: 0.5,
repeat: -1,
yoyo: true,
ease: "power2.inOut",
});
}
}, []);
return (
<section className="max-w-6xl mx-auto px-6 pt-16 pb-12">
<div className="space-y-4">
<div className="flex items-center gap-2 text-slate-500 font-mono text-sm">
<span className="text-emerald-400">$</span>
<span className="relative">
{scrambledText}
<span
ref={cursorRef}
className="inline-block w-2 h-4 bg-emerald-400 ml-0.5 align-middle"
/>
</span>
</div>
<h1 className="text-4xl sm:text-5xl font-bold tracking-tight">
<span className="bg-linear-to-r from-cyan-400 via-violet-400 to-fuchsia-400 bg-clip-text text-transparent">
{title || "Mes Tutoriels"}
</span>
</h1>
<p className="text-slate-400 text-lg max-w-2xl leading-relaxed">
{filtered
? `${tutorialsCount} tutoriel${
tutorialsCount > 1 ? "s" : ""
} dans cette catégorie.`
: "Une collection de guides pratiques. Apprenez à votre rythme avec des exemples concrets."}
</p>
</div>
{/* Stats */}
<div className="mt-10 flex flex-wrap gap-8">
<div className="space-y-1">
<div className="text-3xl font-bold text-slate-100">
{tutorialsCount}
</div>
<div className="text-sm text-slate-500 font-mono">
tutoriel{tutorialsCount > 1 ? "s" : ""}
{filtered ? " (filtrés)" : ""}
</div>
</div>
<div className="space-y-1">
<div className="text-3xl font-bold text-slate-100">
{categoriesCount}
</div>
<div className="text-sm text-slate-500 font-mono">
catégories
</div>
</div>
</div>
</section>
);
}
+62
View File
@@ -0,0 +1,62 @@
"use client";
import { signOut } from "next-auth/react";
import { useState } from "react";
export function LogoutButton() {
const [loading, setLoading] = useState(false);
const handleLogout = async () => {
setLoading(true);
await signOut({ callbackUrl: "/" });
};
return (
<button
onClick={handleLogout}
disabled={loading}
className="cursor-pointer flex items-center gap-2 px-4 py-2 rounded-lg font-mono text-sm
bg-rose-500/10 border border-rose-500/30 text-rose-400
hover:bg-rose-500/20 hover:border-rose-500/50 transition-all
disabled:opacity-50 disabled:cursor-not-allowed"
type="button"
>
{loading ? (
<svg
className="w-4 h-4 animate-spin"
fill="none"
viewBox="0 0 24 24"
>
<circle
className="opacity-25"
cx="12"
cy="12"
r="10"
stroke="currentColor"
strokeWidth="4"
/>
<path
className="opacity-75"
fill="currentColor"
d="M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4z"
/>
</svg>
) : (
<svg
className="w-4 h-4"
fill="none"
viewBox="0 0 24 24"
stroke="currentColor"
>
<path
strokeLinecap="round"
strokeLinejoin="round"
strokeWidth={2}
d="M17 16l4-4m0 0l-4-4m4 4H7m6 4v1a3 3 0 01-3 3H6a3 3 0 01-3-3V7a3 3 0 013-3h4a3 3 0 013 3v1"
/>
</svg>
)}
{loading ? "Déconnexion..." : "Se déconnecter"}
</button>
);
}
+23
View File
@@ -0,0 +1,23 @@
"use client";
import { ArrowLeftOutlined } from "@lineiconshq/free-icons";
import { Lineicons } from "@lineiconshq/react-lineicons";
import Link from "next/link";
export function BackButton() {
return (
<Link
href="/"
className="group inline-flex items-center gap-2 mb-8 px-4 py-2 rounded-lg font-mono text-sm
bg-slate-800/60 border border-slate-700/70
hover:border-cyan-400/60 hover:text-cyan-300 transition-all duration-200"
>
<Lineicons
icon={ArrowLeftOutlined}
size={16}
className="transition-transform duration-200 group-hover:-translate-x-1"
/>
Retour aux tutoriels
</Link>
);
}
+3
View File
@@ -0,0 +1,3 @@
export { BackButton } from "./back-button";
export { HeroSection } from "./HeroSection";
export { LogoutButton } from "./LogoutButton";