defmodule AbsintheFieldTelemetry.Web.Components.Object do @moduledoc false alias AbsintheFieldTelemetry.Types.Object alias AbsintheFieldTelemetry.Types.Field alias AbsintheFieldTelemetry.Types.Location use Phoenix.Component attr :object, Object def object(assigns) do ~H""" <%= unless Object.internal?(@object) do %>
<%= @object |> Object.color() |> color() %> <%= @object.name %> <%= (Object.percentage_hit(@object) * 100) |> Float.round(0) %>%
<.file_reference location={@object.location} />
<% end %> """ end attr :field, Field def field(assigns) do ~H""" <%= @field |> Field.color() |> color() %> <%= @field.name %> (hit count: <%= @field.count %>) <.file_reference location={@field.location} /> """ end attr :location, Location def file_reference(assigns) do ~H"""
<%= @location.file %>:<%= @location.line %>
""" end def color(:red), do: "🔴" def color(:orange), do: "🟠" def color(:green), do: "🟢" end