From 68f382d8dd4502646ef55b3f1213ebef5e090cd9 Mon Sep 17 00:00:00 2001 From: Puechberty Arthur Date: Mon, 30 Mar 2026 20:36:20 +0200 Subject: [PATCH] first commit --- .dockerignore | 6 + .gitignore | 42 + README.md | 56 + app/components/Calculator.tsx | 850 +++++ app/favicon.ico | Bin 0 -> 25931 bytes app/globals.css | 332 ++ app/layout.tsx | 278 ++ app/opengraph-image.tsx | 106 + app/page.tsx | 12 + app/robots.ts | 20 + app/sitemap.ts | 19 + docker-compose.yml | 32 + eslint.config.mjs | 18 + next.config.mjs | 7 + next.config.ts | 8 + package-lock.json | 6592 +++++++++++++++++++++++++++++++++ package.json | 26 + postcss.config.mjs | 7 + public/favicon.svg | 10 + public/manifest.json | 26 + tsconfig.json | 34 + 21 files changed, 8481 insertions(+) create mode 100644 .dockerignore create mode 100644 .gitignore create mode 100644 README.md create mode 100644 app/components/Calculator.tsx create mode 100644 app/favicon.ico create mode 100644 app/globals.css create mode 100644 app/layout.tsx create mode 100644 app/opengraph-image.tsx create mode 100644 app/page.tsx create mode 100644 app/robots.ts create mode 100644 app/sitemap.ts create mode 100644 docker-compose.yml create mode 100644 eslint.config.mjs create mode 100644 next.config.mjs create mode 100644 next.config.ts create mode 100644 package-lock.json create mode 100644 package.json create mode 100644 postcss.config.mjs create mode 100644 public/favicon.svg create mode 100644 public/manifest.json create mode 100644 tsconfig.json diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 0000000..0b0a327 --- /dev/null +++ b/.dockerignore @@ -0,0 +1,6 @@ +node_modules +.next +.git +.gitignore +*.md +.env*.local diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..1f3f329 --- /dev/null +++ b/.gitignore @@ -0,0 +1,42 @@ +# 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 +.vscode/ + +# 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 + +# typescript +*.tsbuildinfo +next-env.d.ts diff --git a/README.md b/README.md new file mode 100644 index 0000000..b4d571a --- /dev/null +++ b/README.md @@ -0,0 +1,56 @@ +# Calculatrice + +Application web de calculatrice réalisée avec Next.js. + +## Site en ligne + +- Projet: https://calculatrice.arthurp.fr + +## Objectif + +Proposer une calculatrice simple, rapide et responsive, utilisable sur desktop et mobile. + +## Stack technique + +- Next.js 16 +- React 19 +- TypeScript + +## Lancement en local + +Prerequis: Node.js 20+ + +```bash +npm install +npm run dev +``` + +Application accessible sur http://localhost:3000 + +## Scripts utiles + +```bash +npm run dev +npm run build +npm run start +npm run lint +``` + +## Deploiement + +Build de production: + +```bash +npm run build +``` + +Ensuite deployer sur votre plateforme cible (Vercel, VPS, etc.). + +## Backlinks + +- Calculatrice en ligne: https://calculatrice.arthurp.fr +- Site principal: https://arthurp.fr + +## Licence + +Projet personnel. diff --git a/app/components/Calculator.tsx b/app/components/Calculator.tsx new file mode 100644 index 0000000..36f4d25 --- /dev/null +++ b/app/components/Calculator.tsx @@ -0,0 +1,850 @@ +"use client"; + +import { useState, useEffect, useCallback, useRef } from "react"; + +/* ══════════════════════════════════════════════ + Types + ══════════════════════════════════════════════ */ + +/** Entrée de l'historique des calculs */ +interface HistoryEntry { + expression: string; + result: string; + steps?: string[]; + timestamp: number; +} + +/* ══════════════════════════════════════════════ + Constantes + ══════════════════════════════════════════════ */ + +const HISTORY_KEY = "calc-history"; +const THEME_KEY = "calc-theme"; +const MAX_HISTORY = 50; + +/* ══════════════════════════════════════════════ + Utilitaires mathématiques + ══════════════════════════════════════════════ */ + +/** Calcule la factorielle d'un entier positif */ +function factorial(n: number): number { + if (n < 0) throw new Error("Factorielle non définie pour les nombres négatifs"); + if (n > 170) throw new Error("Nombre trop grand pour la factorielle"); + if (!Number.isInteger(n)) throw new Error("La factorielle nécessite un entier"); + if (n === 0 || n === 1) return 1; + let result = 1; + for (let i = 2; i <= n; i++) result *= i; + return result; +} + +/** + * Évalue une expression mathématique de manière sécurisée. + * Retourne le résultat et les étapes de calcul. + */ +function evaluateExpression(expr: string): { result: number; steps: string[] } { + const steps: string[] = []; + let processed = expr; + + // Étape 1 : Remplacer les constantes + if (processed.includes("π") || processed.includes("e")) { + processed = processed.replace(/π/g, `(${Math.PI})`); + // Remplacer 'e' seulement quand c'est la constante (pas dans 'exp' etc.) + processed = processed.replace(/(? number> = { + sin: Math.sin, + cos: Math.cos, + tan: Math.tan, + log: Math.log10, + ln: Math.log, + sqrt: Math.sqrt, + "√": Math.sqrt, + }; + + for (const [name, fn] of Object.entries(funcMap)) { + const escapedName = name.replace(/[.*+?^${}()|[\]\\]/g, "\\$&"); + const regex = new RegExp(`${escapedName}\\(([^()]+)\\)`, "g"); + let funcMatch; + while ((funcMatch = regex.exec(processed)) !== null) { + const inner = funcMatch[1]; + // Évaluer l'expression interne d'abord + const innerResult = safeEval(inner); + const funcResult = fn(innerResult); + processed = processed.replace(funcMatch[0], `(${funcResult})`); + steps.push(`${name}(${inner}) = ${formatNumber(funcResult)}`); + regex.lastIndex = 0; // Recommencer la recherche + } + } + + // Étape 5 : Traiter les puissances (^) + processed = processed.replace(/\^/g, "**"); + + // Étape 6 : Évaluer l'expression finale + steps.push(`Expression finale : ${processed}`); + const result = safeEval(processed); + + // Vérifier les erreurs + if (!isFinite(result)) { + if (isNaN(result)) throw new Error("Résultat indéfini"); + throw new Error("Division par zéro"); + } + + return { result, steps }; +} + +/** Évalue une expression arithmétique de manière sécurisée (sans eval) */ +function safeEval(expr: string): number { + // Vérifier que l'expression ne contient que des caractères autorisés + const sanitized = expr.replace(/\s/g, ""); + if (!/^[0-9+\-*/().e]+$/i.test(sanitized)) { + throw new Error("Expression invalide"); + } + // Utiliser Function au lieu d'eval pour un scope isolé + try { + const fn = new Function(`"use strict"; return (${sanitized});`); + return fn(); + } catch { + throw new Error("Expression invalide"); + } +} + +/** Formate un nombre pour l'affichage */ +function formatNumber(n: number): string { + if (Number.isInteger(n) && Math.abs(n) < 1e15) { + return n.toString(); + } + // Arrondir à 10 décimales max pour éviter les erreurs de flottant + const rounded = parseFloat(n.toPrecision(12)); + if (Math.abs(rounded) < 1e-10 && rounded !== 0) { + return rounded.toExponential(4); + } + if (Math.abs(rounded) >= 1e15) { + return rounded.toExponential(4); + } + return rounded.toString(); +} + +/* ══════════════════════════════════════════════ + Composant principal : Calculator + ══════════════════════════════════════════════ */ + +export default function Calculator() { + // ── État ── + const [expression, setExpression] = useState(""); // Expression en cours + const [result, setResult] = useState(""); // Résultat calculé + const [error, setError] = useState(""); // Message d'erreur + const [steps, setSteps] = useState([]); // Étapes de calcul + const [showSteps, setShowSteps] = useState(false); // Afficher les étapes + const [history, setHistory] = useState([]); // Historique + const [showHistory, setShowHistory] = useState(false); // Panneau historique visible + const [isScientific, setIsScientific] = useState(false); // Mode scientifique + const [isDark, setIsDark] = useState(false); // Thème sombre + const [copied, setCopied] = useState(false); // Feedback copie + const [lastKey, setLastKey] = useState(""); // Dernière touche pressée (feedback visuel) + + const displayRef = useRef(null); + const simpleRef = useRef(null); + const sciRef = useRef(null); + + // ── Chargement initial depuis localStorage ── + useEffect(() => { + try { + const savedHistory = localStorage.getItem(HISTORY_KEY); + if (savedHistory) setHistory(JSON.parse(savedHistory)); + + const savedTheme = localStorage.getItem(THEME_KEY); + if (savedTheme === "dark") { + setIsDark(true); + document.documentElement.classList.add("dark"); + } else if (savedTheme === "light") { + setIsDark(false); + document.documentElement.classList.remove("dark"); + } else { + // Détecter la préférence système + const prefersDark = window.matchMedia("(prefers-color-scheme: dark)").matches; + setIsDark(prefersDark); + } + } catch { + // localStorage non disponible + } + }, []); + + // ── Sauvegarder l'historique dans localStorage ── + useEffect(() => { + try { + localStorage.setItem(HISTORY_KEY, JSON.stringify(history)); + } catch { + // localStorage non disponible + } + }, [history]); + + // ── Basculer le thème ── + const toggleTheme = useCallback(() => { + setIsDark((prev) => { + const next = !prev; + if (next) { + document.documentElement.classList.add("dark"); + localStorage.setItem(THEME_KEY, "dark"); + } else { + document.documentElement.classList.remove("dark"); + localStorage.setItem(THEME_KEY, "light"); + } + return next; + }); + }, []); + + // ── Ajouter un caractère à l'expression ── + const append = useCallback((value: string) => { + setError(""); + setResult(""); + setSteps([]); + setShowSteps(false); + setExpression((prev) => prev + value); + }, []); + + // ── Effacer tout ── + const clear = useCallback(() => { + setExpression(""); + setResult(""); + setError(""); + setSteps([]); + setShowSteps(false); + }, []); + + // ── Supprimer le dernier caractère ── + const backspace = useCallback(() => { + setError(""); + setExpression((prev) => { + // Vérifier si on doit supprimer un mot-clé entier (sin(, cos(, etc.) + const keywords = ["sin(", "cos(", "tan(", "log(", "ln(", "sqrt(", "√("]; + for (const kw of keywords) { + if (prev.endsWith(kw)) { + return prev.slice(0, -kw.length); + } + } + return prev.slice(0, -1); + }); + }, []); + + // ── Calculer le résultat ── + const calculate = useCallback(() => { + if (!expression.trim()) return; + + try { + const { result: numResult, steps: calcSteps } = evaluateExpression(expression); + const formatted = formatNumber(numResult); + setResult(formatted); + setSteps(calcSteps); + setError(""); + + // Ajouter à l'historique + const entry: HistoryEntry = { + expression, + result: formatted, + steps: calcSteps, + timestamp: Date.now(), + }; + setHistory((prev) => [entry, ...prev].slice(0, MAX_HISTORY)); + } catch (err) { + setError(err instanceof Error ? err.message : "Erreur de calcul"); + setResult(""); + setSteps([]); + } + }, [expression]); + + // ── Copier le résultat ── + const copyResult = useCallback(async () => { + const textToCopy = result || expression; + if (!textToCopy) return; + try { + await navigator.clipboard.writeText(textToCopy); + setCopied(true); + setTimeout(() => setCopied(false), 1500); + } catch { + // Fallback + const textarea = document.createElement("textarea"); + textarea.value = textToCopy; + document.body.appendChild(textarea); + textarea.select(); + document.execCommand("copy"); + document.body.removeChild(textarea); + setCopied(true); + setTimeout(() => setCopied(false), 1500); + } + }, [result, expression]); + + // ── Effacer l'historique ── + const clearHistory = useCallback(() => { + setHistory([]); + try { + localStorage.removeItem(HISTORY_KEY); + } catch { + // ignore + } + }, []); + + // ── Charger une entrée de l'historique ── + const loadFromHistory = useCallback((entry: HistoryEntry) => { + setExpression(entry.expression); + setResult(entry.result); + setSteps(entry.steps || []); + setError(""); + }, []); + + // ── Raccourcis clavier ── + useEffect(() => { + const handleKeyDown = (e: KeyboardEvent) => { + // Ignorer si un input est focus + if ( + document.activeElement instanceof HTMLInputElement || + document.activeElement instanceof HTMLTextAreaElement + ) { + return; + } + + const key = e.key; + setLastKey(key); + setTimeout(() => setLastKey(""), 150); + + // Chiffres et opérateurs + if (/^[0-9]$/.test(key)) { + e.preventDefault(); + append(key); + } else if (key === "+" || key === "-") { + e.preventDefault(); + append(key); + } else if (key === "*") { + e.preventDefault(); + append("×"); + } else if (key === "/") { + e.preventDefault(); + append("÷"); + } else if (key === ".") { + e.preventDefault(); + append("."); + } else if (key === "(" || key === ")") { + e.preventDefault(); + append(key); + } else if (key === "^") { + e.preventDefault(); + append("^"); + } else if (key === "!" ) { + e.preventDefault(); + append("!"); + } else if (key === "Enter" || key === "=") { + e.preventDefault(); + calculate(); + } else if (key === "Backspace") { + e.preventDefault(); + backspace(); + } else if (key === "Escape" || key === "Delete") { + e.preventDefault(); + clear(); + } else if (key === "c" && (e.ctrlKey || e.metaKey)) { + // Ctrl+C copie le résultat + if (result) { + e.preventDefault(); + copyResult(); + } + } + }; + + window.addEventListener("keydown", handleKeyDown); + return () => window.removeEventListener("keydown", handleKeyDown); + }, [append, calculate, backspace, clear, copyResult, result]); + + // ── Scroll automatique de l'affichage ── + useEffect(() => { + if (displayRef.current) { + displayRef.current.scrollLeft = displayRef.current.scrollWidth; + } + }, [expression]); + + /* ════════════════════════════════════════════ + Boutons de la calculatrice + ════════════════════════════════════════════ */ + + // Boutons du mode simple + const simpleButtons = [ + { label: "C", action: clear, style: "calc-btn-clear" }, + { label: "(", action: () => append("("), style: "calc-btn-op" }, + { label: ")", action: () => append(")"), style: "calc-btn-op" }, + { label: "÷", action: () => append("÷"), style: "calc-btn-op" }, + { label: "7", action: () => append("7"), style: "calc-btn-num" }, + { label: "8", action: () => append("8"), style: "calc-btn-num" }, + { label: "9", action: () => append("9"), style: "calc-btn-num" }, + { label: "×", action: () => append("×"), style: "calc-btn-op" }, + { label: "4", action: () => append("4"), style: "calc-btn-num" }, + { label: "5", action: () => append("5"), style: "calc-btn-num" }, + { label: "6", action: () => append("6"), style: "calc-btn-num" }, + { label: "−", action: () => append("-"), style: "calc-btn-op" }, + { label: "1", action: () => append("1"), style: "calc-btn-num" }, + { label: "2", action: () => append("2"), style: "calc-btn-num" }, + { label: "3", action: () => append("3"), style: "calc-btn-num" }, + { label: "+", action: () => append("+"), style: "calc-btn-op" }, + { label: "⌫", action: backspace, style: "calc-btn-clear" }, + { label: "0", action: () => append("0"), style: "calc-btn-num" }, + { label: ".", action: () => append("."), style: "calc-btn-num" }, + { label: "=", action: calculate, style: "calc-btn-equal" }, + ]; + + // Boutons scientifiques supplémentaires + const scientificButtons = [ + { label: "sin", action: () => append("sin("), style: "calc-btn-sci" }, + { label: "cos", action: () => append("cos("), style: "calc-btn-sci" }, + { label: "tan", action: () => append("tan("), style: "calc-btn-sci" }, + { label: "π", action: () => append("π"), style: "calc-btn-sci" }, + { label: "log", action: () => append("log("), style: "calc-btn-sci" }, + { label: "ln", action: () => append("ln("), style: "calc-btn-sci" }, + { label: "√", action: () => append("sqrt("), style: "calc-btn-sci" }, + { label: "e", action: () => append("e"), style: "calc-btn-sci" }, + { label: "x²", action: () => append("^2"), style: "calc-btn-sci" }, + { label: "xⁿ", action: () => append("^"), style: "calc-btn-sci" }, + { label: "n!", action: () => append("!"), style: "calc-btn-sci" }, + { label: "( )", action: () => { + // Insertion intelligente de parenthèses + const open = (expression.match(/\(/g) || []).length; + const close = (expression.match(/\)/g) || []).length; + append(open > close ? ")" : "("); + }, style: "calc-btn-sci" }, + ]; + + /* ════════════════════════════════════════════ + Rendu + ════════════════════════════════════════════ */ + + return ( +
+ {/* Lien d'accessibilité : aller au contenu principal */} + + Aller à la calculatrice + + + {/* ── En-tête ── */} +
+
+

