commit 2de4261631bea893a959fe971a1bc7874b968e0b Author: Puechberty Arthur Date: Mon Mar 30 23:26:19 2026 +0200 first commit diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 0000000..c72d98b --- /dev/null +++ b/.dockerignore @@ -0,0 +1,9 @@ +node_modules +.next +.git +.gitignore +*.md +docker-compose.yml +.env* +.vscode +types diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..206757c --- /dev/null +++ b/.gitignore @@ -0,0 +1,47 @@ +# See https://help.github.com/articles/ignoring-files/ for more about ignoring files. + +# dependencies +/node_modules +/.pnp +.pnp.* +.yarn/* +!.yarn/patches +!.yarn/plugins +!.yarn/releases +!.yarn/versions + +# testing +/coverage + +# next.js +/.next/ +/out/ + +# production +/build + +# misc +.DS_Store +*.pem + +# debug +npm-debug.log* +yarn-debug.log* +yarn-error.log* +.pnpm-debug.log* + +# env files (can opt-in for committing if needed) +.env* + +# vercel +.vercel + +# local editor/config +.vscode/ + +# local uploads / deployment helpers +sftp-config.json + +# typescript +*.tsbuildinfo +next-env.d.ts diff --git a/README.md b/README.md new file mode 100644 index 0000000..fcbdeae --- /dev/null +++ b/README.md @@ -0,0 +1,68 @@ +# Imprimer Sudoku + +Application web pour generer des grilles de Sudoku 9x9 et imprimer une feuille A4 contenant: + +- 6 grilles de Sudoku +- 1 page de solutions correspondantes +- 4 niveaux de difficulte (facile, moyen, difficile, expert) + +Site en ligne: [imprimersudoku.arthurp.fr](https://imprimersudoku.arthurp.fr) + +## Objectif + +Permettre d'imprimer rapidement des Sudoku propres et lisibles pour l'entrainement a la maison, en classe ou en atelier. + +## Stack technique + +- Next.js 16 (App Router) +- React 19 +- TypeScript +- CSS global (optimise impression) + +## Lancer en local + +Prerequis: + +- Node.js 20+ +- npm + +Installation et demarrage: + +```bash +npm ci +npm run dev +``` + +Application disponible sur `http://localhost:3000`. + +## Scripts utiles + +```bash +npm run dev +npm run build +npm run start +npm run lint +``` + +## Structure rapide + +- `app/page.tsx`: interface utilisateur, generation et impression +- `app/lib/sudoku.ts`: algorithmes de generation/validation des grilles +- `app/components/SudokuGrid.tsx`: affichage des grilles + +## Deploiement + +Build de production: + +```bash +npm run build +npm run start +``` + +Le projet peut etre deployee sur un serveur Node.js, Docker, ou une plateforme compatible Next.js. + +## SEO et backlinks + +Projet associe au site principal: [imprimersudoku.arthurp.fr](https://imprimersudoku.arthurp.fr). + +Si tu republies ce projet (fork, article, annuaire), conserve ce lien pour credit source et backlink. diff --git a/app/components/SudokuGrid.tsx b/app/components/SudokuGrid.tsx new file mode 100644 index 0000000..0c867cb --- /dev/null +++ b/app/components/SudokuGrid.tsx @@ -0,0 +1,44 @@ +"use client"; + +import { Grid } from "../lib/sudoku"; + +interface SudokuGridProps { + grid: Grid; + index: number; + isSolution?: boolean; +} + +export default function SudokuGrid({ grid, index, isSolution = false }: SudokuGridProps) { + return ( +
+
N°{index + 1}
+ + + {grid.map((row, r) => ( + + {row.map((cell, c) => { + const borderClasses = [ + "sudoku-cell", + c % 3 === 0 ? "border-l-thick" : "", + c === 8 ? "border-r-thick" : "", + r % 3 === 0 ? "border-t-thick" : "", + r === 8 ? "border-b-thick" : "", + ].filter(Boolean).join(" "); + + return ( + + ); + })} + + ))} + +
+ {cell !== 0 ? ( + + {cell} + + ) : null} +
+
+ ); +} diff --git a/app/favicon.ico b/app/favicon.ico new file mode 100644 index 0000000..718d6fe Binary files /dev/null and b/app/favicon.ico differ diff --git a/app/globals.css b/app/globals.css new file mode 100644 index 0000000..b84e2ba --- /dev/null +++ b/app/globals.css @@ -0,0 +1,419 @@ +@import "tailwindcss"; + +:root { + --background: #ffffff; + --foreground: #171717; +} + +@theme inline { + --color-background: var(--background); + --color-foreground: var(--foreground); + --font-sans: var(--font-geist-sans); + --font-mono: var(--font-geist-mono); +} + +body { + background: var(--background); + color: var(--foreground); + font-family: Arial, Helvetica, sans-serif; + margin: 0; + padding: 0; +} + +/* ========== APP LAYOUT ========== */ + +.app-container { + min-height: 100vh; +} + +/* ========== CONTROLS (screen only) ========== */ + +.controls { + text-align: center; + padding: 1.5rem 0.75rem 1.2rem; + background: linear-gradient(135deg, #667eea 0%, #764ba2 100%); + color: white; +} + +.app-title { + font-size: 1.4rem; + font-weight: 700; + margin: 0 0 0.4rem; +} + +.app-subtitle { + font-size: 0.85rem; + opacity: 0.9; + margin: 0 0 1rem; + max-width: 500px; + margin-left: auto; + margin-right: auto; + padding: 0 0.5rem; +} + +.button-group { + display: flex; + flex-wrap: wrap; + gap: 0.4rem; + justify-content: center; + align-items: center; + padding: 0 0.5rem; +} + +.btn-difficulty { + padding: 0.5rem 1rem; + border: 2px solid rgba(255, 255, 255, 0.6); + border-radius: 8px; + background: rgba(255, 255, 255, 0.15); + color: white; + font-size: 0.85rem; + font-weight: 600; + cursor: pointer; + transition: all 0.2s; + flex: 1 1 auto; + min-width: 0; +} + +.btn-difficulty:hover:not(:disabled) { + background: rgba(255, 255, 255, 0.3); + border-color: white; +} + +.btn-difficulty.btn-active { + background: white; + color: #764ba2; + border-color: white; +} + +.btn-difficulty:disabled { + opacity: 0.5; + cursor: not-allowed; +} + +.btn-print { + padding: 0.5rem 1.2rem; + border: none; + border-radius: 8px; + background: #fbbf24; + color: #1a1a1a; + font-size: 0.85rem; + font-weight: 700; + cursor: pointer; + transition: all 0.2s; + width: 100%; + margin-top: 0.3rem; +} + +.btn-print:hover:not(:disabled) { + background: #f59e0b; + transform: scale(1.02); +} + +.btn-print:disabled { + opacity: 0.4; + cursor: not-allowed; +} + +.generating-text { + margin-top: 0.8rem; + font-size: 0.9rem; + animation: pulse 1.2s infinite; +} + +@keyframes pulse { + 0%, 100% { opacity: 1; } + 50% { opacity: 0.4; } +} + +/* ========== RESPONSIVE: TABLET (>=600px) ========== */ + +@media screen and (min-width: 600px) { + .controls { + padding: 2rem 1.5rem 1.5rem; + } + + .app-title { + font-size: 1.8rem; + } + + .app-subtitle { + font-size: 1rem; + } + + .btn-difficulty { + padding: 0.6rem 1.4rem; + font-size: 0.95rem; + flex: 0 1 auto; + } + + .btn-print { + width: auto; + padding: 0.6rem 1.6rem; + font-size: 0.95rem; + margin-top: 0; + margin-left: 0.5rem; + } +} + +/* ========== RESPONSIVE: DESKTOP (>=900px) ========== */ + +@media screen and (min-width: 900px) { + .controls { + padding: 2.5rem 2rem 1.5rem; + } + + .app-title { + font-size: 2rem; + } +} + +/* ========== SEO CONTENT (hidden visually, accessible to crawlers) ========== */ + +.seo-content { + position: absolute; + width: 1px; + height: 1px; + padding: 0; + margin: -1px; + overflow: hidden; + clip: rect(0, 0, 0, 0); + white-space: nowrap; + border: 0; +} + +.seo-content h2 { + font-size: 1rem; + font-weight: 700; + color: #374151; + margin: 0 0 0.5rem; +} + +.seo-content p { + margin: 0; +} + +/* ========== PRINT AREA (visible on screen + print) ========== */ + +.print-area { + padding: 0.5rem; +} + +.print-page { + max-width: 210mm; + margin: 0 auto 1.5rem; + padding: 0.75rem; + background: white; + border: 1px solid #e5e7eb; + border-radius: 8px; + overflow-x: auto; +} + +.page-title { + text-align: center; + font-size: 1.1rem; + font-weight: 700; + margin: 0.2rem 0 0.6rem; + color: #1a1a1a; +} + +.sudoku-grid-container { + display: grid; + grid-template-columns: 1fr; + gap: 0.8rem; + justify-items: center; +} + +@media screen and (min-width: 480px) { + .sudoku-grid-container { + grid-template-columns: repeat(2, 1fr); + gap: 0.6rem 0.8rem; + } +} + +@media screen and (min-width: 600px) { + .print-area { + padding: 1rem; + } + + .print-page { + padding: 1rem; + } + + .page-title { + font-size: 1.3rem; + margin: 0.3rem 0 0.8rem; + } + + .sudoku-grid-container { + gap: 0.8rem 1.2rem; + } +} + +@media screen and (min-width: 900px) { + .print-page { + margin: 0 auto 2rem; + } +} + +/* ========== SUDOKU GRID ========== */ + +.sudoku-container { + text-align: center; +} + +.sudoku-number { + font-size: 0.75rem; + font-weight: 600; + color: #6b7280; + margin: 0 0 0.15rem; +} + +.sudoku-table { + border-collapse: collapse; + width: 100%; + max-width: 270px; +} + +.sudoku-cell { + width: clamp(22px, 4.5vw, 32px); + height: clamp(22px, 4.5vw, 32px); + text-align: center; + vertical-align: middle; + font-size: clamp(0.65rem, 1.8vw, 0.95rem); + font-weight: 500; + border: 1px solid #bbb; + padding: 0; +} + +@media screen and (min-width: 480px) { + .sudoku-cell { + width: clamp(24px, 3.2vw, 30px); + height: clamp(24px, 3.2vw, 30px); + font-size: clamp(0.7rem, 1.5vw, 0.9rem); + } + + .sudoku-table { + max-width: 280px; + } +} + +@media screen and (min-width: 900px) { + .sudoku-cell { + width: 30px; + height: 30px; + font-size: 0.9rem; + } + + .sudoku-table { + max-width: 300px; + } +} + +.border-l-thick { border-left: 2.5px solid #222 !important; } +.border-r-thick { border-right: 2.5px solid #222 !important; } +.border-t-thick { border-top: 2.5px solid #222 !important; } +.border-b-thick { border-bottom: 2.5px solid #222 !important; } + +.given-digit { + color: #1a1a1a; + font-weight: 700; +} + +.solution-digit { + color: #1a1a1a; + font-weight: 500; +} + +/* ========== PRINT STYLES ========== */ + +.no-print { + display: block; +} + +@media print { + @page { + size: A4 portrait; + margin: 8mm 10mm 8mm 10mm; + } + + body { + background: white !important; + color: black !important; + margin: 0; + padding: 0; + -webkit-print-color-adjust: exact; + print-color-adjust: exact; + } + + .no-print { + display: none !important; + } + + .print-area { + padding: 0; + } + + .print-page { + border: none !important; + border-radius: 0 !important; + margin: 0; + padding: 0; + max-width: none; + page-break-after: always; + break-after: page; + height: 100%; + display: flex; + flex-direction: column; + } + + .print-page:last-child { + page-break-after: avoid; + } + + .page-title { + font-size: 12pt; + margin: 0 0 2mm; + color: black; + } + + .sudoku-grid-container { + flex: 1; + display: grid; + grid-template-columns: repeat(2, 1fr); + gap: 2mm 6mm; + justify-items: center; + align-content: start; + } + + .sudoku-container { + text-align: center; + } + + .sudoku-number { + font-size: 7pt; + color: #333; + margin: 0 0 0.5mm; + } + + .sudoku-cell { + width: 8mm; + height: 8mm; + font-size: 10pt; + border: 1pt solid #666; + } + + .border-l-thick { border-left: 2.5pt solid #000 !important; } + .border-r-thick { border-right: 2.5pt solid #000 !important; } + .border-t-thick { border-top: 2.5pt solid #000 !important; } + .border-b-thick { border-bottom: 2.5pt solid #000 !important; } + + .given-digit { + color: black; + font-weight: 700; + } + + .solution-digit { + color: black; + font-weight: 500; + } +} diff --git a/app/layout.tsx b/app/layout.tsx new file mode 100644 index 0000000..ae13425 --- /dev/null +++ b/app/layout.tsx @@ -0,0 +1,117 @@ +import type { Metadata, Viewport } from "next"; +import { Geist, Geist_Mono } from "next/font/google"; +import "./globals.css"; + +const geistSans = Geist({ + variable: "--font-geist-sans", + subsets: ["latin"], + display: "swap", +}); + +const geistMono = Geist_Mono({ + variable: "--font-geist-mono", + subsets: ["latin"], + display: "swap", +}); + +export const viewport: Viewport = { + width: "device-width", + initialScale: 1, + themeColor: "#667eea", +}; + +export const metadata: Metadata = { + title: "Générateur de Sudoku gratuit — Imprimer des grilles avec solutions", + description: + "Générez et imprimez gratuitement des grilles de Sudoku avec leurs solutions sur une feuille A4. 4 niveaux de difficulté : facile, moyen, difficile et expert. Aucune inscription requise.", + keywords: [ + "sudoku", + "grille sudoku", + "imprimer sudoku", + "sudoku gratuit", + "sudoku à imprimer", + "sudoku avec solution", + "générateur sudoku", + "sudoku facile", + "sudoku moyen", + "sudoku difficile", + "sudoku expert", + "sudoku PDF", + "jeu de logique", + ], + authors: [{ name: "Sudoku Générateur" }], + creator: "Sudoku Générateur", + publisher: "Sudoku Générateur", + robots: { + index: true, + follow: true, + googleBot: { + index: true, + follow: true, + "max-snippet": -1, + "max-image-preview": "large", + }, + }, + openGraph: { + type: "website", + locale: "fr_FR", + title: "Générateur de Sudoku gratuit — Imprimer des grilles avec solutions", + description: + "Générez et imprimez gratuitement des grilles de Sudoku avec solutions. 4 niveaux : facile, moyen, difficile, expert.", + siteName: "Générateur de Sudoku", + }, + twitter: { + card: "summary_large_image", + title: "Générateur de Sudoku gratuit — Imprimer des grilles", + description: + "Générez et imprimez gratuitement des grilles de Sudoku avec solutions. 4 niveaux de difficulté.", + }, + alternates: { + canonical: "/", + }, +}; + +export default function RootLayout({ + children, +}: Readonly<{ + children: React.ReactNode; +}>) { + const jsonLd = { + "@context": "https://schema.org", + "@type": "WebApplication", + name: "Générateur de Sudoku", + description: + "Générez et imprimez gratuitement des grilles de Sudoku avec solutions sur feuille A4.", + applicationCategory: "GameApplication", + operatingSystem: "Tous", + offers: { + "@type": "Offer", + price: "0", + priceCurrency: "EUR", + }, + inLanguage: "fr", + browserRequirements: "Requires JavaScript. Requires HTML5.", + featureList: [ + "Génération de sudoku valides et solvables", + "4 niveaux de difficulté", + "Impression optimisée A4", + "Solutions incluses", + ], + }; + + return ( + + +