diff --git a/lib/plexus_web/components/core_components.ex b/lib/plexus_web/components/core_components.ex index 6558fda1..c67736e2 100644 --- a/lib/plexus_web/components/core_components.ex +++ b/lib/plexus_web/components/core_components.ex @@ -593,6 +593,37 @@ defmodule PlexusWeb.CoreComponents do """ end + attr :score, Plexus.Schemas.Score, required: true + + def badge(%{score: %Plexus.Schemas.Score{}} = assigns) do + level = + case floor(assigns.score.numerator) do + 0 -> :unrated + 1 -> :borked + 2 -> :bronze + 3 -> :silver + 4 -> :gold + end + + assigns = + assigns + |> assign(:level, level) + |> assign(:title, Phoenix.Naming.humanize(level)) + + ~H""" + + <%= @title %> + + """ + end + ## JS Commands def show(js \\ %JS{}, selector) do diff --git a/lib/plexus_web/live/admin/app_live/index.html.heex b/lib/plexus_web/live/admin/app_live/index.html.heex index 9d37be55..5febb7fd 100644 --- a/lib/plexus_web/live/admin/app_live/index.html.heex +++ b/lib/plexus_web/live/admin/app_live/index.html.heex @@ -13,11 +13,11 @@ row_click={fn {_id, app} -> JS.navigate(~p"/admin/apps/#{app}") end} > <:col :let={{_id, app}} label="Icon"> -
<%= app.package %>
<:col :let={{_dom_id, %{scores: [native_score, _micro_g_score]}}} label="Native"> -- <%= native_score.numerator %>/<%= native_score.denominator %> -
+ <.badge score={native_score} /> <:col :let={{_dom_id, %{scores: [_native_score, micro_g_score]}}} label="MicroG"> -- <%= micro_g_score.numerator %>/<%= micro_g_score.denominator %> -
+ <.badge score={micro_g_score} /> <:action :let={{_dom_id, app}}>