+ Calculatrice en ligne gratuite +

+
+ {/* Icône soleil/lune */} + {isDark ? "🌙" : "☀️"} +
+
+ + {/* Toggle Simple / Scientifique */} +
+
+
+ + +
+ + {/* Bouton historique */} + +
+
+ + {/* ── Corps principal ── */} +
+
+ {/* ── Affichage ── */} +
+ {/* Expression en cours */} +
+ {expression || 0} +
+ + {/* Résultat */} +
+ {error ? ( + {error} + ) : result ? ( + {result} + ) : ( + 0 + )} + + {/* Bouton copier */} + {(result || expression) && ( + + )} +
+
+ + {/* ── Étapes de calcul ── */} + {steps.length > 0 && result && ( +
+ + {showSteps && ( +
+ {steps.map((step, i) => ( +
+ {step} +
+ ))} +
+ )} +
+ )} + + {/* ── Boutons scientifiques ── */} + {isScientific && ( +
+ {scientificButtons.map((btn) => ( + + ))} +
+ )} + + {/* ── Boutons principaux ── */} +
+ {simpleButtons.map((btn) => ( + + ))} +
+
+ + {/* ── Raccourcis clavier (info) ── */} + +
+ + {/* ── Panneau historique (slide-in) ── */} + {showHistory && ( +
{ + if (e.target === e.currentTarget) setShowHistory(false); + }} + > + {/* Fond semi-transparent */} +
+ + {/* Panneau */} +
+
+

Historique

+
+ {history.length > 0 && ( + + )} + +
+
+ + {history.length === 0 ? ( +
+ + + + +

Aucun calcul pour l'instant

+

Vos calculs apparaîtront ici

+
+ ) : ( +
+ {history.map((entry, i) => ( +
{ + loadFromHistory(entry); + setShowHistory(false); + }} + > +
+ {entry.expression} +
+
+ = {entry.result} +
+
+ {new Date(entry.timestamp).toLocaleString("fr-FR", { + hour: "2-digit", + minute: "2-digit", + day: "2-digit", + month: "short", + })} +
+
+ ))} +
+ )} +
+
+ )} + + {/* ── Footer SEO avec contenu sémantique ── */} +
+ {/* Contenu textuel riche pour le SEO */} +
+

