Web: dopracowanie animacji ekosystemu — promienie rdzenia z wariantem fade (Reveal fade, bez drygu CSS), klasy is-live/ray-flow w Ecosystem, porzadki w BootLog/Concepts/Tracks + style (cvx); web 8 testow

This commit is contained in:
tisachi
2026-10-29 02:40:38 +01:00
parent 51e60b23a4
commit f0b24b4631
6 changed files with 91 additions and 49 deletions

View File

@@ -16,22 +16,24 @@ function prefersReducedMotion() {
);
}
/** Boot log z efektem typewritera; w prefers-reduced-motion renderuje się od razu. */
/**
* Boot log z efektem typewritera. Pisania NIE wyłączamy w prefers-reduced-motion:
* to pojawianie się tekstu, nie ruch — przyspieszamy tylko tempo.
*/
export function BootLog() {
const { t, i18n } = useTranslation('boot');
const LINES = useMemo(
() => t('lines', { returnObjects: true }) as unknown as BootLine[],
[t, i18n.language],
);
const done = prefersReducedMotion();
const [visible, setVisible] = useState<{ line: number; char: number }>(
done ? { line: LINES.length, char: 0 } : { line: 0, char: 0 },
);
const [visible, setVisible] = useState<{ line: number; char: number }>({ line: 0, char: 0 });
useEffect(() => {
if (done) return;
let cancelled = false;
let timer: ReturnType<typeof setTimeout>;
const rm = prefersReducedMotion();
const charMs = rm ? CHAR_MS / 2 : CHAR_MS;
const lineMs = rm ? LINE_MS / 2 : LINE_MS;
const tick = (line: number, char: number) => {
if (cancelled) return;
@@ -39,9 +41,9 @@ export function BootLog() {
if (line >= LINES.length) return;
const text = LINES[line].text;
if (char < text.length) {
timer = setTimeout(() => tick(line, char + 1), CHAR_MS);
timer = setTimeout(() => tick(line, char + 1), charMs);
} else {
timer = setTimeout(() => tick(line + 1, 0), LINE_MS);
timer = setTimeout(() => tick(line + 1, 0), lineMs);
}
};
@@ -50,7 +52,7 @@ export function BootLog() {
cancelled = true;
clearTimeout(timer);
};
}, [done, LINES]);
}, [LINES]);
return (
<pre
@@ -65,7 +67,7 @@ export function BootLog() {
<span key={i} className="block whitespace-pre-wrap">
<span>{shown}</span>
{l.ok && finished && <span className="font-semibold text-accent">OK</span>}
{i === visible.line && !done && <span className="boot-caret" />}
{i === visible.line && visible.line < LINES.length && <span className="boot-caret" />}
</span>
);
})}

View File

