Files
decision/frontend/app/app.vue
Yvv 9b6388a600 Palettes harmoniques, logo g breve (Decision), Protocoles promu
- Moods: palettes multi-teintes (secondary, tertiary par mood)
  Peps: corail/ocre/bleu electrique ; Zen: sauge/lavande/terre cuite
  Chagrine: violet/cyan/magenta/or ; Grave: ambre/cuivre/bleu acier
- Logo: gavel + g(Decision) — incompletude de Godel
- Dashboard: 4 cartes d'entree (Documents, Decisions, Protocoles, Mandats)
  chacune avec sa couleur propre
- Protocoles promu au meme rang que les autres sections
  (boite a outils de vote + workflows n8n via MCP)

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-28 19:39:25 +01:00

544 lines
12 KiB
Vue

<script setup lang="ts">
const auth = useAuthStore()
const route = useRoute()
const { initMood } = useMood()
const navigationItems = [
{
label: 'Documents',
icon: 'i-lucide-book-open',
to: '/documents',
},
{
label: 'Decisions',
icon: 'i-lucide-scale',
to: '/decisions',
},
{
label: 'Mandats',
icon: 'i-lucide-user-check',
to: '/mandates',
},
{
label: 'Protocoles',
icon: 'i-lucide-settings',
to: '/protocols',
},
{
label: 'Sanctuaire',
icon: 'i-lucide-archive',
to: '/sanctuary',
},
]
/** Mobile drawer state. */
const mobileMenuOpen = ref(false)
/** Close mobile menu on route change. */
watch(() => route.path, () => {
mobileMenuOpen.value = false
})
/** WebSocket connection and notifications. */
const ws = useWebSocket()
const { setupWsNotifications } = useNotifications()
onMounted(async () => {
initMood()
auth.hydrateFromStorage()
if (auth.token) {
try {
await auth.fetchMe()
} catch {
auth.logout()
}
}
ws.connect()
setupWsNotifications(ws)
})
onUnmounted(() => {
ws.disconnect()
})
function isActive(to: string) {
return route.path === to || route.path.startsWith(to + '/')
}
</script>
<template>
<UApp>
<OfflineBanner />
<div
class="app-shell"
:style="{
backgroundColor: 'var(--mood-bg)',
color: 'var(--mood-text)',
}"
>
<!-- Header -->
<header class="app-header">
<div class="app-header__inner">
<!-- Left: Hamburger (mobile) + Logo -->
<div class="app-header__left">
<button
class="app-header__menu-btn md:hidden"
aria-label="Ouvrir le menu"
@click="mobileMenuOpen = true"
>
<UIcon name="i-lucide-menu" class="text-lg" />
</button>
<NuxtLink to="/" class="app-header__logo">
<UIcon name="i-lucide-gavel" class="app-header__logo-icon" />
<span class="app-header__logo-g">ğ</span><span class="app-header__logo-paren">(</span><span class="app-header__logo-word">Decision</span><span class="app-header__logo-paren">)</span>
</NuxtLink>
</div>
<!-- Center: Mood switcher -->
<MoodSwitcher class="hidden sm:flex" />
<!-- Right: Auth -->
<div class="app-header__right">
<template v-if="auth.isAuthenticated">
<span class="app-header__identity">
{{ auth.identity?.display_name || auth.identity?.address?.slice(0, 10) + '...' }}
</span>
<span
v-if="auth.identity?.is_smith"
class="app-header__role app-header__role--smith"
>
Forgeron
</span>
<span
v-if="auth.identity?.is_techcomm"
class="app-header__role app-header__role--tech"
>
CoTec
</span>
<button
class="app-header__icon-btn"
aria-label="Se deconnecter"
@click="auth.logout()"
>
<UIcon name="i-lucide-log-out" />
</button>
</template>
<template v-else>
<NuxtLink to="/login" class="app-header__connect-btn">
<UIcon name="i-lucide-log-in" class="text-sm" />
<span>Connexion</span>
</NuxtLink>
</template>
</div>
</div>
</header>
<!-- Mobile navigation drawer -->
<USlideover
v-model:open="mobileMenuOpen"
side="left"
title="Navigation"
:ui="{ width: 'max-w-xs' }"
>
<template #body>
<nav class="app-mobile-nav">
<NuxtLink
v-for="item in navigationItems"
:key="item.to"
:to="item.to"
class="app-mobile-nav__link"
:class="{ 'app-mobile-nav__link--active': isActive(item.to) }"
@click="mobileMenuOpen = false"
>
<UIcon :name="item.icon" class="text-base" />
<span>{{ item.label }}</span>
</NuxtLink>
</nav>
<div
v-if="auth.isAuthenticated"
class="app-mobile-nav__user"
>
<span>{{ auth.identity?.display_name || auth.identity?.address?.slice(0, 16) + '...' }}</span>
</div>
</template>
</USlideover>
<!-- Main content with sidebar -->
<div class="app-body">
<!-- Desktop sidebar -->
<aside class="app-sidebar">
<nav class="app-sidebar__nav">
<NuxtLink
v-for="item in navigationItems"
:key="item.to"
:to="item.to"
class="app-sidebar__link"
:class="{ 'app-sidebar__link--active': isActive(item.to) }"
>
<UIcon :name="item.icon" class="text-base" />
<span>{{ item.label }}</span>
</NuxtLink>
</nav>
</aside>
<!-- Page content -->
<main class="app-main">
<ErrorBoundary>
<NuxtPage />
</ErrorBoundary>
</main>
</div>
<!-- WebSocket error banner -->
<Transition name="slide-up">
<div
v-if="ws.error.value"
class="app-ws-banner"
role="alert"
>
<UIcon name="i-lucide-plug-zap" class="text-base" />
<span>{{ ws.error.value }}</span>
<button class="app-ws-banner__btn" @click="ws.disconnect(); ws.connect()">
Reconnecter
</button>
</div>
</Transition>
<!-- Footer -->
<footer class="app-footer">
<span>ğ(Decision) v0.1.0</span>
<span class="app-footer__sep">·</span>
<span>Licence libre</span>
</footer>
</div>
</UApp>
</template>
<style scoped>
/* === Shell === */
.app-shell {
display: flex;
flex-direction: column;
min-height: 100vh;
}
/* === Header === */
.app-header {
position: sticky;
top: 0;
z-index: 30;
background: var(--mood-surface);
border-bottom: 1px solid var(--mood-border);
}
.app-header__inner {
max-width: 80rem;
margin: 0 auto;
padding: 0 1rem;
display: flex;
align-items: center;
justify-content: space-between;
height: 3.25rem;
}
.app-header__left {
display: flex;
align-items: center;
gap: 0.75rem;
}
.app-header__menu-btn {
display: flex;
align-items: center;
justify-content: center;
width: 2rem;
height: 2rem;
border: none;
background: none;
color: var(--mood-text-muted);
cursor: pointer;
border-radius: 4px;
}
.app-header__menu-btn:hover {
color: var(--mood-text);
background: var(--mood-accent-soft);
}
.app-header__logo {
text-decoration: none;
display: flex;
align-items: center;
gap: 0.375rem;
}
.app-header__logo-icon {
font-size: 1.125rem;
color: var(--mood-accent);
}
.app-header__logo-g {
font-size: 1.25rem;
font-weight: 800;
color: var(--mood-accent);
line-height: 1;
font-style: italic;
}
.app-header__logo-paren {
font-size: 0.9375rem;
font-weight: 300;
color: var(--mood-text-muted);
letter-spacing: -0.02em;
}
.app-header__logo-word {
font-size: 0.9375rem;
font-weight: 600;
color: var(--mood-text);
letter-spacing: -0.01em;
}
.app-header__right {
display: flex;
align-items: center;
gap: 0.5rem;
}
.app-header__identity {
font-size: 0.75rem;
font-weight: 500;
color: var(--mood-text);
max-width: 10rem;
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
}
.app-header__role {
font-size: 0.625rem;
font-weight: 600;
text-transform: uppercase;
letter-spacing: 0.04em;
padding: 2px 6px;
border-radius: 3px;
}
.app-header__role--smith {
background: rgba(24, 132, 59, 0.12);
color: var(--mood-success);
}
.app-header__role--tech {
background: rgba(24, 86, 168, 0.12);
color: var(--mood-status-vote, #1856a8);
}
.app-header__icon-btn {
display: flex;
align-items: center;
justify-content: center;
width: 1.75rem;
height: 1.75rem;
border: none;
background: none;
color: var(--mood-text-muted);
cursor: pointer;
border-radius: 4px;
font-size: 0.875rem;
}
.app-header__icon-btn:hover {
color: var(--mood-text);
background: var(--mood-accent-soft);
}
.app-header__connect-btn {
display: inline-flex;
align-items: center;
gap: 0.375rem;
padding: 0.375rem 0.875rem;
font-size: 0.75rem;
font-weight: 600;
color: var(--mood-accent-text);
background: var(--mood-accent);
border: none;
border-radius: 4px;
text-decoration: none;
cursor: pointer;
transition: opacity 0.15s ease;
letter-spacing: 0.01em;
}
.app-header__connect-btn:hover {
opacity: 0.88;
}
/* === Sidebar === */
.app-body {
display: flex;
flex: 1;
}
.app-sidebar {
width: 13rem;
flex-shrink: 0;
border-right: 1px solid var(--mood-border);
background: var(--mood-surface);
display: none;
}
@media (min-width: 768px) {
.app-sidebar {
display: block;
}
}
.app-sidebar__nav {
position: sticky;
top: 3.25rem;
padding: 0.75rem 0.5rem;
display: flex;
flex-direction: column;
gap: 2px;
}
.app-sidebar__link {
display: flex;
align-items: center;
gap: 0.5rem;
padding: 0.5rem 0.75rem;
font-size: 0.8125rem;
font-weight: 500;
color: var(--mood-text-muted);
text-decoration: none;
border-radius: 4px;
transition: all 0.12s ease;
}
.app-sidebar__link:hover {
color: var(--mood-text);
background: var(--mood-accent-soft);
}
.app-sidebar__link--active {
color: var(--mood-accent);
background: var(--mood-accent-soft);
font-weight: 600;
}
/* === Mobile nav === */
.app-mobile-nav {
display: flex;
flex-direction: column;
gap: 2px;
padding: 0.5rem;
}
.app-mobile-nav__link {
display: flex;
align-items: center;
gap: 0.625rem;
padding: 0.625rem 0.75rem;
font-size: 0.875rem;
font-weight: 500;
color: var(--mood-text-muted);
text-decoration: none;
border-radius: 4px;
}
.app-mobile-nav__link:hover {
background: var(--mood-accent-soft);
color: var(--mood-text);
}
.app-mobile-nav__link--active {
color: var(--mood-accent);
background: var(--mood-accent-soft);
font-weight: 600;
}
.app-mobile-nav__user {
margin-top: 1rem;
padding: 0.75rem;
border-top: 1px solid var(--mood-border);
font-size: 0.75rem;
color: var(--mood-text-muted);
}
/* === Main === */
.app-main {
flex: 1;
min-width: 0;
padding: 1.5rem 1rem;
}
@media (min-width: 640px) {
.app-main {
padding: 1.5rem 1.5rem;
}
}
@media (min-width: 1024px) {
.app-main {
padding: 2rem 2rem;
}
}
/* === WS Banner === */
.app-ws-banner {
position: fixed;
bottom: 0;
left: 0;
right: 0;
z-index: 40;
display: flex;
align-items: center;
justify-content: center;
gap: 0.5rem;
padding: 0.5rem 1rem;
background: var(--mood-error);
color: white;
font-size: 0.75rem;
font-weight: 500;
}
.app-ws-banner__btn {
margin-left: 0.5rem;
padding: 0.25rem 0.5rem;
background: rgba(255,255,255,0.2);
border: none;
border-radius: 3px;
color: white;
font-size: 0.6875rem;
font-weight: 600;
cursor: pointer;
}
.app-ws-banner__btn:hover {
background: rgba(255,255,255,0.3);
}
/* === Footer === */
.app-footer {
display: flex;
align-items: center;
justify-content: center;
gap: 0.5rem;
padding: 0.75rem 1rem;
font-size: 0.6875rem;
color: var(--mood-text-muted);
border-top: 1px solid var(--mood-border);
}
.app-footer__sep {
opacity: 0.4;
}
/* === Transitions === */
.slide-up-enter-active,
.slide-up-leave-active {
transition: all 0.3s ease;
}
.slide-up-enter-from,
.slide-up-leave-to {
transform: translateY(100%);
opacity: 0;
}
</style>