From ac00dab67306bf612956ecb62e4f95d795c8e68a Mon Sep 17 00:00:00 2001 From: Julien Calixte Date: Fri, 1 Aug 2025 10:48:53 +0200 Subject: [PATCH] Chore/change theme (#13) * chore: script to change theme * style: fix md --- _scripts/change-theme-dark.ts | 36 +++++++++++++++ _scripts/change-theme-light.ts | 46 +++++++++++++++++++ package.json | 5 ++- plan.md | 6 +-- pnpm-lock.yaml | 81 +++++++++++++++++++++++----------- src/components/ThemeSwap.vue | 6 ++- src/theme.config.ts | 7 +++ 7 files changed, 156 insertions(+), 31 deletions(-) create mode 100644 _scripts/change-theme-dark.ts create mode 100644 _scripts/change-theme-light.ts create mode 100644 src/theme.config.ts diff --git a/_scripts/change-theme-dark.ts b/_scripts/change-theme-dark.ts new file mode 100644 index 0000000..a51e6d4 --- /dev/null +++ b/_scripts/change-theme-dark.ts @@ -0,0 +1,36 @@ +#!/usr/bin/env node + +// Script pour changer facilement le thème sombre de l'application LiteNote +// Usage: pnpm run theme:dark [nom-du-theme] + +import { readFileSync, writeFileSync } from "fs" +import { join } from "path" + +// Chemins vers les fichiers +const themeConfigPath = join(__dirname, "..", "src", "theme.config.ts") + +// Vérifier les arguments +if (process.argv.length < 3) { + console.log("Usage: pnpm run theme:dark [nom-du-theme]") + console.log("Exemple: pnpm run theme:dark business") + process.exit(1) +} + +// Mode fixé à dark pour ce script +const mode = "dark" +const newTheme = process.argv[2] // nom du nouveau thème + +// Lire le contenu actuel du fichier de configuration +let themeConfigContent = readFileSync(themeConfigPath, "utf8") + +// Remplacer la valeur du thème sombre +themeConfigContent = themeConfigContent.replace( + /dark:\s*['"][^'"]*['"],/, + `dark: '${newTheme}',`, +) + +// Écrire le contenu mis à jour dans le fichier +writeFileSync(themeConfigPath, themeConfigContent) + +console.log(`Thème ${mode} mis à jour avec succès vers: ${newTheme}`) +console.log("Redémarrez le serveur de développement si nécessaire") diff --git a/_scripts/change-theme-light.ts b/_scripts/change-theme-light.ts new file mode 100644 index 0000000..53e2bc1 --- /dev/null +++ b/_scripts/change-theme-light.ts @@ -0,0 +1,46 @@ +#!/usr/bin/env node + +// Script pour changer facilement le thème clair de l'application LiteNote +// Usage: pnpm run theme:light [nom-du-theme] + +import { readFileSync, writeFileSync } from "fs" +import { join } from "path" + +// Chemins vers les fichiers +const themeConfigPath = join(__dirname, "..", "src", "theme.config.ts") +const indexPath = join(__dirname, "..", "index.html") + +// Vérifier les arguments +if (process.argv.length < 3) { + console.log("Usage: pnpm run theme:light [nom-du-theme]") + console.log("Exemple: pnpm run theme:light cupcake") + process.exit(1) +} + +// Mode fixé à light pour ce script +const mode = "light" +const newTheme = process.argv[2] // nom du nouveau thème + +// Lire le contenu actuel du fichier de configuration +let themeConfigContent = readFileSync(themeConfigPath, "utf8") + +// Remplacer la valeur du thème clair +themeConfigContent = themeConfigContent.replace( + /light:\s*['"][^'"]*['"],/, + `light: '${newTheme}',`, +) + +// Écrire le contenu mis à jour dans le fichier +writeFileSync(themeConfigPath, themeConfigContent) + +// Mettre à jour également le fichier index.html +let indexContent = readFileSync(indexPath, "utf8") +indexContent = indexContent.replace( + /data-theme="[^"]*"/, + `data-theme="${newTheme}"`, +) +writeFileSync(indexPath, indexContent) + +console.log(`Thème ${mode} mis à jour avec succès vers: ${newTheme}`) +console.log("Le fichier index.html a également été mis à jour.") +console.log("Redémarrez le serveur de développement si nécessaire") diff --git a/package.json b/package.json index 958a6db..e72f2ba 100644 --- a/package.json +++ b/package.json @@ -10,7 +10,9 @@ "types": "tsc --noEmit", "lint": "eslint --ext .ts,.js,.vue --ignore-path .gitignore --fix src", "pwa:asset": "npx vue-pwa-asset-generator -a public/img/logo.png --no-manifest", - "prepare": "husky" + "prepare": "husky", + "theme:light": "esno _scripts/change-theme-light.ts", + "theme:dark": "esno _scripts/change-theme-dark.ts" }, "dependencies": { "@intlify/unplugin-vue-i18n": "^1.6.0", @@ -71,6 +73,7 @@ "eslint-plugin-simple-import-sort": "^10.0.0", "eslint-plugin-unused-imports": "^3.2.0", "eslint-plugin-vue": "^9.31.0", + "esno": "^4.8.0", "husky": "^9.1.7", "prettier": "^3.5.3", "sass": "^1.89.0", diff --git a/plan.md b/plan.md index d3ce0ba..3fdaf7d 100644 --- a/plan.md +++ b/plan.md @@ -329,7 +329,7 @@ Voir aussi [ma-note-privee](# "Cette note n'est pas publique") et [ma-note-publi Vos notes publiques sont accessibles via : -``` +```md Format principal : https://litenote.space/{username}/{username}-litenote-public @@ -424,7 +424,7 @@ https://{username}.github.io/{username}-litenote-public/ ### Nouveaux Fichiers -``` +```sh src/modules/public-sharing/ ├── interfaces/ │ ├── PublicNoteMetadata.ts @@ -451,7 +451,7 @@ src/modules/public-sharing/ ### Fichiers à Modifier -``` +```sh src/hooks/useGitHubContent.hook.ts # Intégration sync publique src/hooks/useFile.hook.ts # Détection métadonnées src/components/FluxNote.vue # Indicateurs visuels diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 9e9e277..495a384 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -140,7 +140,7 @@ importers: version: 8.33.0(eslint@8.57.1)(typescript@5.8.3) '@vitejs/plugin-vue': specifier: ^5.2.4 - version: 5.2.4(vite@6.3.5(@types/node@22.15.24)(jiti@2.4.2)(lightningcss@1.30.1)(sass@1.89.0)(terser@5.36.0))(vue@3.5.16(typescript@5.8.3)) + version: 5.2.4(vite@6.3.5(@types/node@22.15.24)(jiti@2.4.2)(lightningcss@1.30.1)(sass@1.89.0)(terser@5.36.0)(tsx@4.20.3))(vue@3.5.16(typescript@5.8.3)) '@vue/compiler-sfc': specifier: ^3.5.16 version: 3.5.16 @@ -177,6 +177,9 @@ importers: eslint-plugin-vue: specifier: ^9.31.0 version: 9.31.0(eslint@8.57.1) + esno: + specifier: ^4.8.0 + version: 4.8.0 husky: specifier: ^9.1.7 version: 9.1.7 @@ -194,13 +197,13 @@ importers: version: 5.8.3 vite: specifier: ^6.3.5 - version: 6.3.5(@types/node@22.15.24)(jiti@2.4.2)(lightningcss@1.30.1)(sass@1.89.0)(terser@5.36.0) + version: 6.3.5(@types/node@22.15.24)(jiti@2.4.2)(lightningcss@1.30.1)(sass@1.89.0)(terser@5.36.0)(tsx@4.20.3) vite-plugin-pwa: specifier: ^1.0.0 - version: 1.0.0(vite@6.3.5(@types/node@22.15.24)(jiti@2.4.2)(lightningcss@1.30.1)(sass@1.89.0)(terser@5.36.0))(workbox-build@7.0.0)(workbox-window@7.0.0) + version: 1.0.0(vite@6.3.5(@types/node@22.15.24)(jiti@2.4.2)(lightningcss@1.30.1)(sass@1.89.0)(terser@5.36.0)(tsx@4.20.3))(workbox-build@7.0.0)(workbox-window@7.0.0) vitest: specifier: ^3.1.4 - version: 3.1.4(@types/node@22.15.24)(jiti@2.4.2)(lightningcss@1.30.1)(sass@1.89.0)(terser@5.36.0) + version: 3.1.4(@types/node@22.15.24)(jiti@2.4.2)(lightningcss@1.30.1)(sass@1.89.0)(terser@5.36.0)(tsx@4.20.3) webpack: specifier: ^5.99.9 version: 5.99.9 @@ -1652,9 +1655,6 @@ packages: '@types/sanitize-html@2.16.0': resolution: {integrity: sha512-l6rX1MUXje5ztPT0cAFtUayXF06DqPhRyfVXareEN5gGCFaP/iwsxIyKODr9XDhfxPpN6vXUFNfo5kZMXCxBtw==} - '@types/trusted-types@2.0.3': - resolution: {integrity: sha512-NfQ4gyz38SL8sDNrSixxU2Os1a5xcdFxipAFxYEuLUlvU2uDwS4NUpsImcf1//SlWItCVMMLiylsxbmNMToV/g==} - '@types/trusted-types@2.0.7': resolution: {integrity: sha512-ScaPdn1dQczgbl0QFTeTOmVHFULt394XJgOQNoyVhZ6r2vLnMLJfBPd53SB52T/3G36VI1/g2MZaX0cwDuXsfw==} @@ -2504,6 +2504,10 @@ packages: deprecated: This version is no longer supported. Please see https://eslint.org/version-support for other options. hasBin: true + esno@4.8.0: + resolution: {integrity: sha512-acMtooReAQGzLU0zcuEDHa8S62meh5aIyi8jboYxyvAePdmuWx2Mpwmt0xjwO0bs9/SXf+dvXJ0QJoDWw814Iw==} + hasBin: true + espree@10.3.0: resolution: {integrity: sha512-0QYC8b24HWY8zjRnDTL6RiHfDbAWn63qb4LMj1Z4b076A4une81+z03Kg7l7mn/48PUTqoLptSXez8oknU8Clg==} engines: {node: ^18.18.0 || ^20.9.0 || >=21.1.0} @@ -2681,6 +2685,9 @@ packages: resolution: {integrity: sha512-2EmdH1YvIQiZpltCNgkuiUnyukzxM/R6NDJX31Ke3BG1Nq5b0S2PhX59UKi9vZpPDQVdqn+1IcaAwnzTT5vCjw==} engines: {node: '>= 0.4'} + get-tsconfig@4.10.1: + resolution: {integrity: sha512-auHyJ4AgMz7vgS8Hp3N6HXSmlMdUyhSUrfBF16w153rxtLIEOE+HGqaBppczZvnHLqQJfiHotCYpNhl0lUROFQ==} + glob-parent@5.1.2: resolution: {integrity: sha512-AOIgSQCepiJYwP3ARnGx+5VnTu2HBYdzbGP45eLw1vr3zB3vZLeyed1sC9hnbcOc9/SrMyM5RPQrkGz4aS9Zow==} engines: {node: '>= 6'} @@ -3543,6 +3550,9 @@ packages: resolution: {integrity: sha512-pb/MYmXstAkysRFx8piNI1tGFNQIFA3vkE3Gq4EuA1dF6gHp/+vgZqsCGJapvy8N3Q+4o7FwvquPJcnZ7RYy4g==} engines: {node: '>=4'} + resolve-pkg-maps@1.0.0: + resolution: {integrity: sha512-seS2Tj26TBVOC2NIc2rOe2y2ZO7efxITtLZcGSOnHHNOQ7CkiUBfw0Iw2ck6xkIhPwLhKNLS8BO+hEpngQlqzw==} + resolve@1.22.10: resolution: {integrity: sha512-NPRy+/ncIMeDlTAsuqwKIiferiawhefFJtkNSW0qZJEqMEb+qBt/77B/jGeeek+F0uOeN05CDa6HXbbIgtVX4w==} engines: {node: '>= 0.4'} @@ -3670,6 +3680,7 @@ packages: source-map@0.8.0-beta.0: resolution: {integrity: sha512-2ymg6oRBpebeZi9UUNsgQ89bhx01TcTkmNTGnNO88imTmbSgy4nfujrgVEFKWpMTEGA11EDkTt7mqObTPdigIA==} engines: {node: '>= 8'} + deprecated: The work that was done in this beta branch won't be included in future versions sourcemap-codec@1.4.8: resolution: {integrity: sha512-9NykojV5Uih4lgo5So5dtw+f0JgJX30KCNI8gwhz2J9A15wD0Ml6tjHKwf6fTSa6fAdVBdZeNOs9eJ71qCk8vA==} @@ -3839,6 +3850,11 @@ packages: tslib@2.6.1: resolution: {integrity: sha512-t0hLfiEKfMUoqhG+U1oid7Pva4bbDPHYfJNiB7BiIjRkj1pyC++4N3huJfqY6aRH6VTB0rvtzQwjM4K6qpfOig==} + tsx@4.20.3: + resolution: {integrity: sha512-qjbnuR9Tr+FJOMBqJCW5ehvIo/buZq7vH7qD7JziU98h6l3qGy0a/yPFjwO+y0/T7GFpNgNAvEcPPVfyT8rrPQ==} + engines: {node: '>=18.0.0'} + hasBin: true + type-check@0.4.0: resolution: {integrity: sha512-XleUoc9uwGXqjWwXaUTZAmzMcFZ5858QA2vvx1Ur5xIcixXIP+8LnFDgRplU30us6teqdlskFfu+ae4K79Ooew==} engines: {node: '>= 0.8.0'} @@ -5760,10 +5776,7 @@ snapshots: dependencies: htmlparser2: 8.0.2 - '@types/trusted-types@2.0.3': {} - - '@types/trusted-types@2.0.7': - optional: true + '@types/trusted-types@2.0.7': {} '@types/web-bluetooth@0.0.21': {} @@ -5861,9 +5874,9 @@ snapshots: '@ungap/structured-clone@1.2.0': {} - '@vitejs/plugin-vue@5.2.4(vite@6.3.5(@types/node@22.15.24)(jiti@2.4.2)(lightningcss@1.30.1)(sass@1.89.0)(terser@5.36.0))(vue@3.5.16(typescript@5.8.3))': + '@vitejs/plugin-vue@5.2.4(vite@6.3.5(@types/node@22.15.24)(jiti@2.4.2)(lightningcss@1.30.1)(sass@1.89.0)(terser@5.36.0)(tsx@4.20.3))(vue@3.5.16(typescript@5.8.3))': dependencies: - vite: 6.3.5(@types/node@22.15.24)(jiti@2.4.2)(lightningcss@1.30.1)(sass@1.89.0)(terser@5.36.0) + vite: 6.3.5(@types/node@22.15.24)(jiti@2.4.2)(lightningcss@1.30.1)(sass@1.89.0)(terser@5.36.0)(tsx@4.20.3) vue: 3.5.16(typescript@5.8.3) '@vitest/expect@3.1.4': @@ -5873,13 +5886,13 @@ snapshots: chai: 5.2.0 tinyrainbow: 2.0.0 - '@vitest/mocker@3.1.4(vite@6.3.5(@types/node@22.15.24)(jiti@2.4.2)(lightningcss@1.30.1)(sass@1.89.0)(terser@5.36.0))': + '@vitest/mocker@3.1.4(vite@6.3.5(@types/node@22.15.24)(jiti@2.4.2)(lightningcss@1.30.1)(sass@1.89.0)(terser@5.36.0)(tsx@4.20.3))': dependencies: '@vitest/spy': 3.1.4 estree-walker: 3.0.3 magic-string: 0.30.17 optionalDependencies: - vite: 6.3.5(@types/node@22.15.24)(jiti@2.4.2)(lightningcss@1.30.1)(sass@1.89.0)(terser@5.36.0) + vite: 6.3.5(@types/node@22.15.24)(jiti@2.4.2)(lightningcss@1.30.1)(sass@1.89.0)(terser@5.36.0)(tsx@4.20.3) '@vitest/pretty-format@3.1.4': dependencies: @@ -6813,6 +6826,10 @@ snapshots: transitivePeerDependencies: - supports-color + esno@4.8.0: + dependencies: + tsx: 4.20.3 + espree@10.3.0: dependencies: acorn: 8.14.0 @@ -6996,6 +7013,10 @@ snapshots: call-bind: 1.0.2 get-intrinsic: 1.2.1 + get-tsconfig@4.10.1: + dependencies: + resolve-pkg-maps: 1.0.0 + glob-parent@5.1.2: dependencies: is-glob: 4.0.3 @@ -7797,6 +7818,8 @@ snapshots: resolve-from@4.0.0: {} + resolve-pkg-maps@1.0.0: {} + resolve@1.22.10: dependencies: is-core-module: 2.16.0 @@ -8106,6 +8129,13 @@ snapshots: tslib@2.6.1: {} + tsx@4.20.3: + dependencies: + esbuild: 0.25.5 + get-tsconfig: 4.10.1 + optionalDependencies: + fsevents: 2.3.3 + type-check@0.4.0: dependencies: prelude-ls: 1.2.1 @@ -8195,13 +8225,13 @@ snapshots: uuid@8.3.2: {} - vite-node@3.1.4(@types/node@22.15.24)(jiti@2.4.2)(lightningcss@1.30.1)(sass@1.89.0)(terser@5.36.0): + vite-node@3.1.4(@types/node@22.15.24)(jiti@2.4.2)(lightningcss@1.30.1)(sass@1.89.0)(terser@5.36.0)(tsx@4.20.3): dependencies: cac: 6.7.14 debug: 4.4.1 es-module-lexer: 1.7.0 pathe: 2.0.3 - vite: 6.3.5(@types/node@22.15.24)(jiti@2.4.2)(lightningcss@1.30.1)(sass@1.89.0)(terser@5.36.0) + vite: 6.3.5(@types/node@22.15.24)(jiti@2.4.2)(lightningcss@1.30.1)(sass@1.89.0)(terser@5.36.0)(tsx@4.20.3) transitivePeerDependencies: - '@types/node' - jiti @@ -8216,18 +8246,18 @@ snapshots: - tsx - yaml - vite-plugin-pwa@1.0.0(vite@6.3.5(@types/node@22.15.24)(jiti@2.4.2)(lightningcss@1.30.1)(sass@1.89.0)(terser@5.36.0))(workbox-build@7.0.0)(workbox-window@7.0.0): + vite-plugin-pwa@1.0.0(vite@6.3.5(@types/node@22.15.24)(jiti@2.4.2)(lightningcss@1.30.1)(sass@1.89.0)(terser@5.36.0)(tsx@4.20.3))(workbox-build@7.0.0)(workbox-window@7.0.0): dependencies: debug: 4.4.1 pretty-bytes: 6.1.1 tinyglobby: 0.2.14 - vite: 6.3.5(@types/node@22.15.24)(jiti@2.4.2)(lightningcss@1.30.1)(sass@1.89.0)(terser@5.36.0) + vite: 6.3.5(@types/node@22.15.24)(jiti@2.4.2)(lightningcss@1.30.1)(sass@1.89.0)(terser@5.36.0)(tsx@4.20.3) workbox-build: 7.0.0 workbox-window: 7.0.0 transitivePeerDependencies: - supports-color - vite@6.3.5(@types/node@22.15.24)(jiti@2.4.2)(lightningcss@1.30.1)(sass@1.89.0)(terser@5.36.0): + vite@6.3.5(@types/node@22.15.24)(jiti@2.4.2)(lightningcss@1.30.1)(sass@1.89.0)(terser@5.36.0)(tsx@4.20.3): dependencies: esbuild: 0.25.5 fdir: 6.4.5(picomatch@4.0.2) @@ -8242,11 +8272,12 @@ snapshots: lightningcss: 1.30.1 sass: 1.89.0 terser: 5.36.0 + tsx: 4.20.3 - vitest@3.1.4(@types/node@22.15.24)(jiti@2.4.2)(lightningcss@1.30.1)(sass@1.89.0)(terser@5.36.0): + vitest@3.1.4(@types/node@22.15.24)(jiti@2.4.2)(lightningcss@1.30.1)(sass@1.89.0)(terser@5.36.0)(tsx@4.20.3): dependencies: '@vitest/expect': 3.1.4 - '@vitest/mocker': 3.1.4(vite@6.3.5(@types/node@22.15.24)(jiti@2.4.2)(lightningcss@1.30.1)(sass@1.89.0)(terser@5.36.0)) + '@vitest/mocker': 3.1.4(vite@6.3.5(@types/node@22.15.24)(jiti@2.4.2)(lightningcss@1.30.1)(sass@1.89.0)(terser@5.36.0)(tsx@4.20.3)) '@vitest/pretty-format': 3.1.4 '@vitest/runner': 3.1.4 '@vitest/snapshot': 3.1.4 @@ -8263,8 +8294,8 @@ snapshots: tinyglobby: 0.2.14 tinypool: 1.0.2 tinyrainbow: 2.0.0 - vite: 6.3.5(@types/node@22.15.24)(jiti@2.4.2)(lightningcss@1.30.1)(sass@1.89.0)(terser@5.36.0) - vite-node: 3.1.4(@types/node@22.15.24)(jiti@2.4.2)(lightningcss@1.30.1)(sass@1.89.0)(terser@5.36.0) + vite: 6.3.5(@types/node@22.15.24)(jiti@2.4.2)(lightningcss@1.30.1)(sass@1.89.0)(terser@5.36.0)(tsx@4.20.3) + vite-node: 3.1.4(@types/node@22.15.24)(jiti@2.4.2)(lightningcss@1.30.1)(sass@1.89.0)(terser@5.36.0)(tsx@4.20.3) why-is-node-running: 2.3.0 optionalDependencies: '@types/node': 22.15.24 @@ -8546,7 +8577,7 @@ snapshots: workbox-window@7.0.0: dependencies: - '@types/trusted-types': 2.0.3 + '@types/trusted-types': 2.0.7 workbox-core: 7.0.0 wrappy@1.0.2: {} diff --git a/src/components/ThemeSwap.vue b/src/components/ThemeSwap.vue index 92aa3c9..7bdc030 100644 --- a/src/components/ThemeSwap.vue +++ b/src/components/ThemeSwap.vue @@ -1,7 +1,9 @@