Skip to content

Commit 9e5ac9d

Browse files
authored
style(explorer): improve batch detail layout (yetanotherco#709)
1 parent 84f595c commit 9e5ac9d

4 files changed

Lines changed: 42 additions & 32 deletions

File tree

explorer/lib/explorer_web/components/core_components.ex

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -837,4 +837,15 @@ defmodule ExplorerWeb.CoreComponents do
837837
def translate_errors(errors, field) when is_list(errors) do
838838
for {^field, {msg, opts}} <- errors, do: translate_error({msg, opts})
839839
end
840+
841+
@doc """
842+
Divider component.
843+
"""
844+
attr :class, :string, default: nil
845+
846+
def divider(assigns) do
847+
~H"""
848+
<hr class={["border-t rounded-full border-muted-foreground/40 my-1.5", @class]} />
849+
"""
850+
end
840851
end

explorer/lib/explorer_web/components/search.ex

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,16 +28,16 @@ defmodule SearchComponent do
2828
phx-target={@myself}
2929
phx-submit="search_batch"
3030
class={[
31-
"relative flex items-center w-full max-w-md gap-2 z-10 px-5 sm:px-0 drop-shadow-sm",
31+
"relative flex items-center gap-2 z-10 px-5 sm:px-0 drop-shadow-sm max-w-md",
3232
@class
3333
]}
3434
>
3535
<input
3636
phx-hook="SearchFocus"
3737
id={"input_#{assigns.id}"}
38-
class="pr-10 shadow-md flex h-10 w-full file:border-0 text-foreground file:bg-transparent file:text-sm file:font-medium placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed flex-1 rounded-md border border-foreground/20 bg-card px-4 py-2 text-sm font-medium transition-colors hover:bg-muted focus:outline-none focus:ring-1 disabled:pointer-events-none disabled:opacity-50 hover:text-foreground"
38+
class="pr-10 shadow-md flex h-10 w-full md:min-w-72 file:border-0 text-foreground file:bg-transparent file:text-sm file:font-medium placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed flex-1 rounded-md border border-foreground/20 bg-card px-4 py-2 text-sm font-medium transition-colors hover:bg-muted focus:outline-none focus:ring-1 disabled:pointer-events-none disabled:opacity-50 hover:text-foreground"
3939
type="search"
40-
placeholder="Search by merkle root hash..."
40+
placeholder="Search by batch hash (cmd+K)"
4141
name="batch[merkle_root]"
4242
/>
4343
<.button

explorer/lib/explorer_web/components/tweet.ex

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ defmodule TweetComponent do
77
@impl true
88
def render(assigns) do
99
~H"""
10-
<div>
10+
<div class={@class}>
1111
<a
1212
href={"https://twitter.com/intent/tweet?text=#{@text}"}
1313
target="_blank"
@@ -20,8 +20,7 @@ defmodule TweetComponent do
2020
>
2121
<button class={[
2222
"bg-black text-neutral-50 hover:bg-neutral-700 px-3 pb-0.5",
23-
"font-bold text-sm leading-[18px] tracking-wider rounded-full",
24-
@class
23+
"font-bold text-sm leading-[18px] tracking-wider rounded-full"
2524
]}>
2625
<span class="text-xl font-normal">𝕏</span> <span class="tracking-tight">Post</span>
2726
</button>

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

Lines changed: 26 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -4,23 +4,43 @@
44
Batch Details
55
</.card_preheding>
66
<.card
7-
class="px-4 py-5 min-h-fit flex flex-col"
7+
class="relative px-4 py-5 min-h-fit flex flex-col"
88
inner_class="font-semibold inline-flex flex-col text-base gap-y-2 text-muted-foreground [&>p]:text-foreground [&>a]:text-foreground [&>*]:break-all [&>*]:font-normal"
99
>
10-
Merkle Root Hash:
10+
Batch Hash:
1111
<p><%= @merkle_root %></p>
12+
Status: <.dynamic_badge class="w-fit" status={@current_batch.is_verified} />
1213
Amount of Proofs in this Batch:
1314
<p><%= @current_batch.amount_of_proofs %></p>
1415
<%= if @current_batch.cost_per_proof != nil do %>
1516
Cost per Proof:
1617
<p>
1718
<%= @current_batch.cost_per_proof |> EthConverter.wei_to_eth() %> ETH
1819
<%= if @eth_usd_price != :empty and @eth_usd_price != "0.00000" do %>
19-
(<%= @eth_usd_price %> USD)
20+
<span class="inline-flex md:inline-block">(<%= @eth_usd_price %> USD)</span>
2021
<% end %>
2122
</p>
2223
<% end %>
23-
Submission Block Number:
24+
Proofs in this batch:
25+
<%= if @proof_hashes != :empty do %>
26+
<%= if @proof_hashes == :nil do %>
27+
<p class="normal-case">
28+
Proofs couldn't be shown for this Batch
29+
</p>
30+
<% else %>
31+
<div class="h-36 overflow-y-auto text-foreground space-y-2">
32+
<p :for={proof <- @proof_hashes}><%= proof %></p>
33+
</div>
34+
<.button class="w-fit text-foreground" phx-click="hide_proofs">
35+
<.icon name="hero-eye-slash" class="size-4" /> Hide Proofs
36+
</.button>
37+
<% end %>
38+
<% else %>
39+
<.button class="w-fit text-foreground font-semibold" phx-click="show_proofs">
40+
<.icon name="hero-eye" class="size-4" /> Show Proofs
41+
</.button>
42+
<% end %>
43+
<.divider /> Submission Block Number:
2444
<.a
2545
target="_blank"
2646
rel="noopener"
@@ -44,9 +64,8 @@
4464
<p>
4565
<%= @current_batch.submission_timestamp |> Utils.parse_timestamp() %>
4666
</p>
47-
Status: <.dynamic_badge class="w-fit" status={@current_batch.is_verified} />
4867
<%= if @current_batch.is_verified do %>
49-
Response Block Number:
68+
<.divider /> Response Block Number:
5069
<.a
5170
target="_blank"
5271
rel="noopener"
@@ -68,37 +87,18 @@
6887
<p>
6988
<%= @current_batch.response_timestamp |> Utils.parse_timestamp() %>
7089
</p>
71-
Share:
7290
<%!--
7391
%20 represents a space
7492
%23 represents the hash symbol (#)
7593
%0A represents a line feed (LF) or Unix-style newline
7694
--%>
7795
<.live_component
96+
class="absolute top-4 md:-top-12 right-5"
7897
id={"tweet_#{@merkle_root}"}
7998
module={TweetComponent}
8099
text={"Just%20submitted%20a%20proof%20via%20@alignedlayer%0AI%20am%20now%20%23aligned%20✅%0A#{@site_url}/batches/#{@merkle_root}"}
81100
/>
82101
<% end %>
83-
Proofs in this batch:
84-
<%= if @proof_hashes != :empty do %>
85-
<%= if @proof_hashes == :nil do %>
86-
<p class="normal-case">
87-
Proofs couldn't be shown for this Batch
88-
</p>
89-
<% else %>
90-
<div class="h-32 overflow-y-auto text-foreground space-y-2">
91-
<p :for={proof <- @proof_hashes}><%= proof %></p>
92-
<.button class="w-fit text-foreground" phx-click="hide_proofs">
93-
<.icon name="hero-eye-slash" class="size-4" /> Hide Proofs
94-
</.button>
95-
</div>
96-
<% end %>
97-
<% else %>
98-
<.button class="w-fit text-foreground font-semibold" phx-click="show_proofs">
99-
<.icon name="hero-eye" class="size-4" /> Show Proofs
100-
</.button>
101-
<% end %>
102102
</.card>
103103
<% else %>
104104
<div class="flex flex-col space-y-6 justify-center grow relative text-center md:pt-14">

0 commit comments

Comments
 (0)