defmodule Bloccs.Web.Panels.Topology do @moduledoc """ Panel 2 — the network graph drawn in the bloccs hexagon notation. The layout is computed server-side (`Bloccs.Web.Topology.Layout`) and rendered as a single SVG: one `<.hex_glyph>` per node, one cubic-bezier `` per edge. Live node state (`states[node_id]`) is an assign-driven CSS class on each glyph — no client animation. P4 feeds `states`; in P3 every node is `:idle`. """ use Bloccs.Web, :html import Bloccs.Web.Components.Graph attr :network, :any, required: true attr :base_path, :string, required: true attr :states, :map, default: %{} def render(assigns) do ~H"""

Topology

{length(@network.nodes)} nodes · {length(@network.edges)} edges
<.graph network={@network} states={@states} /> <.legend network={@network} />
""" end attr :network, :any, required: true defp legend(assigns) do assigns = assign(assigns, :glyphs, distinct_glyphs(assigns.network)) ~H""" """ end defp distinct_glyphs(network) do network.nodes |> Enum.map(& &1.glyph) |> Enum.uniq() |> Enum.sort() end end