FitOS
@@ -222,6 +298,119 @@ function HubDiagram() {
);
}
+/**
+ * Diagram rdzenia pod lg: układ pionowy (telefon: ćwiczący, trener, rdzeń,
+ * siłownia, administrator — promienie tylko do dwóch najbliższych kafelków)
+ * lub dwie pary nad/pod rdzeniem (tablet sm+: promienie do wszystkich czterech).
+ */
+function StackDiagram() {
+ const containerRef = useRef
(null);
+ const hubRef = useRef(null);
+ const cwiczacyRef = useRef(null);
+ const trenerRef = useRef(null);
+ const silowniaRef = useRef(null);
+ const adminRef = useRef(null);
+ const [wires, setWires] = useState([]);
+ const [hub, setHub] = useState({ x: 50, y: 50 });
+ const [wide, setWide] = useState(() =>
+ typeof window !== 'undefined' && typeof window.matchMedia === 'function'
+ ? window.matchMedia('(min-width: 640px)').matches
+ : true,
+ );
+
+ useEffect(() => {
+ if (typeof window === 'undefined' || typeof window.matchMedia !== 'function') return;
+ const mq = window.matchMedia('(min-width: 640px)');
+ const onChange = () => setWide(mq.matches);
+ onChange();
+ mq.addEventListener('change', onChange);
+ return () => mq.removeEventListener('change', onChange);
+ }, []);
+
+ const compute = useCallback(() => {
+ const container = containerRef.current;
+ const hubEl = hubRef.current;
+ if (!container || !hubEl) return;
+ const targets: WireTarget[] = [
+ { el: cwiczacyRef.current, side: 'top', id: 'cwiczacy' },
+ { el: trenerRef.current, side: 'top', id: 'trener' },
+ { el: silowniaRef.current, side: 'bottom', id: 'silownia' },
+ { el: adminRef.current, side: 'bottom', id: 'admin' },
+ ];
+ // telefon (1 kolumna): promienie tylko do najbliższych — Trener i Siłownia;
+ // tablet (2 kolumny): rdzeń między parami — promienie do wszystkich czterech
+ const visible = wide ? targets : targets.filter((t) => t.id === 'trener' || t.id === 'silownia');
+ const measured = measureWires(container, hubEl, visible, HUB_RADIUS_STACK);
+ setWires(measured.wires);
+ setHub(measured.hub);
+ }, [wide]);
+
+ useEffect(() => {
+ compute();
+ // jsdom nie zna ResizeObserver — wystarczy jednorazowy pomiar (i tak puste recty)
+ if (typeof ResizeObserver !== 'undefined') {
+ const observer = new ResizeObserver(compute);
+ if (containerRef.current) observer.observe(containerRef.current);
+ if (hubRef.current) observer.observe(hubRef.current);
+ window.addEventListener('resize', compute);
+ return () => {
+ observer.disconnect();
+ window.removeEventListener('resize', compute);
+ };
+ }
+ }, [compute]);
+
+ return (
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ );
+}
+
/** Sekcja „Ekosystem” — rdzeń (od ogółu): mapa uczestników i legenda zazębień. */
export function Ecosystem() {
return (
@@ -234,25 +423,8 @@ export function Ecosystem() {
- {/* Telefon/tablet: rdzeń nad listą uczestników */}
-
-
-
-
-
- {PARTICIPANTS.map((p, i) => (
-
-
-
- ))}
-
-
+ {/* Telefon/tablet: rdzeń między parami uczestników z promieniowaniem */}
+
);
}