From ce1d9a7ab4593e6e5922a9fcaf3c495ad1a5bc16 Mon Sep 17 00:00:00 2001 From: Arthur Danjou Date: Tue, 29 Jul 2025 14:35:07 +0000 Subject: [PATCH] =?UTF-8?q?Refactor=20le=20composant=20AppBackground=20pou?= =?UTF-8?q?r=20utiliser=20le=20nom=20au=20lieu=20du=20chemin=20dans=20l'in?= =?UTF-8?q?terface=20NavColorGroup=20et=20mise=20=C3=A0=20jour=20des=20cou?= =?UTF-8?q?leurs=20de=20navigation.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/components/AppBackground.vue | 29 +++++++++-------------------- types/index.ts | 26 +++++++++++++------------- 2 files changed, 22 insertions(+), 33 deletions(-) diff --git a/app/components/AppBackground.vue b/app/components/AppBackground.vue index f65f566..2837235 100644 --- a/app/components/AppBackground.vue +++ b/app/components/AppBackground.vue @@ -4,29 +4,18 @@ import { navColors } from '~~/types' const route = useRoute() const colorMode = useColorMode() -const currentColors = computed(() => { - const colors = navColors.find(nav => route.path.includes(nav.path))!.colors - const fallback = colorMode.value === 'dark' - ? { - color: '#000000', - x: 0, - y: 0, - } - : { - color: '#ffffff', - x: 0, - y: 0, - } - - return colors || [fallback, fallback] +const colors = computed(() => { + const navColor = navColors.find(nav => route.name === nav.name) + if (navColor?.colors) return navColor.colors + + const fallbackColor = colorMode.value === 'dark' ? '#000000' : '#ffffff' + return [{ color: fallbackColor, x: 0, y: 0 }, { color: fallbackColor, x: 0, y: 0 }] }) const backgroundStyle = computed(() => ({ - backgroundImage: ` - radial-gradient(circle 500px at ${currentColors.value[0].x}% ${currentColors.value[0].y}%, ${currentColors.value[0].color}4D, transparent), - radial-gradient(circle 500px at ${currentColors.value[1].x}% ${currentColors.value[1].y}%, ${currentColors.value[1].color}4D, transparent) - `, - backgroundSize: '100% 100%', + backgroundImage: colors.value + .map(c => `radial-gradient(circle 500px at ${c.x}% ${c.y}%, ${c.color}4D, transparent)`) + .join(', ') })) diff --git a/types/index.ts b/types/index.ts index 4b5f960..3b751e0 100644 --- a/types/index.ts +++ b/types/index.ts @@ -179,7 +179,7 @@ interface NavColor { } interface NavColorGroup { - path: string + name: string colors: Array } @@ -234,19 +234,19 @@ export const navs: Array