310 lines
11 KiB
TypeScript
310 lines
11 KiB
TypeScript
import { useEffect, useRef, useState } from 'react';
|
|
import { Building2, Dumbbell, Shield, UserRound, type LucideIcon } from 'lucide-react';
|
|
import { Brandmark } from '../components/Brandmark';
|
|
import { Reveal } from '../components/Reveal';
|
|
import { cn } from '../lib/utils';
|
|
import { Section, SectionHeading } from './shared';
|
|
|
|
interface Participant {
|
|
icon: LucideIcon;
|
|
role: string;
|
|
brings: string;
|
|
gets: string;
|
|
link: string;
|
|
}
|
|
|
|
// Cztery strony rdzenia — FitOS nie ma „użytkowników końcowych”,
|
|
// każdy uczestnik jednocześnie wnosi wartość i ją pobiera.
|
|
export const PARTICIPANTS: Participant[] = [
|
|
{
|
|
icon: Dumbbell,
|
|
role: 'Ćwiczący',
|
|
brings: 'zaufanie i realne wyniki treningów — dane, na których trzyma się cała reszta',
|
|
gets: 'sprzęt, plan, trener i społeczność w jednym miejscu',
|
|
link: 'trenuje w siłowni, której sprzęt limituje jego plan',
|
|
},
|
|
{
|
|
icon: UserRound,
|
|
role: 'Trener',
|
|
brings: 'wiedzę: plany, progresje i opiekę nad podopiecznymi',
|
|
gets: 'dostęp do hal siłowni i podopiecznych, którzy realnie trenują',
|
|
link: 'układa plany pod sprzęt siłowni, w której trenuje jego podopieczny',
|
|
},
|
|
{
|
|
icon: Building2,
|
|
role: 'Siłownia',
|
|
brings: 'sprzęt, godziny, zasady i miejsce do trenowania',
|
|
gets: 'ludzi, którzy przychodzą po plan, i głos w swoim feedzie',
|
|
link: 'dostarcza sprzęt i ogłasza się ludziom, którzy jej potrzebują',
|
|
},
|
|
{
|
|
icon: Shield,
|
|
role: 'Administrator',
|
|
brings: 'porządek: weryfikacje, słowniki treści i pełny audyt czynności',
|
|
gets: 'ekosystem, który działa sam — bez domyślnego zaufania i śmieciowych danych',
|
|
link: 'zatwierdza profile i role — bez tego żadna siłownia nie staje się REAL',
|
|
},
|
|
];
|
|
|
|
interface Wire {
|
|
x1: number;
|
|
y1: number;
|
|
x2: number;
|
|
y2: number;
|
|
spread: number;
|
|
id: string;
|
|
}
|
|
|
|
const HUB_RADIUS = 78;
|
|
const SPREAD_PX = 52;
|
|
// impulsy promieniowania wypełniają cały stożek: wachlarz od wierzchołka
|
|
// do równomiernie rozmieszczonych punktów podstawy (frakcje ±1)
|
|
const STREAKS = [-1, -0.66, -0.33, 0, 0.33, 0.66, 1];
|
|
|
|
/**
|
|
* Diagram rdzenia (lg+): kafelki uczestników z naturalną wysokością (nic się nie
|
|
* ucina) i promienie—trójkąty mierzone w DOM (ResizeObserver): wierzchołek na
|
|
* obwodzie rdzenia, podstawa na ścianie kafelka.
|
|
*/
|
|
function HubDiagram() {
|
|
const containerRef = useRef<HTMLDivElement>(null);
|
|
const trenerRef = useRef<HTMLDivElement>(null);
|
|
const silowniaRef = useRef<HTMLDivElement>(null);
|
|
const cwiczacyRef = useRef<HTMLDivElement>(null);
|
|
const adminRef = useRef<HTMLDivElement>(null);
|
|
const [wires, setWires] = useState<Wire[]>([]);
|
|
|
|
useEffect(() => {
|
|
const container = containerRef.current;
|
|
if (!container) return;
|
|
|
|
const targets = [
|
|
{ el: trenerRef.current, side: 'left' as const, id: 'trener' },
|
|
{ el: silowniaRef.current, side: 'left' as const, id: 'silownia' },
|
|
{ el: cwiczacyRef.current, side: 'right' as const, id: 'cwiczacy' },
|
|
{ el: adminRef.current, side: 'right' as const, id: 'admin' },
|
|
];
|
|
|
|
const compute = () => {
|
|
const cr = container.getBoundingClientRect();
|
|
if (!cr.width || !cr.height) return;
|
|
const cx = cr.width / 2;
|
|
const cy = cr.height / 2;
|
|
const next: Wire[] = [];
|
|
for (const t of targets) {
|
|
if (!t.el) continue;
|
|
const r = t.el.getBoundingClientRect();
|
|
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;
|
|
next.push({
|
|
x1: ((cx + (dx / len) * HUB_RADIUS) / cr.width) * 100,
|
|
y1: ((cy + (dy / len) * HUB_RADIUS) / cr.height) * 100,
|
|
x2: (((t.side === 'left' ? r.right : r.left) - cr.left) / cr.width) * 100,
|
|
y2: (midY / cr.height) * 100,
|
|
// połowa podstawy trójkąta jako % wysokości kontenera
|
|
spread: (SPREAD_PX / cr.height) * 100,
|
|
id: t.id,
|
|
});
|
|
}
|
|
setWires(next);
|
|
};
|
|
|
|
compute();
|
|
// jsdom nie zna ResizeObserver — wystarczy jednorazowy pomiar (i tak puste recty)
|
|
if (typeof ResizeObserver !== 'undefined') {
|
|
const observer = new ResizeObserver(compute);
|
|
observer.observe(container);
|
|
window.addEventListener('resize', compute);
|
|
return () => {
|
|
observer.disconnect();
|
|
window.removeEventListener('resize', compute);
|
|
};
|
|
}
|
|
}, []);
|
|
|
|
return (
|
|
<Reveal className="hidden lg:block">
|
|
<div
|
|
ref={containerRef}
|
|
className="relative mt-14 grid h-[680px] grid-cols-2 grid-rows-2 gap-x-10 gap-y-6"
|
|
>
|
|
<svg
|
|
aria-hidden="true"
|
|
viewBox="0 0 100 100"
|
|
preserveAspectRatio="none"
|
|
className="absolute inset-0 h-full w-full"
|
|
>
|
|
<defs>
|
|
{wires.map((w) => (
|
|
<linearGradient
|
|
key={w.id}
|
|
id={`ray-${w.id}`}
|
|
gradientUnits="userSpaceOnUse"
|
|
x1={w.x1}
|
|
y1={w.y1}
|
|
x2={w.x2}
|
|
y2={w.y2}
|
|
>
|
|
<stop offset="0" stopColor="var(--accent)" stopOpacity="0.55" />
|
|
<stop offset="1" stopColor="var(--accent)" stopOpacity="0.04" />
|
|
</linearGradient>
|
|
))}
|
|
<radialGradient id="ray-glow" gradientUnits="userSpaceOnUse" cx="50" cy="50" r="50">
|
|
<stop offset="0" stopColor="#fff" stopOpacity="1" />
|
|
<stop offset="1" stopColor="#fff" stopOpacity="0" />
|
|
</radialGradient>
|
|
<mask id="ray-soft">
|
|
<rect x="0" y="0" width="100" height="100" fill="url(#ray-glow)" />
|
|
</mask>
|
|
</defs>
|
|
<g mask="url(#ray-soft)">
|
|
{wires.map((w) => (
|
|
<g key={w.id}>
|
|
<polygon
|
|
points={`${w.x1},${w.y1} ${w.x2},${w.y2 - w.spread} ${w.x2},${w.y2 + w.spread}`}
|
|
fill={`url(#ray-${w.id})`}
|
|
/>
|
|
{STREAKS.map((f, i) => (
|
|
<line
|
|
key={f}
|
|
className="ray-flow"
|
|
style={{ animationDelay: `${-i * 0.42}s` }}
|
|
x1={w.x1}
|
|
y1={w.y1}
|
|
x2={w.x2}
|
|
y2={w.y2 + w.spread * f}
|
|
pathLength={100}
|
|
vectorEffect="non-scaling-stroke"
|
|
stroke="var(--accent)"
|
|
strokeOpacity="0.5"
|
|
strokeWidth="2"
|
|
strokeLinecap="round"
|
|
/>
|
|
))}
|
|
</g>
|
|
))}
|
|
</g>
|
|
</svg>
|
|
|
|
<div className="window-glow absolute left-1/2 top-1/2 z-10 grid size-40 -translate-x-1/2 -translate-y-1/2 place-items-center rounded-full border border-line bg-(image:--card-grad) shadow-glow">
|
|
<div className="text-center">
|
|
<Brandmark size={40} className="mx-auto" />
|
|
<p className="mt-2 font-display text-sm font-bold text-ink">FitOS</p>
|
|
<p className="font-mono text-[10px] text-accent">rdzeń</p>
|
|
</div>
|
|
</div>
|
|
|
|
<div className="col-start-1 row-start-1 flex h-full items-center justify-start">
|
|
<div ref={trenerRef} className="h-full w-[65%]">
|
|
<ParticipantCard participant={PARTICIPANTS[1]} className="h-full" />
|
|
</div>
|
|
</div>
|
|
<div className="col-start-1 row-start-2 flex h-full items-center justify-start">
|
|
<div ref={silowniaRef} className="h-full w-[65%]">
|
|
<ParticipantCard participant={PARTICIPANTS[2]} className="h-full" />
|
|
</div>
|
|
</div>
|
|
<div className="col-start-2 row-start-1 flex h-full items-center justify-end">
|
|
<div ref={cwiczacyRef} className="h-full w-[65%]">
|
|
<ParticipantCard participant={PARTICIPANTS[0]} className="h-full" />
|
|
</div>
|
|
</div>
|
|
<div className="col-start-2 row-start-2 flex h-full items-center justify-end">
|
|
<div ref={adminRef} className="h-full w-[65%]">
|
|
<ParticipantCard participant={PARTICIPANTS[3]} className="h-full" />
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</Reveal>
|
|
);
|
|
}
|
|
|
|
/** Sekcja „Ekosystem” — rdzeń (od ogółu): mapa uczestników i legenda zazębień. */
|
|
export function Ecosystem() {
|
|
return (
|
|
<Section id="ekosystem">
|
|
<SectionHeading
|
|
kicker="/rdzen"
|
|
title="Ekosystem — rdzeń systemu"
|
|
lead="FitOS nie jest aplikacją treningową z dodatkiem siłowni. To rdzeń, w którym potrzeby ćwiczących, trenerów i siłowni zazębiają się nawzajem — nikt nie jest tu użytkownikiem końcowym."
|
|
/>
|
|
|
|
<HubDiagram />
|
|
|
|
{/* Telefon/tablet: rdzeń nad listą uczestników */}
|
|
<div className="mt-14 flex flex-col gap-4 lg:hidden">
|
|
<Reveal className="flex justify-center">
|
|
<div className="window-glow grid size-36 place-items-center rounded-full border border-line bg-(image:--card-grad) shadow-glow">
|
|
<div className="text-center">
|
|
<Brandmark size={34} className="mx-auto" />
|
|
<p className="mt-1.5 font-display text-sm font-bold text-ink">FitOS</p>
|
|
<p className="font-mono text-[10px] text-accent">rdzeń</p>
|
|
</div>
|
|
</div>
|
|
</Reveal>
|
|
<div className="mt-14 grid gap-4 sm:grid-cols-2">
|
|
{PARTICIPANTS.map((p, i) => (
|
|
<Reveal key={p.role} delayMs={i * 60} className="h-full">
|
|
<ParticipantCard participant={p} className="h-full" />
|
|
</Reveal>
|
|
))}
|
|
</div>
|
|
</div>
|
|
</Section>
|
|
);
|
|
}
|
|
|
|
function ParticipantCard({
|
|
participant,
|
|
className,
|
|
}: {
|
|
participant: Participant;
|
|
className?: string;
|
|
}) {
|
|
const Icon = participant.icon;
|
|
const rows = [
|
|
{ key: 'wnosi', text: participant.brings, accent: true },
|
|
{ key: 'bierze', text: participant.gets, accent: false },
|
|
{ key: 'wiąże', text: participant.link, accent: true, last: true },
|
|
];
|
|
return (
|
|
<div
|
|
className={cn(
|
|
'window-glow rounded-lg border border-line bg-(image:--card-grad) p-5 shadow-card',
|
|
className,
|
|
)}
|
|
>
|
|
<div className="flex items-center gap-2.5">
|
|
<span className="grid size-8 place-items-center rounded-md border border-line bg-input text-accent">
|
|
<Icon size={15} aria-hidden="true" />
|
|
</span>
|
|
<span className="font-display text-[15px] font-bold text-ink">{participant.role}</span>
|
|
</div>
|
|
<dl className="mt-4 border-t border-line pt-3.5 text-[13px] leading-relaxed">
|
|
{rows.map((row) => (
|
|
<div
|
|
key={row.key}
|
|
className={cn(
|
|
'grid grid-cols-[4.5rem_1fr] items-baseline gap-x-3 pt-2.5',
|
|
!row.last && 'pb-2.5',
|
|
)}
|
|
>
|
|
<dt
|
|
className={cn(
|
|
'font-mono text-[10px] uppercase tracking-[0.14em]',
|
|
row.accent ? 'text-accent' : 'text-dim',
|
|
)}
|
|
>
|
|
{row.key}
|
|
</dt>
|
|
<dd className={row.accent ? 'text-dim' : 'text-ink'}>{row.text}</dd>
|
|
</div>
|
|
))}
|
|
</dl>
|
|
</div>
|
|
);
|
|
}
|