From 789ab16732e87188893fd140e2517335c7de458f Mon Sep 17 00:00:00 2001 From: nicolau Date: Mon, 23 Dec 2024 17:06:02 -0300 Subject: [PATCH 01/36] refactor: tables ui component --- .../explorer_web/components/batches_table.ex | 35 +++++ .../components/core_components.ex | 136 +++++++++--------- .../explorer_web/live/pages/batches/index.ex | 1 + .../live/pages/batches/index.html.heex | 29 +--- .../lib/explorer_web/live/pages/home/index.ex | 1 + .../live/pages/home/index.html.heex | 65 +++------ .../live/pages/operators/index.ex | 86 ++++++----- .../explorer_web/live/pages/restakes/index.ex | 70 ++++----- 8 files changed, 213 insertions(+), 210 deletions(-) create mode 100644 explorer/lib/explorer_web/components/batches_table.ex diff --git a/explorer/lib/explorer_web/components/batches_table.ex b/explorer/lib/explorer_web/components/batches_table.ex new file mode 100644 index 000000000..25c990a51 --- /dev/null +++ b/explorer/lib/explorer_web/components/batches_table.ex @@ -0,0 +1,35 @@ +defmodule ExplorerWeb.BatchesTable do + use Phoenix.Component + use ExplorerWeb, :live_component + + attr(:batches, :list, required: true) + + def batches_table(assigns) do + ~H""" + <.table id="batches" rows={@batches}> + <:col :let={latest_batch} label="Batch Hash" class="text-left"> + <.link navigate={~p"/batches/#{latest_batch.merkle_root}"}> + + <%= Helpers.shorten_hash(latest_batch.merkle_root, 6) %> + <.right_arrow /> + <.tooltip> + <%= latest_batch.merkle_root %> + + + + + <:col :let={latest_batch} label="Status"> + <.dynamic_badge_for_batcher status={Helpers.get_batch_status(latest_batch)} /> + + <:col :let={latest_batch} label="Age"> + + <%= latest_batch.submission_timestamp |> Helpers.parse_timeago() %> + + + <:col :let={latest_batch} label="Block Number"> + <%= latest_batch.submission_block_number |> Helpers.format_number() %> + + + """ + end +end diff --git a/explorer/lib/explorer_web/components/core_components.ex b/explorer/lib/explorer_web/components/core_components.ex index b77c5034b..445dfc7ad 100644 --- a/explorer/lib/explorer_web/components/core_components.ex +++ b/explorer/lib/explorer_web/components/core_components.ex @@ -522,13 +522,26 @@ defmodule ExplorerWeb.CoreComponents do classes([ "px-3 py-1 rounded-full font-semibold relative group", case @variant do - "accent" -> "color-accent text-accent-foreground bg-accent group-hover:bg-accent/80" - "primary" -> "color-primary text-primary-foreground bg-primary group-hover:bg-primary/80" - "secondary" -> "color-secondary text-secondary-foreground bg-secondary group-hover:bg-secondary/80" - "destructive" -> "color-destructive text-destructive-foreground bg-destructive group-hover:bg-destructive/80" - "foreground" -> "color-foreground text-background bg-foreground group-hover:bg-foreground/80" - "card" -> "color-card text-card-foreground bg-card group-hover:bg-card/80" - _ -> "color-accent text-accent-foreground bg-accent group-hover:bg-accent/80" + "accent" -> + "color-accent text-accent-foreground bg-accent group-hover:bg-accent/80" + + "primary" -> + "color-primary text-primary-foreground bg-primary group-hover:bg-primary/80" + + "secondary" -> + "color-secondary text-secondary-foreground bg-secondary group-hover:bg-secondary/80" + + "destructive" -> + "color-destructive text-destructive-foreground bg-destructive group-hover:bg-destructive/80" + + "foreground" -> + "color-foreground text-background bg-foreground group-hover:bg-foreground/80" + + "card" -> + "color-card text-card-foreground bg-card group-hover:bg-card/80" + + _ -> + "color-accent text-accent-foreground bg-accent group-hover:bg-accent/80" end, @class ]) @@ -541,13 +554,16 @@ defmodule ExplorerWeb.CoreComponents do >
<%= for {value, on_click} <- @options do %> -