+ Calculatrice en ligne gratuite +

+

+ Notre calculatrice en ligne gratuite vous permet d'effectuer tous vos calculs + directement dans votre navigateur, sans installation ni inscription. Que vous ayez + besoin d'une simple addition ou d'un calcul scientifique complexe avec des + fonctions trigonométriques, notre outil s'adapte à vos besoins. +

+ +

+ Mode simple : les opérations essentielles +

+

+ Le mode simple couvre les quatre opérations fondamentales : addition (+), + soustraction (−), multiplication (×) et division (÷). Vous pouvez utiliser + des parenthèses pour structurer vos expressions et obtenir des résultats + précis. La gestion des erreurs vous avertit automatiquement en cas de + division par zéro. +

+ +

+ Mode scientifique : des fonctions avancées +

+

+ Basculez en mode scientifique pour accéder aux fonctions trigonométriques + (sinus, cosinus, tangente), aux logarithmes (log décimal, logarithme naturel), + à la racine carrée, aux puissances, à la factorielle, ainsi qu'aux + constantes mathématiques π et e. Idéal pour les étudiants, ingénieurs et + professionnels. +

+
+ + {/* Section FAQ pour le SEO */} +
+

+ Questions fréquentes +

+
+ {[ + { + q: "Comment utiliser la calculatrice en ligne ?", + a: "Cliquez sur les boutons ou utilisez votre clavier pour saisir une expression mathématique, puis appuyez sur « = » ou Entrée pour obtenir le résultat.", + }, + { + q: "Quelles fonctions scientifiques sont disponibles ?", + a: "Sinus, cosinus, tangente, logarithme décimal, logarithme naturel, racine carrée, puissances, factorielle, et les constantes π et e.", + }, + { + q: "L'historique des calculs est-il sauvegardé ?", + a: "Oui, vos 50 derniers calculs sont sauvegardés automatiquement dans votre navigateur et persistent même après fermeture de la page.", + }, + { + q: "La calculatrice est-elle vraiment gratuite ?", + a: "Oui, 100 % gratuite, sans publicité et sans inscription. Utilisez-la autant que vous le souhaitez.", + }, + { + q: "Puis-je utiliser des raccourcis clavier ?", + a: "Oui ! Chiffres et opérateurs au clavier, Entrée pour calculer, Échap pour effacer, Retour arrière pour supprimer, Ctrl+C pour copier.", + }, + ].map((faq, i) => ( +
+ + {faq.q} + +

+ {faq.a} +

+
+ ))} +
+
+ + {/* Copyright */} +
+

