diff --git a/CONTEXT.md b/CONTEXT.md index 9ce9d9f..80df1f3 100644 --- a/CONTEXT.md +++ b/CONTEXT.md @@ -30,7 +30,7 @@ vrai navigateur (Chromium) avec 4 niveaux jouables. | Erreurs | `app/js/core/ErrorTranslator.js` + `app/js/i18n/errors.{fr,en}.json` | | Progression | `app/js/core/ProgressStore.js`, `KeyValueStores.js` (IndexedDB/mémoire), `SettingsStore.js` | | Audio / voix | `app/js/core/AudioEngine.js` (sons synthétisés), `VoiceEngine.js` (mp3 Piper + repli speechSynthesis), `speechKey.js` ; `scripts/generate_voice.py`, `voice_key.py` | -| UI | `app/js/ui/` (CellView, CellManager, NotebookView, HintPanel, ProgressMap, BadgeToast, SettingsPanel, dom.js), `app/js/i18n/{i18n.js,fr.json,en.json}`, `app/css/app.css` | +| UI | `app/js/ui/` (CellView, CellManager, NotebookView, HintPanel, ProgressMap, BadgeToast, SettingsPanel, dom.js), `app/js/i18n/{i18n.js,fr.json,en.json}`, `app/css/{themes,base,cells}.css`, `ui/CodeEditor.js`, `ui/highlightPython.js` | | Shell PWA | `app/index.html`, `app/js/main.js`, `app/service-worker.js`, `app/manifest.webmanifest` | | Tooling | `Makefile`, `scripts/{dev_server,validate_levels,build}.py`, `scripts/vendor_pyodide.sh` | | Tests | `tests/js/*.test.mjs` (node:test), `tests/python/`, `backend/sync/tests.py`, `tests/e2e/` (Chromium) | @@ -80,8 +80,12 @@ vrai navigateur (Chromium) avec 4 niveaux jouables. `ui/Drawer.js`, en-tête avec niveau courant + précédent/suivant, lien direct `#/levels/`, historique navigateur). **Étape 1 faite** : page de propositions `docs/design/identity/index.html` (3 palettes avec contrastes WCAG calculés, 3 typographies auto-hébergeables OFL, 3 mascottes + messages - fr/en) ; **recommandation : palette B, typo 2, mascotte 1 (Chouette)** — *en attente du choix de - l'utilisateur*. **Reste** : identité visuelle + fr/en) ; **recommandation : palette B, typo 2, mascotte 1 (Chouette)** — **choix validé par l'utilisateur** (voir + `docs/design/07-visual-identity.md`). **Étape 2 faite** : CSS découpé (`themes`/`base`/`cells`), + palette B + typo 2 auto-hébergée, éditeur coloré (`CodeEditor`, `highlightPython`), icône + chouette + PNG (`make icons`), test de contraste des thèmes. **Étape 3 restante** : carte de + progression graphique + personnage-guide (chouette) aux messages variés fr/en, badges + illustrés, feedback coloré doublé de texte. Anciennes notes : **Reste** : identité visuelle (palette, typo, logo), découpage CSS (`base`/`themes`/`cells`), coloration syntaxique de l'éditeur, carte de progression graphique, personnage-guide aux messages variés fr/en, badges illustrés, feedback coloré (vert/rouge, toujours doublé d'un texte). Procéder en 3 diff --git a/Makefile b/Makefile index 2fb0c30..1a2e7d5 100644 --- a/Makefile +++ b/Makefile @@ -5,7 +5,7 @@ VENV := .venv VENV_PY := $(VENV)/bin/python PORT ?= 8000 -.PHONY: help install vendor-pyodide dev validate-levels build test test-js test-python test-backend test-e2e typecheck voice check-voice clean +.PHONY: help install vendor-pyodide dev validate-levels build test test-js test-python test-backend test-e2e typecheck icons voice check-voice clean help: ## Affiche cette aide @grep -E '^[a-z-]+:.*##' $(MAKEFILE_LIST) | awk -F':.*## ' '{printf " %-16s %s\n", $$1, $$2}' @@ -48,6 +48,10 @@ test-e2e: ## Tests bout en bout dans Chromium (CHROMIUM=/chemin/navigateur) typecheck: $(VENV)/.installed ## Vérifie les types Python avec pyright $(VENV)/bin/pyright +icons: ## Régénère les icônes PNG depuis app/icons/icon.svg (Chromium requis) + npm --prefix tests/e2e install --silent + node scripts/render_icons.mjs + voice: ## Génère la narration (Piper → mp3) pour les textes de niveaux ; voir levels/AUDIO-CREDITS.md $(PYTHON) -m venv .venv-voice .venv-voice/bin/pip install --quiet -r requirements-voice.txt diff --git a/app/assets/fonts/LICENSE-atkinson-hyperlegible.txt b/app/assets/fonts/LICENSE-atkinson-hyperlegible.txt new file mode 100644 index 0000000..54e3127 --- /dev/null +++ b/app/assets/fonts/LICENSE-atkinson-hyperlegible.txt @@ -0,0 +1,93 @@ +Copyright 2020 Braille Institute of America, Inc. AtkinsonHyperlegible-Italic.ttf: Copyright 2020 Braille Institute of America, Inc. AtkinsonHyperlegible-Bold.ttf: Copyright 2020 Braille Institute of America, Inc. AtkinsonHyperlegible-BoldItalic.ttf: Copyright 2020 Braille Institute of America, Inc. + +This Font Software is licensed under the SIL Open Font License, Version 1.1. +This license is copied below, and is also available with a FAQ at: +http://scripts.sil.org/OFL + + +----------------------------------------------------------- +SIL OPEN FONT LICENSE Version 1.1 - 26 February 2007 +----------------------------------------------------------- + +PREAMBLE +The goals of the Open Font License (OFL) are to stimulate worldwide +development of collaborative font projects, to support the font creation +efforts of academic and linguistic communities, and to provide a free and +open framework in which fonts may be shared and improved in partnership +with others. + +The OFL allows the licensed fonts to be used, studied, modified and +redistributed freely as long as they are not sold by themselves. The +fonts, including any derivative works, can be bundled, embedded, +redistributed and/or sold with any software provided that any reserved +names are not used by derivative works. The fonts and derivatives, +however, cannot be released under any other type of license. The +requirement for fonts to remain under this license does not apply +to any document created using the fonts or their derivatives. + +DEFINITIONS +"Font Software" refers to the set of files released by the Copyright +Holder(s) under this license and clearly marked as such. This may +include source files, build scripts and documentation. + +"Reserved Font Name" refers to any names specified as such after the +copyright statement(s). + +"Original Version" refers to the collection of Font Software components as +distributed by the Copyright Holder(s). + +"Modified Version" refers to any derivative made by adding to, deleting, +or substituting -- in part or in whole -- any of the components of the +Original Version, by changing formats or by porting the Font Software to a +new environment. + +"Author" refers to any designer, engineer, programmer, technical +writer or other person who contributed to the Font Software. + +PERMISSION & CONDITIONS +Permission is hereby granted, free of charge, to any person obtaining +a copy of the Font Software, to use, study, copy, merge, embed, modify, +redistribute, and sell modified and unmodified copies of the Font +Software, subject to the following conditions: + +1) Neither the Font Software nor any of its individual components, +in Original or Modified Versions, may be sold by itself. + +2) Original or Modified Versions of the Font Software may be bundled, +redistributed and/or sold with any software, provided that each copy +contains the above copyright notice and this license. These can be +included either as stand-alone text files, human-readable headers or +in the appropriate machine-readable metadata fields within text or +binary files as long as those fields can be easily viewed by the user. + +3) No Modified Version of the Font Software may use the Reserved Font +Name(s) unless explicit written permission is granted by the corresponding +Copyright Holder. This restriction only applies to the primary font name as +presented to the users. + +4) The name(s) of the Copyright Holder(s) or the Author(s) of the Font +Software shall not be used to promote, endorse or advertise any +Modified Version, except to acknowledge the contribution(s) of the +Copyright Holder(s) and the Author(s) or with their explicit written +permission. + +5) The Font Software, modified or unmodified, in part or in whole, +must be distributed entirely under this license, and must not be +distributed under any other license. The requirement for fonts to +remain under this license does not apply to any document created +using the Font Software. + +TERMINATION +This license becomes null and void if any of the above conditions are +not met. + +DISCLAIMER +THE FONT SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTIES OF +MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT +OF COPYRIGHT, PATENT, TRADEMARK, OR OTHER RIGHT. IN NO EVENT SHALL THE +COPYRIGHT HOLDER BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, +INCLUDING ANY GENERAL, SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL +DAMAGES, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +FROM, OUT OF THE USE OR INABILITY TO USE THE FONT SOFTWARE OR FROM +OTHER DEALINGS IN THE FONT SOFTWARE. diff --git a/app/assets/fonts/LICENSE-jetbrains-mono.txt b/app/assets/fonts/LICENSE-jetbrains-mono.txt new file mode 100644 index 0000000..8f7ed67 --- /dev/null +++ b/app/assets/fonts/LICENSE-jetbrains-mono.txt @@ -0,0 +1,93 @@ +Copyright 2020 The JetBrains Mono Project Authors (https://github.com/JetBrains/JetBrainsMono) JetBrainsMono-Italic[wght].ttf: Copyright 2020 The JetBrains Mono Project Authors (https://github.com/JetBrains/JetBrainsMono) + +This Font Software is licensed under the SIL Open Font License, Version 1.1. +This license is copied below, and is also available with a FAQ at: +http://scripts.sil.org/OFL + + +----------------------------------------------------------- +SIL OPEN FONT LICENSE Version 1.1 - 26 February 2007 +----------------------------------------------------------- + +PREAMBLE +The goals of the Open Font License (OFL) are to stimulate worldwide +development of collaborative font projects, to support the font creation +efforts of academic and linguistic communities, and to provide a free and +open framework in which fonts may be shared and improved in partnership +with others. + +The OFL allows the licensed fonts to be used, studied, modified and +redistributed freely as long as they are not sold by themselves. The +fonts, including any derivative works, can be bundled, embedded, +redistributed and/or sold with any software provided that any reserved +names are not used by derivative works. The fonts and derivatives, +however, cannot be released under any other type of license. The +requirement for fonts to remain under this license does not apply +to any document created using the fonts or their derivatives. + +DEFINITIONS +"Font Software" refers to the set of files released by the Copyright +Holder(s) under this license and clearly marked as such. This may +include source files, build scripts and documentation. + +"Reserved Font Name" refers to any names specified as such after the +copyright statement(s). + +"Original Version" refers to the collection of Font Software components as +distributed by the Copyright Holder(s). + +"Modified Version" refers to any derivative made by adding to, deleting, +or substituting -- in part or in whole -- any of the components of the +Original Version, by changing formats or by porting the Font Software to a +new environment. + +"Author" refers to any designer, engineer, programmer, technical +writer or other person who contributed to the Font Software. + +PERMISSION & CONDITIONS +Permission is hereby granted, free of charge, to any person obtaining +a copy of the Font Software, to use, study, copy, merge, embed, modify, +redistribute, and sell modified and unmodified copies of the Font +Software, subject to the following conditions: + +1) Neither the Font Software nor any of its individual components, +in Original or Modified Versions, may be sold by itself. + +2) Original or Modified Versions of the Font Software may be bundled, +redistributed and/or sold with any software, provided that each copy +contains the above copyright notice and this license. These can be +included either as stand-alone text files, human-readable headers or +in the appropriate machine-readable metadata fields within text or +binary files as long as those fields can be easily viewed by the user. + +3) No Modified Version of the Font Software may use the Reserved Font +Name(s) unless explicit written permission is granted by the corresponding +Copyright Holder. This restriction only applies to the primary font name as +presented to the users. + +4) The name(s) of the Copyright Holder(s) or the Author(s) of the Font +Software shall not be used to promote, endorse or advertise any +Modified Version, except to acknowledge the contribution(s) of the +Copyright Holder(s) and the Author(s) or with their explicit written +permission. + +5) The Font Software, modified or unmodified, in part or in whole, +must be distributed entirely under this license, and must not be +distributed under any other license. The requirement for fonts to +remain under this license does not apply to any document created +using the Font Software. + +TERMINATION +This license becomes null and void if any of the above conditions are +not met. + +DISCLAIMER +THE FONT SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTIES OF +MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT +OF COPYRIGHT, PATENT, TRADEMARK, OR OTHER RIGHT. IN NO EVENT SHALL THE +COPYRIGHT HOLDER BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, +INCLUDING ANY GENERAL, SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL +DAMAGES, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +FROM, OUT OF THE USE OR INABILITY TO USE THE FONT SOFTWARE OR FROM +OTHER DEALINGS IN THE FONT SOFTWARE. diff --git a/app/assets/fonts/atkinson-hyperlegible-latin-400-normal.woff2 b/app/assets/fonts/atkinson-hyperlegible-latin-400-normal.woff2 new file mode 100644 index 0000000..2e43c90 Binary files /dev/null and b/app/assets/fonts/atkinson-hyperlegible-latin-400-normal.woff2 differ diff --git a/app/assets/fonts/atkinson-hyperlegible-latin-700-normal.woff2 b/app/assets/fonts/atkinson-hyperlegible-latin-700-normal.woff2 new file mode 100644 index 0000000..bc31903 Binary files /dev/null and b/app/assets/fonts/atkinson-hyperlegible-latin-700-normal.woff2 differ diff --git a/app/assets/fonts/jetbrains-mono-latin-400-normal.woff2 b/app/assets/fonts/jetbrains-mono-latin-400-normal.woff2 new file mode 100644 index 0000000..5858873 Binary files /dev/null and b/app/assets/fonts/jetbrains-mono-latin-400-normal.woff2 differ diff --git a/app/assets/fonts/jetbrains-mono-latin-700-normal.woff2 b/app/assets/fonts/jetbrains-mono-latin-700-normal.woff2 new file mode 100644 index 0000000..3a4e333 Binary files /dev/null and b/app/assets/fonts/jetbrains-mono-latin-700-normal.woff2 differ diff --git a/app/css/app.css b/app/css/base.css similarity index 71% rename from app/css/app.css rename to app/css/base.css index 43ad995..d24ad9c 100644 --- a/app/css/app.css +++ b/app/css/base.css @@ -1,57 +1,10 @@ -/* Styles de l'application : jetons de thème, clair/sombre, taille réglable, focus visible. */ - -:root { - --bg: #ffffff; - --surface: #f4f6fa; - --text: #1b1f27; - --muted: #4a5365; - --border: #b8c0cf; - --accent: #1d4ed8; - --accent-text: #ffffff; - --ok: #146c2e; - --ko: #a31515; - --focus: #b45309; - /* Réglable par SettingsPanel : html { font-size: calc(var(--font-scale) * 100%) } */ - --font-scale: 1; -} - -@media (prefers-color-scheme: dark) { - :root:not([data-theme="light"]) { - --bg: #12151c; - --surface: #1c212c; - --text: #eceff5; - --muted: #b3bccd; - --border: #4a5365; - --accent: #8ab4ff; - --accent-text: #0b1020; - --ok: #6ee08a; - --ko: #ff8a8a; - --focus: #ffcc66; - } -} - -:root[data-theme="dark"] { - --bg: #12151c; - --surface: #1c212c; - --text: #eceff5; - --muted: #b3bccd; - --border: #4a5365; - --accent: #8ab4ff; - --accent-text: #0b1020; - --ok: #6ee08a; - --ko: #ff8a8a; - --focus: #ffcc66; -} - -html { - font-size: calc(var(--font-scale) * 100%); -} +/* Base : corps de page, focus, boutons, en-tête, notebook, tiroirs, toasts, réglages. */ body { margin: 0; background: var(--bg); color: var(--text); - font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; + font-family: var(--font-ui); line-height: 1.55; } @@ -60,26 +13,33 @@ body { outline-offset: 2px; } -.notebook { - max-width: 48rem; - margin: 0 auto; - padding: 1rem; +/* L'attribut hidden doit toujours l'emporter sur les règles display des composants. */ +[hidden] { + display: none !important; } -.notebook-status { - color: var(--muted); - min-height: 1.5em; +code, +pre { + font-family: var(--font-code); + /* Pas de ligatures : un débutant doit voir exactement les caractères tapés (>= et non ≥). */ + font-variant-ligatures: none; } -.explain, -.cell { - background: var(--surface); - border: 1px solid var(--border); - border-radius: 0.5rem; - padding: 1rem; - margin: 1rem 0; +.skip-link { + position: absolute; + left: -9999px; } +.skip-link:focus { + left: 1rem; + top: 1rem; + padding: 0.5rem 1rem; + background: var(--bg); + color: var(--text); + z-index: 30; +} + +/* Boutons */ .btn { min-height: 2.75rem; /* cible tactile confortable (WCAG 2.5.8) */ padding: 0.4rem 1rem; @@ -102,167 +62,6 @@ body { cursor: not-allowed; } -.cell-actions { - display: flex; - flex-wrap: wrap; - gap: 0.5rem; - margin: 0.5rem 0; -} - -.code-editor { - width: 100%; - box-sizing: border-box; - font-family: ui-monospace, "SFMono-Regular", Consolas, monospace; - font-size: 1rem; - padding: 0.75rem; - background: var(--bg); - color: var(--text); - border: 1px solid var(--border); - border-radius: 0.375rem; - tab-size: 4; -} - -.cell-shortcut { - margin: 0.25rem 0; - color: var(--muted); - font-size: 0.875rem; -} - -.cell-output { - min-height: 1.5rem; - margin: 0.5rem 0; - padding: 0.5rem 0.75rem; - background: var(--bg); - border-left: 4px solid var(--border); - white-space: pre-wrap; -} - -.feedback-ok { - color: var(--ok); - font-weight: 600; -} - -.feedback-ko, -.error-title { - color: var(--ko); - font-weight: 600; -} - -.hint-list { - flex-basis: 100%; - margin: 0; -} - -.toast-region { - position: fixed; - right: 1rem; - bottom: 1rem; - display: flex; - flex-direction: column; - gap: 0.5rem; - max-width: calc(100vw - 2rem); -} - -.toast { - display: flex; - gap: 0.75rem; - align-items: center; - padding: 0.75rem 1rem; - background: var(--surface); - color: var(--text); - border: 2px solid var(--accent); - border-radius: 0.5rem; -} - -.level-list { - list-style: none; - padding: 0; -} - -.level-button { - display: flex; - justify-content: space-between; - width: 100%; - margin: 0.25rem 0; - padding: 0.5rem 0.75rem; - background: var(--surface); - color: var(--text); - border: 1px solid var(--border); - border-radius: 0.375rem; - font: inherit; - cursor: pointer; -} - -.level-button.is-current { - border-width: 3px; - border-color: var(--accent); -} - -.setting { - display: grid; - grid-template-columns: 8rem 1fr; - gap: 0.75rem; - align-items: center; - margin: 0.75rem 0; -} - -.setting select, -.setting input[type="range"] { - width: 100%; - min-height: 2.5rem; - font: inherit; -} - -.setting input[type="checkbox"] { - width: 1.5rem; - height: 1.5rem; - justify-self: start; -} - -.setting > .btn:only-child { - grid-column: 1 / -1; -} - -@media (prefers-reduced-motion: reduce) { - * { - animation: none !important; - transition: none !important; - } -} - -.skip-link { - position: absolute; - left: -9999px; -} - -.skip-link:focus { - left: 1rem; - top: 1rem; - padding: 0.5rem 1rem; - background: var(--bg); - color: var(--text); - z-index: 10; -} - -.explain > :first-child, -.cell > :first-child { - margin-top: 0; -} - -.level-button { - flex-wrap: wrap; - gap: 0.25rem 0.75rem; - text-align: left; -} - -.level-title { - flex: 1 1 8rem; -} - -.level-state { - white-space: nowrap; -} - /* En-tête : accès aux niveaux (gauche), niveau courant avec navigation (centre), réglages (droite). */ .app-header { display: grid; @@ -281,6 +80,18 @@ body { min-width: 0; } +.brand { + display: flex; + align-items: center; + gap: 0.5rem; +} + +.brand img { + width: 2rem; + height: 2rem; + border-radius: 0.5rem; +} + .app-heading h1 { margin: 0; font-size: 1.25rem; @@ -306,6 +117,59 @@ body { white-space: nowrap; } +/* Notebook */ +.notebook { + max-width: 48rem; + margin: 0 auto; + padding: 1rem; +} + +.notebook-status { + color: var(--muted); + min-height: 1.5em; +} + +.explain { + background: var(--surface); + border: 1px solid var(--border); + border-radius: 0.5rem; + padding: 1rem; + margin: 1rem 0; +} + +.explain > :first-child { + margin-top: 0; +} + +.explain code { + background: var(--code); + padding: 0.05rem 0.3rem; + border-radius: 0.25rem; +} + +/* Notifications */ +.toast-region { + position: fixed; + right: 1rem; + bottom: 1rem; + display: flex; + flex-direction: column; + gap: 0.5rem; + max-width: calc(100vw - 2rem); + z-index: 40; +} + +.toast { + display: flex; + gap: 0.75rem; + align-items: center; + padding: 0.75rem 1rem; + background: var(--surface); + color: var(--text); + border: 2px solid var(--accent); + border-radius: 0.5rem; +} + /* Tiroirs coulissants. Fermés : visibility:hidden (hors navigation clavier), ouverts : glissent. */ .drawer-overlay { position: fixed; @@ -375,6 +239,7 @@ body { padding: 1rem; } +/* Progression */ .progress-bar { width: 100%; height: 1rem; @@ -383,7 +248,69 @@ body { .progress-count { margin: 0 0 0.25rem; - font-weight: 600; + font-weight: 700; +} + +.level-list { + list-style: none; + padding: 0; +} + +.level-button { + display: flex; + flex-wrap: wrap; + justify-content: space-between; + gap: 0.25rem 0.75rem; + width: 100%; + margin: 0.25rem 0; + padding: 0.5rem 0.75rem; + background: var(--surface); + color: var(--text); + border: 1px solid var(--border); + border-radius: 0.375rem; + font: inherit; + text-align: left; + cursor: pointer; +} + +.level-button.is-current { + border-width: 3px; + border-color: var(--accent); +} + +.level-title { + flex: 1 1 8rem; +} + +.level-state { + white-space: nowrap; +} + +/* Réglages */ +.setting { + display: grid; + grid-template-columns: 8rem 1fr; + gap: 0.75rem; + align-items: center; + margin: 0.75rem 0; +} + +.setting select, +.setting input[type="range"] { + width: 100%; + min-height: 2.5rem; + font: inherit; +} + +.setting input[type="checkbox"] { + width: 1.5rem; + height: 1.5rem; + justify-self: start; + accent-color: var(--accent); +} + +.setting > .btn:only-child { + grid-column: 1 / -1; } @media (max-width: 40rem) { @@ -396,3 +323,10 @@ body { grid-row: 2; } } + +@media (prefers-reduced-motion: reduce) { + * { + animation: none !important; + transition: none !important; + } +} diff --git a/app/css/cells.css b/app/css/cells.css new file mode 100644 index 0000000..5c93b39 --- /dev/null +++ b/app/css/cells.css @@ -0,0 +1,154 @@ +/* Cellules de code : éditeur coloré, actions, sortie, retours de validation, indices, saisie. */ + +.cell { + background: var(--surface); + border: 1px solid var(--border); + border-radius: 0.5rem; + padding: 1rem; + margin: 1rem 0; +} + +.cell > :first-child { + margin-top: 0; +} + +.cell-actions { + display: flex; + flex-wrap: wrap; + gap: 0.5rem; + margin: 0.5rem 0; +} + +.cell-shortcut { + margin: 0.25rem 0; + color: var(--muted); + font-size: 0.875rem; +} + +/* Éditeur : un