Repository Public
1// Gabarit statique de la page : tout le contenu existe dans le HTML servi (sans JavaScript, la rotonde est2// un groupe de six liens posés sur le cercle). Appelé par le greffon Vite (vite.config.ts).3import { APPS, PLAN, N, angleDe, type KaApp } from "./apps.ts";45const rad = (d: number) => (d * Math.PI) / 180;6const f = (n: number) => (Math.round(n * 100) / 100).toString();7const pol = (r: number, a: number): [number, number] => [r * Math.cos(rad(a)), r * Math.sin(rad(a))];8const esc = (s: string) => s.replace(/&/g, "&").replace(/</g, "<").replace(/"/g, """);910/**11 * Les symboles des six marques, tels que publiés dans leur système de marque (grille 64 × 64), sans retouche.12 * Seules les couleurs passent par des variables (--e : encre de la marque, --c : sa couleur) pour suivre le thème,13 * et les pièces mobiles portent data-p pour le geste signature.14 */15const SYMBOLES: Record<KaApp["id"], string> = {16 louka:17 `<path d="M15 60V9a3 3 0 0 1 3-3h28a3 3 0 0 1 3 3v51" fill="none" stroke="var(--c)" stroke-width="5" stroke-linejoin="round"/>` +18 `<path data-p="battant" d="M17.5 8.5 42 13v41.5L17.5 60Z" fill="var(--e)"/>` +19 `<circle data-p="poignee" cx="37.6" cy="34.5" r="1.9" fill="var(--c)"/>` +20 `<path d="M8 60h48" stroke="var(--e)" stroke-width="3" stroke-linecap="round" fill="none"/>`,21 immoka:22 `<path fill-rule="evenodd" fill="var(--e)" d="M32 6.5 41.5 15.3V9.5H47v10.9l2.7 2.5c3 2.8 6 4.3 10.1 5a1.8 1.8 0 0 1-.3 3.6H53V58H11V31.5H4.5a1.8 1.8 0 0 1-.3-3.6c4.1-.7 7.1-2.2 10.1-5ZM23 58V29.5a1.5 1.5 0 0 1 1.5-1.5h15a1.5 1.5 0 0 1 1.5 1.5V58Z"/>` +23 `<path data-p="battant" fill-rule="evenodd" fill="var(--c)" d="M23 28 36.5 31.3v23.9L23 58ZM34.7 44.2a1.5 1.5 0 1 1-3 0a1.5 1.5 0 1 1 3 0Z"/>` +24 `<path d="M4 59.5h56" stroke="var(--e)" stroke-width="3" stroke-linecap="round" fill="none"/>`,25 vraiprix:26 `<path d="M26.5 56H11V27L32 8 53 27V56H37.5" fill="none" stroke="var(--e)" stroke-width="5.5" stroke-linejoin="miter" stroke-miterlimit="8"/>` +27 `<g data-p="pendule"><path d="M32 11.5V30" fill="none" stroke="var(--e)" stroke-width="1.75"/>` +28 `<path d="M29.75 29h4.5v4L39 39.5 32 58.75 25 39.5 29.75 33Z" fill="var(--c)"/></g>`,29 autoka:30 `<g data-p="portiere"><path fill-rule="evenodd" fill="var(--c)" d="M14.5 51.5A2.5 2.5 0 0 1 12 49L12 28.71A2 2 0 0 1 12.25 27.75L22.89 8.3A2.5 2.5 0 0 1 25.08 7L50 7A3 3 0 0 1 53 10L53 49A2.5 2.5 0 0 1 50.5 51.5ZM22.4 26.75A1.2 1.2 0 0 1 21.35 24.98L27.56 13.38A1.2 1.2 0 0 1 28.62 12.75L46.5 12.75A1.5 1.5 0 0 1 48 14.25L48 25.55A1.2 1.2 0 0 1 46.8 26.75ZM40 31.5H46.5A1.5 1.5 0 0 1 46.5 34.5H40A1.5 1.5 0 0 1 40 31.5Z"/></g>` +31 `<path d="M6 56H58" fill="none" stroke="var(--e)" stroke-width="3.5" stroke-linecap="round"/>`,32 foodka:33 `<path fill="var(--e)" d="M9 17A8.5 8.5 0 1 1 26 17A8.5 8.5 0 1 1 9 17ZM31.5 28V7A2.5 2.5 0 0 1 34 4.5H44A2.5 2.5 0 0 1 46.5 7V28Z"/>` +34 `<path d="M5.5 28H58.5" fill="none" stroke="var(--e)" stroke-width="5" stroke-linecap="round"/>` +35 `<path data-p="etiquette" fill-rule="evenodd" fill="var(--c)" d="M23.5 34H54.5A3.5 3.5 0 0 1 58 37.5V54.5A3.5 3.5 0 0 1 54.5 58H23.5A3.5 3.5 0 0 1 20 54.5V37.5A3.5 3.5 0 0 1 23.5 34ZM36.5 39.5H51A2 2 0 0 1 53 41.5V45A2 2 0 0 1 51 47H36.5A2 2 0 0 1 34.5 45V41.5A2 2 0 0 1 36.5 39.5ZM43.75 50H51.25A1.75 1.75 0 0 1 53 51.75V51.75A1.75 1.75 0 0 1 51.25 53.5H43.75A1.75 1.75 0 0 1 42 51.75V51.75A1.75 1.75 0 0 1 43.75 50Z"/>`,36 fabrika:37 `<rect x="4" y="3" width="6.5" height="34" rx="3.25" fill="var(--e)"/>` +38 `<path d="M7.25 10H57.5" fill="none" stroke="var(--e)" stroke-width="5.5" stroke-linecap="round"/>` +39 `<path d="M7.5 30L21 12" fill="none" stroke="var(--e)" stroke-width="3.5" stroke-linecap="round"/>` +40 `<g data-p="plaque"><path d="M29 12V21M51 12V21" fill="none" stroke="var(--e)" stroke-width="3.5" stroke-linecap="round"/>` +41 `<rect x="20" y="20" width="40" height="40" rx="4" fill="var(--c)"/></g>`,42};4344export const symbole = (a: KaApp, cls = "sym") =>45 `<svg class="${cls}" viewBox="0 0 64 64" aria-hidden="true" focusable="false">${SYMBOLES[a.id]}</svg>`;4647const nom = (a: KaApp) =>48 `<span class="mot"><span>${a.nom[0]}</span><span class="tu">-</span><span class="ka">${a.nom[1]}</span></span>`;4950/** Symbole du Groupe Ka : la rotonde en plan, six baies, la porte du haut ouverte. */51export function symboleGroupe(cls = "gk-sym"): string {52 const R = 23;53 let s = "";54 // la baie du haut est plus large : c'est la porte ouverte55 const demi = (i: number) => (mod6(i) === 0 ? 14 : 7);56 for (let i = 0; i < N; i++) {57 const [x0, y0] = pol(R, angleDe(i) + demi(i)), [x1, y1] = pol(R, angleDe(i + 1) - demi(i + 1));58 s += `<path d="M${f(32 + x0)} ${f(32 + y0)}A${R} ${R} 0 0 1 ${f(32 + x1)} ${f(32 + y1)}"/>`;59 }60 const [hx, hy] = pol(R, -90 - 14), [fx] = pol(R, -90 + 14);61 s += `<path d="M${f(32 + hx)} ${f(32 + hy - 2)}v${f(fx - hx + 2)}" stroke-width="4" stroke-linecap="round"/>`;62 return `<svg class="${cls}" viewBox="0 0 64 64" fill="none" stroke="currentColor" stroke-width="6.5" aria-hidden="true" focusable="false">${s}</svg>`;63}64const mod6 = (i: number) => ((i % N) + N) % N;6566/** Le plan : mur en six segments, six battants (fermés) et leurs arcs de débattement, six filets de couleur. */67export function plan(): string {68 const { R, mur, baie, filet } = PLAN;69 let murs = "", portes = "";70 for (let i = 0; i < N; i++) {71 const [x0, y0] = pol(R, angleDe(i) + baie), [x1, y1] = pol(R, angleDe(i + 1) - baie);72 murs += `<path d="M${f(x0)} ${f(y0)}A${R} ${R} 0 0 1 ${f(x1)} ${f(y1)}"/>`;73 }74 APPS.forEach((a, i) => {75 const t = angleDe(i);76 const [hx, hy] = pol(R, t - baie), [fx, fy] = pol(R, t + baie);77 const c = Math.hypot(fx - hx, fy - hy);78 // extrémité du battant ouvert à 90° : la corde tournée d'un quart de tour vers l'intérieur79 const qx = hx - (fy - hy), qy = hy + (fx - hx);80 const [sx, sy] = pol(filet, t);81 const [ox, oy] = pol(filet, t + 180);82 portes +=83 `<g class="baie a-${a.id}" data-i="${i}">` +84 `<path class="filet" pathLength="1" d="M${f(sx)} ${f(sy)}A${filet} ${filet} 0 0 1 ${f(ox)} ${f(oy)}"/>` +85 `<path class="filet" pathLength="1" d="M${f(sx)} ${f(sy)}A${filet} ${filet} 0 0 0 ${f(ox)} ${f(oy)}"/>` +86 `<path class="arc" d="M${f(fx)} ${f(fy)}A${f(c)} ${f(c)} 0 0 1 ${f(qx)} ${f(qy)}"/>` +87 `<path class="battant" data-h="${f(hx)} ${f(hy)}" d="M${f(hx)} ${f(hy)}L${f(fx)} ${f(fy)}"/>` +88 `<circle class="gond" cx="${f(hx)}" cy="${f(hy)}" r="${f(mur / 2 + 1.5)}"/>` +89 `</g>`;90 });91 return (92 `<svg class="murs" viewBox="-500 -500 1000 1000" aria-hidden="true" focusable="false">` +93 `<g id="rotonde"><g class="mur" fill="none" stroke-width="${mur}">${murs}</g>${portes}</g></svg>`94 );95}9697/** Les six liens du cercle. --cx / --cy : position sur le cercle, lue par la feuille de style avant le moteur. */98export function portes(): string {99 return APPS.map((a, i) => {100 const t = rad(angleDe(i));101 return (102 `<li><a class="porte a-${a.id}" id="porte-${a.id}" href="${a.url}" data-i="${i}" data-app="${a.id}" ` +103 `style="--cx:${f(Math.cos(t))};--cy:${f(Math.sin(t))}">` +104 `<span class="porte-sym">${symbole(a)}</span>` +105 `<span class="porte-nom">${nom(a)}<span class="vh">, ${esc(a.genre.toLowerCase())}</span></span></a></li>`106 );107 }).join("");108}109110const liens = (a: KaApp) =>111 a.liens.length112 ? `<p class="liens">${a.liens.map((l) => `<a href="${esc(l.url)}">${esc(l.libelle)}</a>`).join("")}</p>`113 : "";114115/** Les volets du centre : un par site, plus celui du Groupe Ka au repos. */116export function volets(): string {117 const groupe =118 `<div class="volet volet-groupe actif" data-volet="groupe">` +119 `<div class="tete"><h1>Six adresses, six portes</h1></div>` +120 `<div class="corps"><p class="phrase">Se loger, acheter, évaluer, rouler, manger, magasiner : six sites québécois, chacun derrière sa porte.</p>` +121 `<p class="indice"><span class="si-js">Choisissez une porte.</span><span class="si-clavier"> Les flèches ← → font tourner la rotonde.</span></p></div>` +122 `</div>`;123 const apps = APPS.map(124 (a) =>125 `<div class="volet a-${a.id}" data-volet="${a.id}">` +126 `<div class="tete"><p class="titre">${nom(a)}</p><p class="genre">${esc(a.genre)}</p></div>` +127 `<div class="corps"><p class="phrase">${esc(a.phrase)}</p>` +128 `<p class="chiffre num"><!--chiffre:${a.id}--></p>` +129 `<p><a class="entrer" href="${a.url}"><span>Entrer dans ${a.domaine}</span>${FLECHE}</a></p>${liens(a)}</div>` +130 `</div>`,131 ).join("");132 return groupe + apps;133}134135const FLECHE = `<svg class="fleche" viewBox="0 0 16 16" aria-hidden="true" focusable="false"><path d="M3 8h9.5M8.5 3.5 13 8l-4.5 4.5" fill="none" stroke="currentColor" stroke-width="1.6" stroke-linecap="round" stroke-linejoin="round"/></svg>`;136137/** Sous le cercle : une courte section par site, lisible et utilisable sans JavaScript. */138export function adresses(): string {139 return APPS.map(140 (a) =>141 `<li class="adresse a-${a.id}" id="adresse-${a.slug}">` +142 `<span class="adresse-sym">${symbole(a)}</span>` +143 `<div class="adresse-tete"><h3>${nom(a)}</h3><p class="genre">${esc(a.genre)}</p></div>` +144 `<p class="adresse-texte">${esc(a.phrase)} <span class="chiffre num"><!--chiffre:${a.id}--></span></p>` +145 `<p class="adresse-lien"><a href="${a.url}"><span>${a.domaine}</span>${FLECHE}</a>${liens(a)}</p>` +146 `</li>`,147 ).join("");148}149150export function remplir(html: string): string {151 return html152 .replace("<!--PLAN-->", plan())153 .replace("<!--PORTES-->", portes())154 .replace("<!--VOLETS-->", volets())155 .replace("<!--ADRESSES-->", adresses())156 .replaceAll("<!--GK-->", symboleGroupe());157}158