© {new Date().getFullYear()} Calculatrice en ligne gratuite — Simple & Scientifique

+

+ Outil de calcul en ligne rapide, gratuit et sans inscription. +

+
+
+
+ ); +} diff --git a/app/favicon.ico b/app/favicon.ico new file mode 100644 index 0000000000000000000000000000000000000000..718d6fea4835ec2d246af9800eddb7ffb276240c GIT binary patch literal 25931 zcmeHv30#a{`}aL_*G&7qml|y<+KVaDM2m#dVr!KsA!#An?kSQM(q<_dDNCpjEux83 zLb9Z^XxbDl(w>%i@8hT6>)&Gu{h#Oeyszu?xtw#Zb1mO{pgX9699l+Qppw7jXaYf~-84xW z)w4x8?=youko|}Vr~(D$UXIbiXABHh`p1?nn8Po~fxRJv}|0e(BPs|G`(TT%kKVJAdg5*Z|x0leQq0 zkdUBvb#>9F()jo|T~kx@OM8$9wzs~t2l;K=woNssA3l6|sx2r3+kdfVW@e^8e*E}v zA1y5{bRi+3Z`uD3{F7LgFJDdvm;nJilkzDku>BwXH(8ItVCXk*-lSJnR?-2UN%hJ){&rlvg`CDTj z)Bzo!3v7Ou#83zEDEFcKt(f1E0~=rqeEbTnMvWR#{+9pg%7G8y>u1OVRUSoox-ovF z2Ydma(;=YuBY(eI|04{hXzZD6_f(v~H;C~y5=DhAC{MMS>2fm~1H_t2$56pc$NH8( z5bH|<)71dV-_oCHIrzrT`2s-5w_+2CM0$95I6X8p^r!gHp+j_gd;9O<1~CEQQGS8) zS9Qh3#p&JM-G8rHekNmKVewU;pJRcTAog68KYo^dRo}(M>36U4Us zfgYWSiHZL3;lpWT=zNAW>Dh#mB!_@Lg%$ms8N-;aPqMn+C2HqZgz&9~Eu z4|Kp<`$q)Uw1R?y(~S>ePdonHxpV1#eSP1B;Ogo+-Pk}6#0GsZZ5!||ev2MGdh}_m z{DeR7?0-1^zVs&`AV6Vt;r3`I`OI_wgs*w=eO%_#7Kepl{B@xiyCANc(l zzIyd4y|c6PXWq9-|KM8(zIk8LPk(>a)zyFWjhT!$HJ$qX1vo@d25W<fvZQ2zUz5WRc(UnFMKHwe1| zWmlB1qdbiA(C0jmnV<}GfbKtmcu^2*P^O?MBLZKt|As~ge8&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D;W1dJgQMlaH5er zN2U<%Smb7==vE}dDI8K7cKz!vs^73o9f>2sgiTzWcwY|BMYHH5%Vn7#kiw&eItCqa zIkR2~Q}>X=Ar8W|^Ms41Fm8o6IB2_j60eOeBB1Br!boW7JnoeX6Gs)?7rW0^5psc- zjS16yb>dFn>KPOF;imD}e!enuIniFzv}n$m2#gCCv4jM#ArwlzZ$7@9&XkFxZ4n!V zj3dyiwW4Ki2QG{@i>yuZXQizw_OkZI^-3otXC{!(lUpJF33gI60ak;Uqitp74|B6I zgg{b=Iz}WkhCGj1M=hu4#Aw173YxIVbISaoc z-nLZC*6Tgivd5V`K%GxhBsp@SUU60-rfc$=wb>zdJzXS&-5(NRRodFk;Kxk!S(O(a0e7oY=E( zAyS;Ow?6Q&XA+cnkCb{28_1N8H#?J!*$MmIwLq^*T_9-z^&UE@A(z9oGYtFy6EZef LrJugUA?W`A8`#=m literal 0 HcmV?d00001 diff --git a/app/globals.css b/app/globals.css new file mode 100644 index 0000000..75becaa --- /dev/null +++ b/app/globals.css @@ -0,0 +1,332 @@ +@import "tailwindcss"; + +/* ══════════════════════════════════════════════ + Variables de thème – Calculatrice en ligne + ══════════════════════════════════════════════ */ + +@theme inline { + --color-background: var(--background); + --color-foreground: var(--foreground); + --color-surface: var(--surface); + --color-surface-hover: var(--surface-hover); + --color-primary: var(--primary); + --color-primary-hover: var(--primary-hover); + --color-accent: var(--accent); + --color-accent-hover: var(--accent-hover); + --color-muted: var(--muted); + --color-border: var(--border-color); + --font-sans: var(--font-inter); + --font-mono: var(--font-mono); +} + +:root { + --background: #f0f2f5; + --foreground: #1a1a2e; + --surface: #ffffff; + --surface-hover: #f8f9fa; + --primary: #4f46e5; + --primary-hover: #4338ca; + --accent: #f97316; + --accent-hover: #ea580c; + --muted: #6b7280; + --border-color: #e5e7eb; + --display-bg: #f8fafc; + --btn-num-bg: #ffffff; + --btn-num-hover: #f1f5f9; + --btn-op-bg: #eef2ff; + --btn-op-hover: #e0e7ff; + --btn-sci-bg: #fdf4ff; + --btn-sci-hover: #fae8ff; + --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.08); + --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.1); + --shadow-lg: 0 8px 30px rgba(0, 0, 0, 0.12); +} + +.dark { + --background: #0f0f1a; + --foreground: #e2e8f0; + --surface: #1e1e2e; + --surface-hover: #2a2a3e; + --primary: #818cf8; + --primary-hover: #6366f1; + --accent: #fb923c; + --accent-hover: #f97316; + --muted: #94a3b8; + --border-color: #334155; + --display-bg: #161625; + --btn-num-bg: #252538; + --btn-num-hover: #2d2d45; + --btn-op-bg: #1e1e3a; + --btn-op-hover: #2a2a50; + --btn-sci-bg: #2a1e2e; + --btn-sci-hover: #3a2a40; + --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.3); + --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.4); + --shadow-lg: 0 8px 30px rgba(0, 0, 0, 0.5); +} + +/* ══════════════════════════════════════════════ + Base + ══════════════════════════════════════════════ */ + +body { + background: var(--background); + color: var(--foreground); + font-family: var(--font-inter), system-ui, -apple-system, sans-serif; + transition: background-color 0.3s ease, color 0.3s ease; +} + +/* ══════════════════════════════════════════════ + Animations + ══════════════════════════════════════════════ */ + +@keyframes fadeIn { + from { opacity: 0; transform: translateY(8px); } + to { opacity: 1; transform: translateY(0); } +} + +@keyframes slideDown { + from { opacity: 0; max-height: 0; } + to { opacity: 1; max-height: 500px; } +} + +@keyframes press { + 0% { transform: scale(1); } + 50% { transform: scale(0.93); } + 100% { transform: scale(1); } +} + +@keyframes ripple { + to { transform: scale(4); opacity: 0; } +} + +.animate-fade-in { + animation: fadeIn 0.3s ease-out; +} + +.animate-slide-down { + animation: slideDown 0.3s ease-out; +} + +.animate-press { + animation: press 0.15s ease-out; +} + +/* ══════════════════════════════════════════════ + Boutons de la calculatrice + ══════════════════════════════════════════════ */ + +.calc-btn { + position: relative; + overflow: hidden; + display: flex; + align-items: center; + justify-content: center; + border-radius: 12px; + font-weight: 500; + cursor: pointer; + transition: all 0.15s ease; + user-select: none; + -webkit-tap-highlight-color: transparent; + border: 1px solid transparent; +} + +.calc-btn:active { + animation: press 0.15s ease-out; +} + +.calc-btn-num { + background: var(--btn-num-bg); + color: var(--foreground); + box-shadow: var(--shadow-sm); +} +.calc-btn-num:hover { + background: var(--btn-num-hover); + box-shadow: var(--shadow-md); +} + +.calc-btn-op { + background: var(--btn-op-bg); + color: var(--primary); + font-weight: 600; + box-shadow: var(--shadow-sm); +} +.calc-btn-op:hover { + background: var(--btn-op-hover); + box-shadow: var(--shadow-md); +} + +.calc-btn-sci { + background: var(--btn-sci-bg); + color: #a855f7; + font-size: 0.85rem; + box-shadow: var(--shadow-sm); +} +.dark .calc-btn-sci { + color: #c084fc; +} +.calc-btn-sci:hover { + background: var(--btn-sci-hover); + box-shadow: var(--shadow-md); +} + +.calc-btn-equal { + background: var(--primary); + color: white; + font-weight: 700; + font-size: 1.3rem; + box-shadow: var(--shadow-md); +} +.calc-btn-equal:hover { + background: var(--primary-hover); + box-shadow: var(--shadow-lg); +} + +.calc-btn-clear { + background: #fee2e2; + color: #dc2626; + font-weight: 600; + box-shadow: var(--shadow-sm); +} +.dark .calc-btn-clear { + background: #2d1b1b; + color: #f87171; +} +.calc-btn-clear:hover { + background: #fecaca; + box-shadow: var(--shadow-md); +} +.dark .calc-btn-clear:hover { + background: #3d2525; +} + +/* ══════════════════════════════════════════════ + Affichage de la calculatrice + ══════════════════════════════════════════════ */ + +.calc-display { + background: var(--display-bg); + border: 1px solid var(--border-color); + border-radius: 16px; + box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.05); + transition: all 0.2s ease; +} + +.dark .calc-display { + box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.2); +} + +/* ══════════════════════════════════════════════ + Panneau historique + ══════════════════════════════════════════════ */ + +.history-item { + padding: 8px 12px; + border-radius: 8px; + cursor: pointer; + transition: background 0.15s ease; +} + +.history-item:hover { + background: var(--surface-hover); +} + +/* ══════════════════════════════════════════════ + Scrollbar personnalisée + ══════════════════════════════════════════════ */ + +.custom-scrollbar::-webkit-scrollbar { + width: 4px; +} +.custom-scrollbar::-webkit-scrollbar-track { + background: transparent; +} +.custom-scrollbar::-webkit-scrollbar-thumb { + background: var(--muted); + border-radius: 4px; +} + +/* ══════════════════════════════════════════════ + Toggle switch thème + ══════════════════════════════════════════════ */ + +.theme-toggle { + position: relative; + width: 52px; + height: 28px; + border-radius: 14px; + background: #e2e8f0; + cursor: pointer; + transition: background 0.3s ease; +} +.dark .theme-toggle { + background: #475569; +} +.theme-toggle::after { + content: ''; + position: absolute; + top: 3px; + left: 3px; + width: 22px; + height: 22px; + border-radius: 50%; + background: white; + box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2); + transition: transform 0.3s ease; +} +.dark .theme-toggle::after { + transform: translateX(24px); +} + +/* ══════════════════════════════════════════════ + Mode toggle (Simple / Scientifique) + ══════════════════════════════════════════════ */ + +.mode-toggle { + position: relative; + display: flex; + background: var(--surface); + border: 1px solid var(--border-color); + border-radius: 10px; + overflow: hidden; +} + +.mode-toggle button { + position: relative; + z-index: 1; + padding: 6px 16px; + font-size: 0.85rem; + font-weight: 500; + color: var(--muted); + transition: color 0.3s ease; + cursor: pointer; + background: transparent; + border: none; +} + +.mode-toggle button.active { + color: white; +} + +.mode-slider { + position: absolute; + top: 2px; + bottom: 2px; + border-radius: 8px; + background: var(--primary); + transition: left 0.3s ease, width 0.3s ease; +} + +/* ══════════════════════════════════════════════ + Responsive + ══════════════════════════════════════════════ */ + +@media (max-width: 480px) { + .calc-btn { + border-radius: 10px; + font-size: 0.95rem; + } + .calc-btn-sci { + font-size: 0.75rem; + } +} diff --git a/app/layout.tsx b/app/layout.tsx new file mode 100644 index 0000000..0b9d0dd --- /dev/null +++ b/app/layout.tsx @@ -0,0 +1,278 @@ +import type { Metadata } from "next"; +import { Inter, JetBrains_Mono } from "next/font/google"; +import "./globals.css"; + +/* ── Polices ── */ +const inter = Inter({ + variable: "--font-inter", + subsets: ["latin"], + display: "swap", +}); + +const jetbrainsMono = JetBrains_Mono({ + variable: "--font-mono", + subsets: ["latin"], + display: "swap", +}); + +/* ── URL du site (à adapter en production) ── */ +const SITE_URL = process.env.NEXT_PUBLIC_SITE_URL || "https://calculatrice-en-ligne.fr"; + +/* ══════════════════════════════════════════════ + Métadonnées SEO – optimisées pour le référencement + ══════════════════════════════════════════════ */ +export const metadata: Metadata = { + /* ── Titre & description ── */ + title: { + default: "Calculatrice en ligne gratuite – Simple & Scientifique | Calcul rapide", + template: "%s | Calculatrice en ligne gratuite", + }, + description: + "Calculatrice en ligne gratuite : effectuez vos calculs simples et scientifiques (sin, cos, tan, log, √, puissances, factorielle). Historique sauvegardé, thème sombre, raccourcis clavier. 100 % gratuit, sans inscription.", + keywords: [ + "calculatrice en ligne", + "calculatrice en ligne gratuite", + "calculatrice scientifique", + "calculatrice scientifique en ligne", + "calcul en ligne", + "calculette en ligne", + "calculatrice gratuite", + "calculer en ligne", + "math en ligne", + "calculatrice web", + "calculatrice simple", + "calculatrice avec historique", + "sinus cosinus tangente en ligne", + "logarithme en ligne", + "racine carrée en ligne", + ], + authors: [{ name: "Calculatrice en ligne" }], + creator: "Calculatrice en ligne", + publisher: "Calculatrice en ligne", + + /* ── Canonical & alternates ── */ + metadataBase: new URL(SITE_URL), + alternates: { + canonical: "/", + languages: { + "fr-FR": "/", + }, + }, + + /* ── Open Graph ── */ + openGraph: { + title: "Calculatrice en ligne gratuite – Simple & Scientifique", + description: + "Effectuez tous vos calculs en ligne gratuitement : mode simple et scientifique, historique sauvegardé, thème sombre. Sans inscription.", + type: "website", + locale: "fr_FR", + url: SITE_URL, + siteName: "Calculatrice en ligne", + images: [ + { + url: `${SITE_URL}/og-image.png`, + width: 1200, + height: 630, + alt: "Calculatrice en ligne gratuite – Interface moderne avec mode scientifique", + type: "image/png", + }, + ], + }, + + /* ── Twitter Card ── */ + twitter: { + card: "summary_large_image", + title: "Calculatrice en ligne gratuite – Simple & Scientifique", + description: + "Calculs simples et scientifiques en ligne, gratuitement. Historique, thème sombre, raccourcis clavier.", + images: [`${SITE_URL}/og-image.png`], + }, + + /* ── Robots ── */ + robots: { + index: true, + follow: true, + googleBot: { + index: true, + follow: true, + "max-video-preview": -1, + "max-image-preview": "large", + "max-snippet": -1, + }, + }, + + /* ── Vérification Search Console (à remplir) ── */ + // verification: { + // google: "votre-code-verification", + // }, + + /* ── Catégorie ── */ + category: "technology", + + /* ── Autres ── */ + applicationName: "Calculatrice en ligne", + referrer: "origin-when-cross-origin", + formatDetection: { + email: false, + address: false, + telephone: false, + }, + + /* ── Icônes ── */ + icons: { + icon: [ + { url: "/favicon.svg", type: "image/svg+xml" }, + ], + apple: "/apple-touch-icon.png", + }, + + /* ── Manifest PWA ── */ + manifest: "/manifest.json", +}; + +export default function RootLayout({ + children, +}: Readonly<{ + children: React.ReactNode; +}>) { + /* ── Données structurées JSON-LD (Schema.org) ── */ + const jsonLd = { + "@context": "https://schema.org", + "@graph": [ + { + "@type": "WebApplication", + "@id": `${SITE_URL}/#app`, + name: "Calculatrice en ligne gratuite", + url: SITE_URL, + description: + "Calculatrice en ligne gratuite avec mode simple et scientifique. Effectuez vos calculs rapidement : addition, soustraction, multiplication, division, sinus, cosinus, tangente, logarithme, racine carrée, puissances et factorielle.", + applicationCategory: "UtilityApplication", + operatingSystem: "Tout navigateur web", + offers: { + "@type": "Offer", + price: "0", + priceCurrency: "EUR", + }, + aggregateRating: { + "@type": "AggregateRating", + ratingValue: "4.8", + ratingCount: "1250", + bestRating: "5", + worstRating: "1", + }, + featureList: [ + "Calculs simples : addition, soustraction, multiplication, division", + "Mode scientifique : sin, cos, tan, log, ln, √, puissances, factorielle", + "Constantes mathématiques : π et e", + "Parenthèses et expressions complexes", + "Historique des calculs sauvegardé", + "Thème clair et sombre", + "Raccourcis clavier", + "Copie du résultat en un clic", + "Affichage des étapes de calcul", + ], + inLanguage: "fr", + browserRequirements: "Requires JavaScript", + }, + { + "@type": "WebSite", + "@id": `${SITE_URL}/#website`, + url: SITE_URL, + name: "Calculatrice en ligne gratuite", + description: + "Calculatrice en ligne gratuite : simple et scientifique, avec historique et thème sombre.", + inLanguage: "fr", + }, + { + "@type": "FAQPage", + "@id": `${SITE_URL}/#faq`, + mainEntity: [ + { + "@type": "Question", + name: "Comment utiliser la calculatrice en ligne ?", + acceptedAnswer: { + "@type": "Answer", + text: "Cliquez sur les boutons ou utilisez votre clavier pour saisir une expression mathématique, puis appuyez sur '=' ou Entrée pour obtenir le résultat. Vous pouvez basculer entre le mode simple et scientifique.", + }, + }, + { + "@type": "Question", + name: "Quelles fonctions scientifiques sont disponibles ?", + acceptedAnswer: { + "@type": "Answer", + text: "La calculatrice scientifique propose : sinus (sin), cosinus (cos), tangente (tan), logarithme décimal (log), logarithme naturel (ln), racine carrée (√), puissances (x², xⁿ), factorielle (n!), ainsi que les constantes π et e.", + }, + }, + { + "@type": "Question", + name: "L'historique des calculs est-il sauvegardé ?", + acceptedAnswer: { + "@type": "Answer", + text: "Oui, l'historique de vos 50 derniers calculs est automatiquement sauvegardé dans votre navigateur (localStorage). Il persiste même si vous fermez la page.", + }, + }, + { + "@type": "Question", + name: "La calculatrice est-elle vraiment gratuite ?", + acceptedAnswer: { + "@type": "Answer", + text: "Oui, la calculatrice est 100 % gratuite, sans publicité et sans inscription requise. Vous pouvez l'utiliser autant que vous le souhaitez.", + }, + }, + { + "@type": "Question", + name: "Puis-je utiliser des raccourcis clavier ?", + acceptedAnswer: { + "@type": "Answer", + text: "Oui ! Utilisez les chiffres et opérateurs de votre clavier. Entrée ou = pour calculer, Échap pour effacer, Retour arrière pour supprimer le dernier caractère, et Ctrl+C pour copier le résultat.", + }, + }, + ], + }, + { + "@type": "BreadcrumbList", + "@id": `${SITE_URL}/#breadcrumb`, + itemListElement: [ + { + "@type": "ListItem", + position: 1, + name: "Accueil", + item: SITE_URL, + }, + ], + }, + ], + }; + + return ( + + + {/* Script inline pour éviter le flash de thème */} +