Files
sejeteralo/frontend/app/components/DisplaySettings.vue
Yvv 4ba5e78e58 Add dark mode palettes + Woodpecker CI pipeline
- Add 2 dark palettes (Nuit, Ocean) to DisplaySettings with full SVG
  theme tokens — all hardcoded SVG colors (grids, legends, text fills,
  pills, dot strokes, drag handles) replaced with reactive bindings
- Update scoped CSS to use var(--color-*) and var(--svg-*) throughout
- Add Woodpecker CI pipeline (.woodpecker.yml): build → docker push → deploy
- Add multi-stage Dockerfiles for backend (Python) and frontend (Nuxt)
- Add production docker-compose with Traefik labels + dev override
- Remove old single-stage Dockerfiles and root docker-compose.yml
- Update Makefile with docker-dev target
- Exclude data files (pdf, xls, ipynb) from git

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-23 21:36:31 +01:00

365 lines
11 KiB
Vue

<template>
<div class="ds-selector" ref="selectorRef">
<button class="ds-trigger" aria-label="Reglages d'affichage" @click="isOpen = !isOpen">
<svg width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
<circle cx="12" cy="12" r="3"/><path d="M19.4 15a1.65 1.65 0 0 0 .33 1.82l.06.06a2 2 0 0 1-2.83 2.83l-.06-.06a1.65 1.65 0 0 0-1.82-.33 1.65 1.65 0 0 0-1 1.51V21a2 2 0 0 1-4 0v-.09A1.65 1.65 0 0 0 9 19.4a1.65 1.65 0 0 0-1.82.33l-.06.06a2 2 0 0 1-2.83-2.83l.06-.06A1.65 1.65 0 0 0 4.68 15a1.65 1.65 0 0 0-1.51-1H3a2 2 0 0 1 0-4h.09A1.65 1.65 0 0 0 4.6 9a1.65 1.65 0 0 0-.33-1.82l-.06-.06a2 2 0 0 1 2.83-2.83l.06.06A1.65 1.65 0 0 0 9 4.68a1.65 1.65 0 0 0 1-1.51V3a2 2 0 0 1 4 0v.09a1.65 1.65 0 0 0 1 1.51 1.65 1.65 0 0 0 1.82-.33l.06-.06a2 2 0 0 1 2.83 2.83l-.06.06A1.65 1.65 0 0 0 19.4 9a1.65 1.65 0 0 0 1.51 1H21a2 2 0 0 1 0 4h-.09a1.65 1.65 0 0 0-1.51 1z"/>
</svg>
</button>
<Transition name="ds-drop">
<div v-if="isOpen" class="ds-dropdown">
<h4 class="ds-title">Affichage</h4>
<!-- Font size -->
<div class="ds-section">
<span class="ds-label">Taille texte</span>
<div class="ds-toggle-group">
<button v-for="s in fontSizes" :key="s.value"
class="ds-toggle" :class="{ 'ds-toggle--active': currentFontSize === s.value }"
@click="setFontSize(s.value)">
{{ s.label }}
</button>
</div>
</div>
<!-- Chart density -->
<div class="ds-section">
<span class="ds-label">Densite graphiques</span>
<div class="ds-toggle-group">
<button v-for="d in densities" :key="d.value"
class="ds-toggle" :class="{ 'ds-toggle--active': currentDensity === d.value }"
@click="setDensity(d.value)">
{{ d.label }}
</button>
</div>
</div>
<!-- Palette -->
<div class="ds-section">
<span class="ds-label">Ambiance</span>
<div class="ds-palette-grid">
<button v-for="p in paletteList" :key="p.name"
class="ds-palette-btn" :class="{
'ds-palette-btn--active': currentPalette === p.name,
'ds-palette-btn--dark': p.dark,
}"
@click="setPalette(p.name)">
<span class="ds-palette-dots">
<span class="ds-dot" :style="{ background: p.primary }"></span>
<span class="ds-dot" :style="{ background: p.accent }"></span>
</span>
<span class="ds-palette-info">
<span class="ds-palette-name">{{ p.label }}</span>
<span class="ds-palette-mode">{{ p.dark ? 'Sombre' : 'Clair' }}</span>
</span>
</button>
</div>
</div>
</div>
</Transition>
</div>
</template>
<script setup lang="ts">
// Global shared dark mode state (accessible from any component via useState)
const isDark = useState('theme-dark', () => false)
const selectorRef = ref<HTMLElement>()
const isOpen = ref(false)
// ── Font size ──
const fontSizes = [
{ label: 'A-', value: 'small' },
{ label: 'A', value: 'normal' },
{ label: 'A+', value: 'large' },
]
const currentFontSize = ref('normal')
function setFontSize(size: string) {
currentFontSize.value = size
if (import.meta.client) {
localStorage.setItem('sej-fontSize', size)
const map: Record<string, string> = { small: '14px', normal: '16px', large: '18px' }
document.documentElement.style.fontSize = map[size] || '16px'
}
}
// ── Chart density ──
const densities = [
{ label: 'Compact', value: 'compact' },
{ label: 'Normal', value: 'normal' },
{ label: 'Large', value: 'large' },
]
const currentDensity = ref('normal')
function setDensity(d: string) {
currentDensity.value = d
if (import.meta.client) {
localStorage.setItem('sej-density', d)
const map: Record<string, string> = { compact: '0.85', normal: '1', large: '1.15' }
document.documentElement.style.setProperty('--chart-scale', map[d] || '1')
}
}
// ── Palette definitions ──
interface Palette {
name: string; label: string; dark: boolean
primary: string; accent: string
bg: string; surface: string; text: string; textMuted: string; border: string
// SVG-specific
svgPlotBg: string; svgGrid: string; svgLegendBg: string; svgText: string; svgTextLight: string
}
const paletteList: Palette[] = [
// ── Light palettes ──
{
name: 'eau', label: 'Eau', dark: false,
primary: '#2563eb', accent: '#059669',
bg: '#f8fafc', surface: '#ffffff', text: '#1e293b', textMuted: '#64748b', border: '#e2e8f0',
svgPlotBg: '#f8fafc', svgGrid: '#e2e8f0', svgLegendBg: 'white', svgText: '#334155', svgTextLight: '#64748b',
},
{
name: 'terre', label: 'Terre', dark: false,
primary: '#92400e', accent: '#d97706',
bg: '#fefbf6', surface: '#ffffff', text: '#1c1917', textMuted: '#78716c', border: '#e7e5e4',
svgPlotBg: '#faf8f5', svgGrid: '#e7e5e4', svgLegendBg: 'white', svgText: '#44403c', svgTextLight: '#78716c',
},
{
name: 'foret', label: 'Foret', dark: false,
primary: '#166534', accent: '#65a30d',
bg: '#f7fdf9', surface: '#ffffff', text: '#14532d', textMuted: '#6b7c6e', border: '#d1e7d6',
svgPlotBg: '#f5fbf7', svgGrid: '#d1e7d6', svgLegendBg: 'white', svgText: '#2d4a35', svgTextLight: '#6b7c6e',
},
{
name: 'ardoise', label: 'Ardoise', dark: false,
primary: '#475569', accent: '#64748b',
bg: '#f8fafc', surface: '#ffffff', text: '#1e293b', textMuted: '#64748b', border: '#e2e8f0',
svgPlotBg: '#f8fafc', svgGrid: '#e2e8f0', svgLegendBg: 'white', svgText: '#334155', svgTextLight: '#64748b',
},
// ── Dark palettes ──
{
name: 'nuit', label: 'Nuit', dark: true,
primary: '#60a5fa', accent: '#34d399',
bg: '#0f172a', surface: '#1e293b', text: '#f1f5f9', textMuted: '#94a3b8', border: '#334155',
svgPlotBg: '#1e293b', svgGrid: '#334155', svgLegendBg: '#1e293b', svgText: '#cbd5e1', svgTextLight: '#94a3b8',
},
{
name: 'ocean', label: 'Ocean', dark: true,
primary: '#38bdf8', accent: '#2dd4bf',
bg: '#0c1222', surface: '#162032', text: '#e2e8f0', textMuted: '#7dd3fc', border: '#1e3a5f',
svgPlotBg: '#162032', svgGrid: '#1e3a5f', svgLegendBg: '#162032', svgText: '#bae6fd', svgTextLight: '#7dd3fc',
},
]
const currentPalette = ref('eau')
function setPalette(name: string) {
currentPalette.value = name
const p = paletteList.find(x => x.name === name)
if (!p || !import.meta.client) return
localStorage.setItem('sej-palette', name)
const root = document.documentElement
const s = root.style
s.setProperty('--color-primary', p.primary)
s.setProperty('--color-primary-dark', darken(p.primary))
s.setProperty('--color-secondary', p.accent)
s.setProperty('--color-bg', p.bg)
s.setProperty('--color-surface', p.surface)
s.setProperty('--color-text', p.text)
s.setProperty('--color-text-muted', p.textMuted)
s.setProperty('--color-border', p.border)
// SVG theme vars
s.setProperty('--svg-plot-bg', p.svgPlotBg)
s.setProperty('--svg-grid', p.svgGrid)
s.setProperty('--svg-legend-bg', p.svgLegendBg)
s.setProperty('--svg-text', p.svgText)
s.setProperty('--svg-text-light', p.svgTextLight)
root.classList.toggle('palette-dark', p.dark)
isDark.value = p.dark
}
function darken(hex: string): string {
const r = parseInt(hex.slice(1, 3), 16)
const g = parseInt(hex.slice(3, 5), 16)
const b = parseInt(hex.slice(5, 7), 16)
const f = 0.82
return `#${Math.round(r * f).toString(16).padStart(2, '0')}${Math.round(g * f).toString(16).padStart(2, '0')}${Math.round(b * f).toString(16).padStart(2, '0')}`
}
// ── Init from localStorage ──
onMounted(() => {
if (!import.meta.client) return
const savedFont = localStorage.getItem('sej-fontSize')
if (savedFont) setFontSize(savedFont)
const savedDensity = localStorage.getItem('sej-density')
if (savedDensity) setDensity(savedDensity)
const savedPalette = localStorage.getItem('sej-palette')
if (savedPalette) setPalette(savedPalette)
})
// ── Click outside to close ──
function onClickOutside(e: MouseEvent) {
if (selectorRef.value && !selectorRef.value.contains(e.target as Node)) {
isOpen.value = false
}
}
onMounted(() => document.addEventListener('click', onClickOutside))
onUnmounted(() => document.removeEventListener('click', onClickOutside))
</script>
<style scoped>
.ds-selector { position: relative; }
.ds-trigger {
display: flex;
align-items: center;
justify-content: center;
width: 2rem;
height: 2rem;
border-radius: 6px;
color: var(--color-text-muted);
background: none;
border: none;
cursor: pointer;
transition: all 0.15s;
}
.ds-trigger:hover {
color: var(--color-text);
background: var(--color-bg);
}
.ds-dropdown {
position: absolute;
top: calc(100% + 0.5rem);
right: 0;
width: 260px;
padding: 0.75rem;
border-radius: 10px;
background: var(--color-surface);
border: 1px solid var(--color-border);
box-shadow: 0 8px 24px rgba(0,0,0,0.12), 0 2px 8px rgba(0,0,0,0.06);
display: flex;
flex-direction: column;
gap: 0.65rem;
z-index: 100;
}
.ds-title {
font-size: 0.68rem;
font-weight: 700;
text-transform: uppercase;
letter-spacing: 0.1em;
color: var(--color-text-muted);
margin: 0;
}
.ds-section {
display: flex;
flex-direction: column;
gap: 0.3rem;
}
.ds-label {
font-size: 0.68rem;
font-weight: 600;
color: var(--color-text-muted);
text-transform: uppercase;
letter-spacing: 0.04em;
}
.ds-toggle-group {
display: flex;
gap: 0.2rem;
background: var(--color-bg);
border-radius: 6px;
padding: 2px;
}
.ds-toggle {
flex: 1;
display: flex;
align-items: center;
justify-content: center;
padding: 0.3rem 0.4rem;
border-radius: 4px;
font-size: 0.72rem;
font-weight: 500;
color: var(--color-text-muted);
background: none;
border: none;
cursor: pointer;
transition: all 0.15s;
}
.ds-toggle:hover { color: var(--color-text); }
.ds-toggle--active {
background: var(--color-primary);
color: white;
box-shadow: 0 1px 3px rgba(37, 99, 235, 0.25);
}
.ds-palette-grid {
display: grid;
grid-template-columns: 1fr 1fr;
gap: 0.3rem;
}
.ds-palette-btn {
display: flex;
align-items: center;
gap: 0.35rem;
padding: 0.3rem 0.35rem;
border-radius: 6px;
background: var(--color-bg);
border: 1.5px solid transparent;
cursor: pointer;
transition: all 0.15s;
}
.ds-palette-btn:hover { border-color: var(--color-border); }
.ds-palette-btn--active {
border-color: var(--color-primary);
}
.ds-palette-btn--dark {
background: #1e293b;
}
.ds-palette-btn--dark .ds-palette-name { color: #e2e8f0; }
.ds-palette-btn--dark .ds-palette-mode { color: #94a3b8; }
.ds-palette-dots {
display: flex;
gap: 2px;
flex-shrink: 0;
}
.ds-dot {
width: 10px;
height: 10px;
border-radius: 50%;
box-shadow: 0 1px 2px rgba(0,0,0,0.15);
}
.ds-palette-info {
display: flex;
flex-direction: column;
min-width: 0;
}
.ds-palette-name {
font-size: 0.7rem;
font-weight: 600;
color: var(--color-text);
line-height: 1.2;
}
.ds-palette-mode {
font-size: 0.58rem;
color: var(--color-text-muted);
line-height: 1.2;
}
/* Transition */
.ds-drop-enter-active { transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1); }
.ds-drop-leave-active { transition: all 0.12s ease; }
.ds-drop-enter-from, .ds-drop-leave-to {
opacity: 0;
transform: translateY(-4px) scale(0.96);
}
</style>