@@ -6,10 +6,12 @@ interface RevealProps {
className?: string;
delayMs?: number;
id?: string;
/** Fade bez przesunięcia — dla układów mierzonych w DOM (promienie rdzenia). */
fade?: boolean;
}
/** Wejście sekcji na scroll — IntersectionObserver; reduced-motion ogarnia CSS (.reveal). */
export function Reveal({ children, className, delayMs = 0, id }: RevealProps) {
export function Reveal({ children, className, delayMs = 0, id, fade = false }: RevealProps) {
const ref = useRef<HTMLDivElement>(null);
const [visible, setVisible] = useState(false);
@@ -41,7 +43,7 @@ export function Reveal({ children, className, delayMs = 0, id }: RevealProps) {
<div
id={id}
ref={ref}
className={cn('reveal', visible && 'revealed', className)}
className={cn('reveal', fade && 'reveal-fade', visible && 'revealed', className)}
style={delayMs ? ({ '--reveal-delay': `${delayMs}ms` } as CSSProperties) : undefined}
>
{children}

View File

@@ -45,9 +45,6 @@ function ChartBackdrop() {
const len2 = line2.getTotalLength();
line2.style.strokeDasharray = String(len2);
const reduce =
typeof window.matchMedia === 'function' &&
window.matchMedia('(prefers-reduced-motion: reduce)').matches;
// na dotyku wypelnienia ida przez clip (CSS), bez maski feather —
// przesuwanie stopów gradientu co klatkę wymusza re-rasteryzacje maski
const feather =
@@ -92,13 +89,9 @@ function ChartBackdrop() {
if (!inView) return;
const r = wrap.getBoundingClientRect();
const vh = window.innerHeight;
// p=0 gdy nagłówek mija środek widoku, p=1 przy końcu sekcji
const p = reduce ? 1 : Math.min(Math.max((vh * 0.4 - r.top) / (r.height * 0.85), 0), 1);
if (reduce) {
shown = p;
paint();
return;
}
// p=0 gdy gora sekcji wchodzi dolna krawedzia widoku (start od lewej),
// p=1 gdy sekcja przesyla polowe widoku powyzej (koniec przy wyjsciu)
const p = Math.min(Math.max((vh - r.top) / (r.height + vh * 0.5), 0), 1);
target = p;
if (!frame) frame = requestAnimationFrame(run);
};
@@ -453,6 +446,8 @@ const CONCEPTS: Concept[] = [
export function Concepts() {
const { t } = useTranslation('concepts');
return (
// BEZ cvx: content-visibility => paint containment => przycina wylew
// na pełną szerokość okna (w-dvw) wykres tła do boków sekcji
<Section id="slownik">
<div className="relative">
<ChartBackdrop />

View File

@@ -50,7 +50,16 @@ interface WireTarget {
side: 'left' | 'right' | 'top' | 'bottom';
}
function basePoint(r: DOMRect, cr: DOMRect, side: WireTarget['side']) {
interface Box {
left: number;
top: number;
right: number;
bottom: number;
width: number;
height: number;
}
function basePoint(r: Box, cr: Box, side: WireTarget['side']) {
switch (side) {
case 'left':
return { x: r.right - cr.left, y: r.top + r.height / 2 - cr.top };
@@ -63,6 +72,25 @@ function basePoint(r: DOMRect, cr: DOMRect, side: WireTarget['side']) {
}
}
/**
* Suma transformów `.reveal` nad elementem (kafelki wjeżdżają z opóźnieniami).
* Promienie muszą liczyć się z pozycji docelowej: `getBoundingClientRect` oddaje
* transform w locie, więc ResizeObserver wywołany zmianą wysokości okna (pasek
* adresu na mobile) ustawiał podstawy trójkątów w połowie drogi do kafelka.
*/
function revealShift(el: HTMLElement): number {
let sum = 0;
let node: HTMLElement | null = el;
while (node) {
if (node.classList.contains('reveal')) {
const m = /matrix\(([^)]+)\)/.exec(getComputedStyle(node).transform);
if (m) sum += Number.parseFloat(m[1].split(',')[5]) || 0;
}
node = node.parentElement;
}
return sum;
}
/**
* Promienie—trójkąty mierzone w DOM: wierzchołek na obwodzie rdzenia,
* podstawy na ścianach kafelków. Współrzędne w % kontenera (viewBox 0–100).
@@ -75,24 +103,37 @@ function measureWires(
) {
const cr = container.getBoundingClientRect();
if (!cr.width || !cr.height) return { wires: [] as Wire[], hub: { x: 50, y: 50 } };
const hr = hubEl.getBoundingClientRect();
const hostShift = revealShift(container);
const box = (el: HTMLElement): Box => {
const r = el.getBoundingClientRect();
const off = revealShift(el) - hostShift;
return {
left: r.left,
top: r.top - off,
right: r.right,
bottom: r.bottom - off,
width: r.width,
height: r.height,
};
};
const hr = box(hubEl);
const cx = hr.left + hr.width / 2 - cr.left;
const cy = hr.top + hr.height / 2 - cr.top;
const wires: Wire[] = [];
for (const t of targets) {
if (!t.el) continue;
const r = t.el.getBoundingClientRect();
const r = box(t.el);
const midX = r.left + r.width / 2 - cr.left;
const midY = r.top + r.height / 2 - cr.top;
const dx = midX - cx;
const dy = midY - cy;
const len = Math.hypot(dx, dy) || 1;
const base = basePoint(r, cr, t.side);
const foot = basePoint(r, cr, t.side);
wires.push({
x1: ((cx + (dx / len) * hubRadius) / cr.width) * 100,
y1: ((cy + (dy / len) * hubRadius) / cr.height) * 100,
x2: (base.x / cr.width) * 100,
y2: (base.y / cr.height) * 100,
x2: (foot.x / cr.width) * 100,
y2: (foot.y / cr.height) * 100,
// połowa podstawy trójkąta jako % wymiaru kontenera w osi rozrzutu
spread:
(t.side === 'left' || t.side === 'right' ? SPREAD_PX / cr.height : SPREAD_PX / cr.width) *
@@ -355,18 +396,18 @@ function StackDiagram() {
</svg>
<div className="grid grid-cols-1 gap-4 sm:grid-cols-2 sm:gap-x-10">
<Reveal className="h-full">
<Reveal fade className="h-full">
<div ref={cwiczacyRef} className="h-full">
<ParticipantCard participant={PARTICIPANTS[0]} className="h-full" />
</div>
</Reveal>
<Reveal delayMs={60} className="h-full">
<Reveal fade delayMs={60} className="h-full">
<div ref={trenerRef} className="h-full">
<ParticipantCard participant={PARTICIPANTS[1]} className="h-full" />
</div>
</Reveal>
<Reveal className="col-span-full flex justify-center py-10">
<Reveal fade className="col-span-full flex justify-center py-10">
<div
ref={hubRef}
className="window-glow relative z-10 grid size-36 place-items-center rounded-full border border-line bg-(image:--card-grad) shadow-glow"
@@ -379,12 +420,12 @@ function StackDiagram() {
</div>
</Reveal>
<Reveal delayMs={120} className="h-full">
<Reveal fade delayMs={120} className="h-full">
<div ref={silowniaRef} className="h-full">
<ParticipantCard participant={PARTICIPANTS[2]} className="h-full" />
</div>
</Reveal>
<Reveal delayMs={180} className="h-full">
<Reveal fade delayMs={180} className="h-full">
<div ref={adminRef} className="h-full">
<ParticipantCard participant={PARTICIPANTS[3]} className="h-full" />
</div>
@@ -401,7 +442,7 @@ export function Ecosystem() {
const [sectionRef, inView] = useInView<HTMLElement>('0px');
return (
<Section ref={sectionRef} id="ekosystem" className={inView ? 'is-live' : undefined}>
<Section ref={sectionRef} id="ekosystem" className={cn('cvx', inView && 'is-live')}>
<SectionHeading kicker="/rdzen" title={t('title')} lead={t('lead')} />
<HubDiagram />

View File

@@ -123,7 +123,7 @@ export function Tracks() {
};
return (
<Section id="sciezki">
<Section id="sciezki" className="cvx">
<div className="mx-auto max-w-2xl text-center">
<p className="font-mono text-xs tracking-widest text-accent">/sciezka</p>
<h2 className="mt-2 text-3xl font-bold text-ink sm:text-4xl">{t('introTitle')}</h2>

View File

@@ -225,6 +225,19 @@
transform: none;
}
/* Układy mierzone w DOM (rdzeń ekosystemu): fade bez przesunięcia, bo transform
w locie rozjeżdża pomiar promieni względem krawędzi kafelków */
.reveal-fade {
transform: none;
}
/* Sekcje o ciężkim układzie: przeglądarka pomija ich renderowanie, dopóki nie
zbliżają się do viewportu — główna ulga dla scrolla na mobile w długiej stronie */
.cvx {
content-visibility: auto;
contain-intrinsic-size: auto 1400px;
}
/* Paralaksa tła — warstwy trzymane na GPU, żeby scroll nie „żabkował” */
[data-parallax] {
will-change: transform;
@@ -306,7 +319,8 @@
}
}
/* Redukcja ruchu: typewriter/kropki/wejścia renderują się statycznie */
/* Redukcja ruchu: bez paralaksy/przesunięć/rysowania — zachowane subtelne,
lokalne pętle (promienie), żeby sekcje nie wyglądały na „martwe” */
@media (prefers-reduced-motion: reduce) {
html {
scroll-behavior: auto;
@@ -317,25 +331,13 @@
animation: none;
}
.boot-caret {
display: none;
}
.streak-dot {
animation: none;
}
.ray-flow,
.is-live .ray-flow {
animation: none;
stroke-dasharray: 10 90;
stroke-dashoffset: -30;
}
.reveal {
opacity: 1;
transform: none;
transition: none;
transition: opacity 240ms var(--ease-out-quart);
}
.window-glow:hover {