ploxion-bd/app.blade.php

232 lines
15 KiB
PHP
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

{{-- PL0XI0N bd — « le site comme une BD » (RS-7). Un lecteur de bande dessinée
où l'on se BALADE de case en case : une planche pleine, on avance ‹ › / clic /
flèches / swipe, ou on prend du recul en mode PLANCHE (grille de toutes les
cases). v1 raconte la naissance d'un xion (ON+I=ION → bion → ploxion → xion).
100% client-side, art en CSS/emoji (zéro asset, deploy-safe), droit au silence.
window.jOSApps['bd']. mount(c, ctx) -> { unmount }. --}}
<style>
.bd { display:flex; flex-direction:column; height:100%; background:#0a0a0f;
color:#fff; font-family:'Bangers','Comic Sans MS',ui-sans-serif,system-ui,sans-serif; }
.bd__bar { flex:0 0 auto; display:flex; align-items:center; gap:10px; padding:7px 12px;
background:#111; border-bottom:3px solid #000; }
.bd__t { font-size:1.05rem; letter-spacing:.06em; color:#ffe14e; text-shadow:2px 2px 0 #000; }
.bd__sp { flex:1; }
.bd__btn { cursor:pointer; border:2px solid #000; background:#ffe14e; color:#000; font-weight:700;
border-radius:6px; padding:3px 11px; font-family:inherit; font-size:.78rem; box-shadow:2px 2px 0 #000; }
.bd__btn:hover { background:#fff; }
.bd__cnt { font-size:.8rem; color:rgba(255,255,255,.7); }
.bd__stage { flex:1; min-height:0; position:relative; overflow:hidden; background:#1a1a22; }
/* une CASE de BD : bord noir épais + halftone */
.bd__panel { position:absolute; inset:14px; border:5px solid #000; border-radius:4px; overflow:hidden;
box-shadow:8px 8px 0 rgba(0,0,0,.5); display:flex; align-items:center; justify-content:center;
transition:transform .32s cubic-bezier(.5,0,.2,1), opacity .25s; }
.bd__panel::after { content:''; position:absolute; inset:0; pointer-events:none; opacity:.16;
background-image:radial-gradient(rgba(0,0,0,.9) 1px, transparent 1.4px); background-size:7px 7px; }
.bd__scene { position:absolute; inset:0; display:flex; align-items:center; justify-content:center; }
.bd__glyph { font-family:ui-sans-serif,system-ui; font-size:clamp(3rem,22vmin,8rem); filter:drop-shadow(0 4px 12px rgba(0,0,0,.6)); }
/* zones de texte BD */
.bd__cap { position:absolute; left:12px; top:12px; max-width:75%; background:#fff6cf; color:#1a1208;
border:3px solid #000; border-radius:3px; padding:6px 11px; font-size:clamp(.8rem,2.6vw,1.1rem);
line-height:1.15; box-shadow:3px 3px 0 #000; z-index:3; transform:rotate(-1deg); }
.bd__bulle { position:absolute; background:#fff; color:#111; border:3px solid #000; border-radius:18px;
padding:7px 13px; font-size:clamp(.78rem,2.4vw,1rem); line-height:1.1; max-width:62%;
box-shadow:3px 3px 0 rgba(0,0,0,.4); z-index:3; }
.bd__bulle::after { content:''; position:absolute; width:0; height:0; border:11px solid transparent;
border-top-color:#000; bottom:-22px; left:26px; }
.bd__bulle b { color:#b0246a; }
/* flèches de navigation, zones cliquables */
.bd__nav { position:absolute; top:0; bottom:0; width:24%; z-index:4; cursor:pointer; background:none; border:0;
color:#fff; font-size:2rem; opacity:0; transition:opacity .15s; }
.bd__nav:hover { opacity:.85; }
.bd__nav--l { left:0; } .bd__nav--r { right:0; }
.bd__hint { position:absolute; bottom:8px; left:0; right:0; text-align:center; z-index:4;
font-family:ui-sans-serif,system-ui; font-size:.66rem; color:rgba(255,255,255,.4); pointer-events:none; }
/* mode PLANCHE : grille de toutes les cases */
.bd__planche { position:absolute; inset:0; overflow-y:auto; padding:14px; display:grid;
grid-template-columns:repeat(auto-fill,minmax(150px,1fr)); gap:12px; background:#1a1a22; }
.bd__mini { position:relative; aspect-ratio:4/3; border:4px solid #000; border-radius:3px; overflow:hidden;
cursor:pointer; box-shadow:5px 5px 0 rgba(0,0,0,.4); }
.bd__mini:hover { transform:translateY(-2px); }
.bd__mini .bd__glyph { font-size:2.6rem; }
.bd__mini .bd__cap { font-size:.6rem; padding:3px 6px; max-width:85%; }
.bd__mini-n { position:absolute; right:4px; bottom:3px; z-index:3; font-size:.7rem; color:#fff; text-shadow:1px 1px 0 #000; }
/* emblème/couverture reçu du bus (glyphes.glyph -> bd.cover) */
.bd__embl { display:inline-flex; width:22px; height:22px; align-items:center; justify-content:center; }
.bd__embl[hidden] { display:none; }
.bd__embl svg { width:100%; height:100%; display:block; }
.bd__pembl { position:absolute; right:10px; top:10px; width:46px; height:46px; z-index:3;
filter:drop-shadow(2px 2px 0 rgba(0,0,0,.6)); pointer-events:none; }
.bd__pembl svg { width:100%; height:100%; display:block; }
</style>
<script>
(function () {
function esc(s) { return window.jOSb.esc(s); }
// La planche : chaque case = un fond + une scène (glyphe) + une légende + des bulles.
var PANELS = [
{ bg:'radial-gradient(circle at 50% 45%,#3a2a5a,#0a0a14)', glyph:'🌀', cap:'Au commencement : le ON. Le chaos — rien, et tout à la fois.', bulles:[] },
{ bg:'linear-gradient(160deg,#102a3a,#05131c)', glyph:'👁', cap:"Puis le I. L'observateur. L'âme qui regarde.", bulles:[{t:'…et si je plongeais ?', x:'30%', y:'18%'}] },
{ bg:'radial-gradient(circle at 50% 50%,#ffd84e,#b0246a)', glyph:'⚡', cap:'ON + I = ION. Le réel NAÎT.', bulles:[{t:'<b>ION !</b>', x:'52%', y:'24%'}] },
{ bg:'linear-gradient(160deg,#0e2a1e,#04120c)', glyph:'🔷', cap:"Un bion s'éveille. Il se branche, se débranche — sans rien casser.", bulles:[{t:'je tourne tout seul.', x:'40%', y:'20%'}] },
{ bg:'linear-gradient(160deg,#1a1030,#0a0618)', glyph:'🧩', cap:'Mille bions assemblés = un PLOXION. La brique vivante.', bulles:[{t:'on est plus forts ensemble.', x:'28%', y:'16%'}] },
{ bg:'radial-gradient(circle at 50% 40%,#0aff9f33,#05080f 70%)', glyph:'🛸', cap:'Tous les ploxions ensemble = le XION. Et toi, tu t\'y balades.', bulles:[{t:'bienvenue dans le xerboxion. ∞', x:'24%', y:'66%'}] },
];
// PORTS DU BUS — construit un album lisible depuis un payload recits.pick :
// récit {t,a,y,idea,sci,x}, ou {title,pages|panels|text}. Retourne [] si rien d'utilisable.
var LOAD_BGS = ['linear-gradient(160deg,#102a3a,#05131c)', 'radial-gradient(circle at 50% 45%,#3a2a5a,#0a0a14)',
'linear-gradient(160deg,#0e2a1e,#04120c)', 'linear-gradient(160deg,#1a1030,#0a0618)'];
function toPanels(p, t) {
var pages = Array.isArray(p.pages) ? p.pages : (Array.isArray(p.panels) ? p.panels : null);
if (!pages && typeof p.text === 'string' && p.text.trim()) {
pages = p.text.split(/\n\s*\n|\n/).map(function (s) { return s.trim(); }).filter(Boolean);
}
if (!pages) {
pages = [];
if (typeof p.idea === 'string' && p.idea) pages.push({ glyph: '💡', text: p.idea });
if (typeof p.sci === 'string' && p.sci) pages.push({ glyph: '🔬', text: p.sci });
if (typeof p.x === 'string' && p.x) pages.push({ glyph: '✨', text: p.x });
}
var out = pages.slice(0, 60).map(function (pg, n) {
var o = (pg && typeof pg === 'object') ? pg : { text: pg };
var txt = o.cap || o.text || o.t;
if (typeof txt !== 'string' || !txt.trim()) return null;
return { bg: LOAD_BGS[n % LOAD_BGS.length],
glyph: (typeof o.glyph === 'string' && o.glyph.trim()) ? o.glyph.slice(0, 8) : '📜',
cap: esc(txt.slice(0, 400)), bulles: [] };
}).filter(Boolean);
if (t) {
var sub = [typeof p.a === 'string' ? p.a : '', (typeof p.y === 'string' || typeof p.y === 'number') ? String(p.y) : '']
.filter(Boolean).join(' · ');
out.unshift({ bg: 'radial-gradient(circle at 50% 50%,#ffd84e,#b0246a)', glyph: '📖',
cap: esc(t) + (sub ? ' — ' + esc(sub) : ''), bulles: [] });
}
return out;
}
function mount(container, ctx) {
var alive = true, i = 0, planche = false;
var album = PANELS, title = 'le xerboxion', cover = '', doneRead = false;
container.innerHTML =
'<div class="bd">'
+ ' <div class="bd__bar"><span class="bd__t">📖 BD · <span data-title>le xerboxion</span></span>'
+ ' <span class="bd__embl" data-cover hidden></span>'
+ ' <span class="bd__sp"></span><span class="bd__cnt"></span>'
+ ' <button class="bd__btn" data-mode>planche</button></div>'
+ ' <div class="bd__stage" data-stage></div>'
+ '</div>';
var stage = container.querySelector('[data-stage]');
var cnt = container.querySelector('.bd__cnt');
var modeBtn = container.querySelector('[data-mode]');
var titleEl = container.querySelector('[data-title]');
var coverEl = container.querySelector('[data-cover]');
function panelHTML(p, withNav) {
var bulles = (p.bulles||[]).map(function (b) {
return '<div class="bd__bulle" style="left:' + b.x + ';top:' + b.y + '">' + b.t + '</div>';
}).join('');
return '<div class="bd__scene" style="background:' + p.bg + '"></div>'
+ '<span class="bd__glyph">' + esc(p.glyph) + '</span>'
+ '<div class="bd__cap">' + p.cap + '</div>'
+ bulles
+ (cover ? '<div class="bd__pembl">' + cover + '</div>' : '')
+ (withNav
? '<button class="bd__nav bd__nav--l" data-prev aria-label="Précédent">‹</button>'
+ '<button class="bd__nav bd__nav--r" data-next aria-label="Suivant">›</button>'
+ '<div class="bd__hint">‹ › · flèches · clic · swipe — ou « planche » pour tout voir</div>'
: '');
}
function renderPanel() {
cnt.textContent = (i + 1) + ' / ' + album.length;
var el = document.createElement('div');
el.className = 'bd__panel';
el.innerHTML = panelHTML(album[i], true);
stage.innerHTML = '';
stage.appendChild(el);
el.querySelector('[data-prev]').addEventListener('click', function (e) { e.stopPropagation(); go(-1); });
el.querySelector('[data-next]').addEventListener('click', function (e) { e.stopPropagation(); go(1); });
// OUT bd.done -> xp.action : dernière planche atteinte = lecture finie (1x par album)
if (i === album.length - 1 && !doneRead) {
doneRead = true;
try { if (window.jOSPorts && window.jOSPorts.emit) window.jOSPorts.emit('bd', 'done', { title: title, panels: album.length }); } catch (e) {}
}
}
function renderPlanche() {
cnt.textContent = album.length + ' cases';
var html = '<div class="bd__planche">';
album.forEach(function (p, n) {
html += '<div class="bd__mini" data-goto="' + n + '">'
+ '<div class="bd__scene" style="background:' + p.bg + '"></div>'
+ '<span class="bd__glyph">' + esc(p.glyph) + '</span>'
+ '<div class="bd__cap">' + p.cap + '</div>'
+ '<span class="bd__mini-n">' + (n + 1) + '</span></div>';
});
html += '</div>';
stage.innerHTML = html;
stage.querySelectorAll('[data-goto]').forEach(function (m) {
m.addEventListener('click', function () { i = +m.getAttribute('data-goto'); planche = false; modeBtn.textContent = 'planche'; renderPanel(); });
});
}
function render() { planche ? renderPlanche() : renderPanel(); }
function go(d) { if (planche) return; i = (i + d + album.length) % album.length; renderPanel(); }
modeBtn.addEventListener('click', function () { planche = !planche; modeBtn.textContent = planche ? 'lire' : 'planche'; render(); });
var keyh = function (e) {
if (e.key === 'ArrowRight') { e.preventDefault(); go(1); }
else if (e.key === 'ArrowLeft') { e.preventDefault(); go(-1); }
else if (e.key.toLowerCase() === 'p') { modeBtn.click(); }
};
container.addEventListener('keydown', keyh);
container.setAttribute('tabindex', '0');
// swipe + clic sur les moitiés (le bd__nav couvre déjà les bords)
var sx = 0;
stage.addEventListener('pointerdown', function (e) { sx = e.clientX; });
stage.addEventListener('pointerup', function (e) { var dx = e.clientX - sx; if (Math.abs(dx) > 40) go(dx < 0 ? 1 : -1); });
// ---- PORTS D'ENTRÉE (bus jOSPorts) : bd.load <- recits.pick · bd.cover <- glyphes.glyph ----
var offs = [];
if (window.jOSPorts && window.jOSPorts.on) {
try {
// un récit choisi devient un album lisible en cases (bd et recits = lecteurs jumeaux)
offs.push(window.jOSPorts.on('ploxion.bd.load', function (p) {
if (!alive || !p || typeof p !== 'object') return;
try {
var t = [p.title, p.t, p.name].filter(function (s) { return typeof s === 'string' && s.trim(); })[0] || '';
var panels = toPanels(p, t);
if (!panels.length) return;
album = panels; i = 0; doneRead = false; planche = false;
if (t) { title = t; titleEl.textContent = title; }
modeBtn.textContent = 'planche';
render();
} catch (e) {}
}));
// un glyphe SVG généré sert de couverture/emblème à l'album affiché
offs.push(window.jOSPorts.on('ploxion.bd.cover', function (p) {
if (!alive || p == null) return;
try {
var svg = (typeof p === 'string') ? p : (typeof p.svg === 'string' ? p.svg : '');
svg = (svg || '').trim();
if (svg.slice(0, 4).toLowerCase() !== '<svg') return;
if (svg.length > 20000 || /<script|\son\w+\s*=|javascript:/i.test(svg)) return;
cover = svg;
coverEl.innerHTML = svg;
coverEl.hidden = false;
coverEl.title = (typeof p === 'object' && typeof p.name === 'string' && p.name) ? p.name : 'emblème (glyphes)';
if (!planche) renderPanel();
} catch (e) {}
}));
} catch (e) {}
}
render();
setTimeout(function () { try { container.focus(); } catch (e) {} }, 30);
return { unmount: function () { alive = false; offs.forEach(function (off) { try { off && off(); } catch (e) {} }); container.removeEventListener('keydown', keyh); container.innerHTML = ''; } };
}
window.jOSApps = window.jOSApps || {};
window.jOSApps['bd'] = { manifest: { id: 'bd', name: 'BD', icon: '📖' }, mount: mount };
})();
</script>