Skip to content

Commit 9c00f54

Browse files
feat(explorer): add batch status on detail page (#339)
Co-authored-by: Mariano A. Nicolini <[email protected]>
1 parent d2b2f53 commit 9c00f54

File tree

3 files changed

+69
-20
lines changed

3 files changed

+69
-20
lines changed

explorer/lib/explorer_web/components/core_components.ex

Lines changed: 35 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -304,12 +304,46 @@ defmodule ExplorerWeb.CoreComponents do
304304

305305
def a(assigns) do
306306
~H"""
307-
<.link class={["underline underline-offset-4 font-medium after:content-['↗'] hover:after:content-['→'] transition-all duration-150", @class]} {@rest}>
307+
<.link
308+
class={[
309+
"underline underline-offset-4 font-medium after:content-['↗'] hover:after:content-['→'] transition-all duration-150",
310+
@class
311+
]}
312+
{@rest}
313+
>
308314
<%= render_slot(@inner_block) %>
309315
</.link>
310316
"""
311317
end
312318

319+
@doc """
320+
Renders a dynamic badge compoent.
321+
"""
322+
attr :class, :string, default: nil
323+
attr :status, :boolean, default: true
324+
attr :pending_text, :string, default: "Pending"
325+
attr :verified_text, :string, default: "Verified"
326+
slot :inner_block, default: nil
327+
328+
def dynamic_badge(assigns) do
329+
~H"""
330+
<span class={[
331+
"px-3 py-1 rounded-full",
332+
case @status do
333+
true -> "text-black bg-primary group-hover:bg-primary/80"
334+
false -> "text-white bg-secondary group-hover:bg-secondary/80"
335+
end,
336+
@class
337+
]}>
338+
<%= case @status do
339+
true -> @verified_text
340+
false -> @pending_text
341+
end %>
342+
<%= render_slot(@inner_block) %>
343+
</span>
344+
"""
345+
end
346+
313347
@doc """
314348
Renders an input with label and error messages.
315349

explorer/lib/explorer_web/live/pages/batch/index.html.heex

Lines changed: 33 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,40 @@
33
<h1 class="text-5xl font-bold font-foreground">Batch Details</h1>
44
<.card
55
class="px-6 py-5 min-h-fit flex flex-col rounded-3xl"
6-
inner_class="font-semibold inline-flex flex-col text-base gap-y-2 text-muted-foreground [&>span]:text-foreground [&>a]:text-foreground"
6+
inner_class="font-semibold inline-flex flex-col text-base gap-y-2 text-muted-foreground [&>p]:text-foreground [&>a]:text-foreground"
77
>
8-
Merkle Root Hash: <span class="break-all font-normal"><%= @merkle_root %></span>
9-
Block Hash: <span class="break-all font-normal"><%= @newBatchInfo.block_hash %></span>
10-
Block Number: <.a target="_blank" rel="noopener" href={"https://holesky.etherscan.io/block/#{@newBatchInfo.block_number}"} class="break-all font-normal"><%= @newBatchInfo.block_number %></.a>
11-
Transaction Hash:
12-
<.a target="_blank" rel="noopener" href={"https://holesky.etherscan.io/tx/#{@newBatchInfo.transaction_hash}"} class="break-all font-normal"><%= @newBatchInfo.transaction_hash %></.a>
13-
Aligned Contract Address: <.a target="_blank" rel="noopener" href={"https://holesky.etherscan.io/address/#{@newBatchInfo.address}"} class="break-all font-normal"><%= @newBatchInfo.address %></.a>
8+
Merkle Root Hash:
9+
<p class="break-all font-normal"><%= @merkle_root %></p>
10+
Block Hash:
11+
<p class="break-all font-normal"><%= @newBatchInfo.block_hash %></p>
12+
Block Number:
13+
<.a
14+
target="_blank"
15+
rel="noopener"
16+
href={"https://holesky.etherscan.io/block/#{@newBatchInfo.block_number}"}
17+
class="break-all font-normal"
18+
>
19+
<%= @newBatchInfo.block_number %>
20+
</.a>
21+
Batch Submission Transaction Hash:
22+
<.a
23+
target="_blank"
24+
rel="noopener"
25+
href={"https://holesky.etherscan.io/tx/#{@newBatchInfo.transaction_hash}"}
26+
class="break-all font-normal"
27+
>
28+
<%= @newBatchInfo.transaction_hash %>
29+
</.a>
30+
Aligned Contract Address:
31+
<.a
32+
target="_blank"
33+
rel="noopener"
34+
href={"https://holesky.etherscan.io/address/#{@newBatchInfo.address}"}
35+
class="break-all font-normal"
36+
>
37+
<%= @newBatchInfo.address %>
38+
</.a>
39+
Status: <.dynamic_badge class="w-fit" status={@batchWasResponded} />
1440
</.card>
1541
<% else %>
1642
<div class="flex flex-col space-y-6 justify-center grow relative text-center">

explorer/lib/explorer_web/live/pages/batches/index.html.heex

Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -34,18 +34,7 @@
3434
<th class={[
3535
"font-medium text-base rounded-full"
3636
]}>
37-
<span class={[
38-
"px-3 py-1 rounded-full",
39-
case batch.responded do
40-
true -> "text-black bg-primary group-hover:bg-primary/80"
41-
false -> "text-white bg-secondary group-hover:bg-secondary/80"
42-
end
43-
]}>
44-
<%= case batch.responded do
45-
true -> "Verified"
46-
false -> "Pending"
47-
end %>
48-
</span>
37+
<.dynamic_badge status={batch.responded} />
4938
</th>
5039
</tr>
5140
<% end %>

0 commit comments

Comments
 (0)