import type { Background, InkMode } from '~~/types' // Charte Figures Libres — valeurs mesurées dans gabarit_book_v3.pdf et // reprises du thème Grav figureslibres-v2 (scss/configuration/_variable.scss). export const FL_INK = '#0e1229' export const FL_BASE = '#f5f5f5' /** Couleurs de bandeau du gabarit PDF (aplats CMJN convertis). */ export const PDF_COLORS = [ '#ec008c', // magenta 100% — utilité publique '#8bd261', // vert C45 J71 — utilité sociale '#fff766', // jaune 60% — utilité culturelle (bandeau) '#fff200', // jaune 100% — utilité culturelle (filet) ] /** Couleurs du site Grav (hover des keywords de l'index). */ export const SITE_COLORS = [ '#ffaeab', // publique '#71ff94', // sociale '#feff74', // culturelle '#fabbde', // commanditaires '#82f8ee', // figures libres '#4bffc9', // projets ] /** Palette proposée pour les bandeaux de pages projet. */ export const BAND_COLORS = [...PDF_COLORS, ...SITE_COLORS] /** Couleur de bandeau par catégorie (page couverture de projet, gabarit). */ export const CATEGORY_BAND: Record = { publique: '#ec008c', sociale: '#8bd261', culturelle: '#fff766', } /** Couleur de filet par catégorie (pages grille — jaune à 100 %). */ export const CATEGORY_STRIP: Record = { publique: '#ec008c', sociale: '#8bd261', culturelle: '#fff200', } /** Classe CSS de la fonte de titre par catégorie (mixins du thème Grav). */ export const CATEGORY_TITLE_CLASS: Record = { publique: 'fl-font-publique', sociale: 'fl-font-sociale', culturelle: 'fl-font-culturelle', } /** Aplats clairs proposés pour le mode « teinté ». */ export const TINT_PRESETS = [ '#f5f5f5', // gris clair (base) '#efece3', // beige '#ffeceb', // rose pâle '#fbfbdc', // jaune pâle '#e9fbee', // vert pâle '#e2fff6', // menthe pâle ] /** Pleines couleurs de la charte pour le mode « couleur ». */ export const COLOR_PRESETS = [FL_INK, ...PDF_COLORS, ...SITE_COLORS] function luminance(hex: string): number { const m = hex.replace('#', '') if (m.length < 6) return 1 const [r, g, b] = [0, 2, 4].map(i => parseInt(m.slice(i, i + 2), 16) / 255) return 0.2126 * r + 0.7152 * g + 0.0722 * b } /** Encre lisible sur un fond donné — le gabarit imprime en noir/blanc purs. */ export function inkOn(color: string, ink: InkMode = 'auto'): string { if (ink === 'black') return '#000000' if (ink === 'white') return '#ffffff' return luminance(color) < 0.45 ? '#ffffff' : '#000000' } export function bandColorOf(category: string | undefined, override?: string): string { return override || CATEGORY_BAND[category ?? ''] || FL_INK } export function stripColorOf(category: string | undefined, override?: string): string { return override || CATEGORY_STRIP[category ?? ''] || FL_INK } export function backgroundColorOf(bg: Background): string { if (bg.mode === 'white') return '#ffffff' return bg.color || (bg.mode === 'tint' ? FL_BASE : FL_INK) } /** Style inline d'une page : fond + couleur d'encre lisible. */ export function backgroundStyle(bg: Background): Record { const color = backgroundColorOf(bg) return { backgroundColor: color, color: luminance(color) < 0.45 ? '#ffffff' : FL_INK, } }