defmodule Bloccs.Web.Components.Graph do @moduledoc """ The shared topology SVG: places one `<.hex_glyph>` per node and one bezier `` per edge from a server-computed `Bloccs.Web.Topology.Layout`. Used by the topology panel (live node state) and the coverage panel (reached/unreached overlay). Pure rendering — no data loading, no layout math. """ use Bloccs.Web, :html alias Bloccs.Web.Topology.Layout attr :network, :any, required: true attr :states, :map, default: %{} # nil = no coverage overlay; a MapSet of {from_node, to_node} = reached edges attr :reached_edges, :any, default: nil def graph(assigns) do assigns = assign(assigns, :layout, Layout.compute(assigns.network)) ~H"""
<.hex_glyph glyph={n.glyph} state={Map.get(@states, n.id, :idle)} label={n.label} x={n.x} y={n.y} /> {n.label}
""" end defp edge_class(nil, _edge), do: nil defp edge_class(reached, %{from: f, to: t}) do if MapSet.member?(reached, {f, t}), do: "bloccs-edge--reached", else: "bloccs-edge--unreached" end end