forked from yvv/decision
Compare commits
3 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 39883ee444 | |||
| 55020033ee | |||
| a9e586cda1 |
@@ -25,6 +25,7 @@ Thumbs.db
|
|||||||
|
|
||||||
# Database
|
# Database
|
||||||
*.db
|
*.db
|
||||||
|
*.db.bak*
|
||||||
*.sqlite
|
*.sqlite
|
||||||
|
|
||||||
# Docker volumes
|
# Docker volumes
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ const decisionsStore = useDecisionsStore()
|
|||||||
const protocolsStore = useProtocolsStore()
|
const protocolsStore = useProtocolsStore()
|
||||||
const mandatesStore = useMandatesStore()
|
const mandatesStore = useMandatesStore()
|
||||||
const route = useRoute()
|
const route = useRoute()
|
||||||
const { initMood } = useMood()
|
const { initMood } = useLibreMood()
|
||||||
|
|
||||||
const navigationItems = [
|
const navigationItems = [
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
const { currentMood, moods, setMood } = useMood()
|
const { currentMood, moods, setMood } = useLibreMood()
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
|
|||||||
@@ -1,4 +1,7 @@
|
|||||||
import type { Ref } from 'vue'
|
// Ambiances libreDecision — délègue le mécanisme au layer @yvv/nuxt-base.
|
||||||
|
// Les couleurs (identité du projet) restent dans assets/css/moods.css (classes .mood-*).
|
||||||
|
// Le layer fournit l'auto-import `useMood(moods, options)` ; on l'enveloppe ici
|
||||||
|
// sous le nom `useLibreMood` pour éviter la collision avec ce composable auto-importé.
|
||||||
|
|
||||||
export interface Mood {
|
export interface Mood {
|
||||||
id: string
|
id: string
|
||||||
@@ -9,8 +12,6 @@ export interface Mood {
|
|||||||
isDark: boolean
|
isDark: boolean
|
||||||
}
|
}
|
||||||
|
|
||||||
const STORAGE_KEY = 'libredecision_mood'
|
|
||||||
|
|
||||||
const moods: Mood[] = [
|
const moods: Mood[] = [
|
||||||
{ id: 'peps', label: 'Peps', description: 'Chaud et tonique', icon: 'i-lucide-sun', color: '#d44a10', isDark: false },
|
{ id: 'peps', label: 'Peps', description: 'Chaud et tonique', icon: 'i-lucide-sun', color: '#d44a10', isDark: false },
|
||||||
{ id: 'zen', label: 'Zen', description: 'Nature vivante', icon: 'i-lucide-leaf', color: '#2e8b48', isDark: false },
|
{ id: 'zen', label: 'Zen', description: 'Nature vivante', icon: 'i-lucide-leaf', color: '#2e8b48', isDark: false },
|
||||||
@@ -18,49 +19,6 @@ const moods: Mood[] = [
|
|||||||
{ id: 'grave', label: 'Grave', description: 'Ambre mineral', icon: 'i-lucide-shield', color: '#d8a030', isDark: true },
|
{ id: 'grave', label: 'Grave', description: 'Ambre mineral', icon: 'i-lucide-shield', color: '#d8a030', isDark: true },
|
||||||
]
|
]
|
||||||
|
|
||||||
const currentMood: Ref<string> = ref('peps')
|
export function useLibreMood() {
|
||||||
|
return useMood(moods, { storageKey: 'libredecision_mood', defaultId: 'peps' })
|
||||||
function applyMood(moodId: string) {
|
|
||||||
if (import.meta.server) return
|
|
||||||
|
|
||||||
const mood = moods.find(m => m.id === moodId)
|
|
||||||
if (!mood) return
|
|
||||||
|
|
||||||
const html = document.documentElement
|
|
||||||
|
|
||||||
// Remove all existing mood classes
|
|
||||||
moods.forEach(m => html.classList.remove(`mood-${m.id}`))
|
|
||||||
|
|
||||||
// Add the new mood class
|
|
||||||
html.classList.add(`mood-${moodId}`)
|
|
||||||
|
|
||||||
// Sync color-mode (light/dark) via Nuxt's useColorMode
|
|
||||||
const colorMode = useColorMode()
|
|
||||||
colorMode.preference = mood.isDark ? 'dark' : 'light'
|
|
||||||
|
|
||||||
// Persist choice
|
|
||||||
localStorage.setItem(STORAGE_KEY, moodId)
|
|
||||||
|
|
||||||
currentMood.value = moodId
|
|
||||||
}
|
|
||||||
|
|
||||||
function setMood(moodId: string) {
|
|
||||||
applyMood(moodId)
|
|
||||||
}
|
|
||||||
|
|
||||||
function initMood() {
|
|
||||||
if (import.meta.server) return
|
|
||||||
|
|
||||||
const saved = localStorage.getItem(STORAGE_KEY)
|
|
||||||
const moodId = saved && moods.some(m => m.id === saved) ? saved : 'peps'
|
|
||||||
applyMood(moodId)
|
|
||||||
}
|
|
||||||
|
|
||||||
export function useMood() {
|
|
||||||
return {
|
|
||||||
currentMood: readonly(currentMood),
|
|
||||||
moods,
|
|
||||||
setMood,
|
|
||||||
initMood,
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
export default defineNuxtConfig({
|
export default defineNuxtConfig({
|
||||||
|
extends: ['@yvv/nuxt-base'],
|
||||||
compatibilityDate: '2025-07-15',
|
compatibilityDate: '2025-07-15',
|
||||||
ssr: false,
|
ssr: false,
|
||||||
devtools: { enabled: false },
|
devtools: { enabled: false },
|
||||||
|
|||||||
Generated
+5
@@ -16,6 +16,7 @@
|
|||||||
"@polkadot/util": "^13.5.9",
|
"@polkadot/util": "^13.5.9",
|
||||||
"@unocss/nuxt": "^66.6.0",
|
"@unocss/nuxt": "^66.6.0",
|
||||||
"@vueuse/nuxt": "^14.2.1",
|
"@vueuse/nuxt": "^14.2.1",
|
||||||
|
"@yvv/nuxt-base": "git+ssh://gitea@git.open.us.org/yvv/yvv-nuxt-base.git#v0.1.0",
|
||||||
"nuxt": "^4.3.1",
|
"nuxt": "^4.3.1",
|
||||||
"pinia": "^3.0.2",
|
"pinia": "^3.0.2",
|
||||||
"vue": "^3.5.28",
|
"vue": "^3.5.28",
|
||||||
@@ -9035,6 +9036,10 @@
|
|||||||
"license": "Apache-2.0",
|
"license": "Apache-2.0",
|
||||||
"peer": true
|
"peer": true
|
||||||
},
|
},
|
||||||
|
"node_modules/@yvv/nuxt-base": {
|
||||||
|
"version": "0.1.0",
|
||||||
|
"resolved": "git+ssh://gitea@git.open.us.org/yvv/yvv-nuxt-base.git#b1c6a2f28052564d505dd05b363169cb97fb81b3"
|
||||||
|
},
|
||||||
"node_modules/abbrev": {
|
"node_modules/abbrev": {
|
||||||
"version": "3.0.1",
|
"version": "3.0.1",
|
||||||
"resolved": "https://registry.npmjs.org/abbrev/-/abbrev-3.0.1.tgz",
|
"resolved": "https://registry.npmjs.org/abbrev/-/abbrev-3.0.1.tgz",
|
||||||
|
|||||||
@@ -18,6 +18,7 @@
|
|||||||
"@polkadot/util": "^13.5.9",
|
"@polkadot/util": "^13.5.9",
|
||||||
"@unocss/nuxt": "^66.6.0",
|
"@unocss/nuxt": "^66.6.0",
|
||||||
"@vueuse/nuxt": "^14.2.1",
|
"@vueuse/nuxt": "^14.2.1",
|
||||||
|
"@yvv/nuxt-base": "git+ssh://gitea@git.open.us.org/yvv/yvv-nuxt-base.git#v0.1.0",
|
||||||
"nuxt": "^4.3.1",
|
"nuxt": "^4.3.1",
|
||||||
"pinia": "^3.0.2",
|
"pinia": "^3.0.2",
|
||||||
"vue": "^3.5.28",
|
"vue": "^3.5.28",
|
||||||
|
|||||||
Reference in New Issue
Block a user