import { useEffect, useState } from 'react' // The FAFO mark is a hexagonal node graph. This is the same geometry, used for what it stands for: // one work order moving through the governed state machine, lighting the audit trail as it goes. const C = 260 const deg = (a) => (a * Math.PI) / 180 const pt = (r, a) => [C + r * Math.cos(deg(a)), C + r * Math.sin(deg(a))] const OUTER = 205 const INNER = 102 const vertexAngles = [-90, -30, 30, 90, 150, 210] // pointy-top outer hexagon const midAngles = [-60, 0, 60, 120, 180, 240] // outer edge midpoints and inner (flat-top) vertices const nodes = {} vertexAngles.forEach((a, i) => (nodes[`v${i}`] = pt(OUTER, a))) midAngles.forEach((a, i) => (nodes[`m${i}`] = pt(OUTER * Math.cos(deg(30)), a))) midAngles.forEach((a, i) => (nodes[`i${i}`] = pt(INNER, a))) nodes.c = [C, C] const edges = [] for (let i = 0; i < 6; i++) { edges.push([`v${i}`, `m${i}`], [`m${i}`, `v${(i + 1) % 6}`]) // outer ring through midpoints edges.push([`i${i}`, `i${(i + 1) % 6}`]) // inner ring edges.push([`m${i}`, `i${i}`]) // midpoint to inner vertex edges.push([`i${i}`, 'c']) // inner vertex to centre } // The governed path: each stop is a real state in the work order lifecycle. const PATH = [ { id: 'v0', label: 'Intent', dx: 0, dy: -22, anchor: 'middle' }, { id: 'm0', label: 'Contract', dx: 16, dy: -8, anchor: 'start' }, { id: 'i0', label: 'Grounding', dx: 16, dy: 4, anchor: 'start' }, { id: 'c', label: 'Execution', dx: 0, dy: 30, anchor: 'middle' }, { id: 'i3', label: 'Evidence', dx: -16, dy: 4, anchor: 'end' }, { id: 'm3', label: 'Gatekeeper', dx: -16, dy: 22, anchor: 'end' }, { id: 'v4', label: 'Closed', dx: -14, dy: 6, anchor: 'end' }, ] const pathEdges = PATH.slice(1).map((s, i) => [PATH[i].id, s.id].sort().join('|')) const edgeKey = (e) => [...e].sort().join('|') export default function WorkGraph() { const [step, setStep] = useState(0) const [reduced, setReduced] = useState(false) useEffect(() => { const mq = window.matchMedia('(prefers-reduced-motion: reduce)') const sync = () => setReduced(mq.matches) sync() mq.addEventListener('change', sync) return () => mq.removeEventListener('change', sync) }, []) useEffect(() => { if (reduced) return // Steps 1..7 light the path; step 8 holds the finished trail before it clears. const id = setInterval(() => setStep((s) => (s + 1) % (PATH.length + 2)), 1100) return () => clearInterval(id) }, [reduced]) const lit = reduced ? PATH.length : Math.min(step, PATH.length) const litIds = new Set(PATH.slice(0, lit).map((s) => s.id)) const litEdges = new Set(pathEdges.slice(0, Math.max(0, lit - 1))) const current = lit > 0 && lit <= PATH.length ? PATH[lit - 1] : null return (
{edges.map((e) => { const [a, b] = e const k = edgeKey(e) return ( ) })} {Object.entries(nodes).map(([id, [x, y]]) => ( ))} {PATH.map((s, i) => { const [x, y] = nodes[s.id] return ( {s.label} ) })}
One work order through the governed state machine Illustrative, not a live feed
) }