Skip to content
This repository has been archived by the owner on Oct 4, 2024. It is now read-only.

Commit

Permalink
[Frontend] add timestamp hover in frontend (#361)
Browse files Browse the repository at this point in the history
* add timestamp hover in frontend

* fix CSS for hovers

---------

Co-authored-by: Santiago Pittella <[email protected]>
  • Loading branch information
SantiagoPittella and Santiago Pittella authored Nov 10, 2023
1 parent 717bcf7 commit 4b4a07c
Show file tree
Hide file tree
Showing 9 changed files with 120 additions and 12 deletions.
16 changes: 14 additions & 2 deletions lib/starknet_explorer_web/live/block_index_live.ex
Original file line number Diff line number Diff line change
Expand Up @@ -54,9 +54,21 @@ defmodule StarknetExplorerWeb.BlockIndexLive do
</span>
</div>
</div>
<div>
<div class="block-data">
<div class="list-h">Age</div>
<%= Utils.get_block_age(block) %>
<div class="hash flex">
<div class="flex items-center gap-2">
<%= Utils.get_block_age(block) %>
<CoreComponents.tooltip
id="block-timestamp-tooltip"
text={"#{block.timestamp
|> DateTime.from_unix()
|> then(fn {:ok, time} -> time end)
|> Calendar.strftime("%c")} UTC"}
class="translate-y-px"
/>
</div>
</div>
</div>
</div>
<% end %>
Expand Down
10 changes: 9 additions & 1 deletion lib/starknet_explorer_web/live/class_index_live.ex
Original file line number Diff line number Diff line change
Expand Up @@ -68,8 +68,16 @@ defmodule StarknetExplorerWeb.ClassIndexLive do
<div>
<div class="list-h">Declared at</div>
<div class="block-data">
<div class="hash flex">
<div class="flex items-center gap-2">
<%= Utils.get_block_age_from_timestamp(class.timestamp) %>
<CoreComponents.tooltip
id="class-timestamp-tooltip"
text={"#{class.timestamp
|> DateTime.from_unix()
|> then(fn {:ok, time} -> time end)
|> Calendar.strftime("%c")} UTC"}
class="translate-y-px"
/>
</div>
</div>
</div>
Expand Down
10 changes: 9 additions & 1 deletion lib/starknet_explorer_web/live/contract_index_live.ex
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,16 @@ defmodule StarknetExplorerWeb.ContractIndexLive do
</div>
<div>
<div class="list-h">Deployed At</div>
<div>
<div class="flex items-center gap-2">
<%= Utils.get_block_age_from_timestamp(contract.timestamp) %>
<CoreComponents.tooltip
id="contract-timestamp-tooltip"
text={"#{contract.timestamp
|> DateTime.from_unix()
|> then(fn {:ok, time} -> time end)
|> Calendar.strftime("%c")} UTC"}
class="translate-y-px"
/>
</div>
</div>
</div>
Expand Down
10 changes: 9 additions & 1 deletion lib/starknet_explorer_web/live/event_index_live.ex
Original file line number Diff line number Diff line change
Expand Up @@ -85,8 +85,16 @@ defmodule StarknetExplorerWeb.EventIndexLive do
</div>
<div>
<div class="list-h">Age</div>
<div>
<div class="flex items-center gap-2">
<%= Utils.get_block_age_from_timestamp(event.age) %>
<CoreComponents.tooltip
id="event-timestamp-tooltip"
text={"#{event.age
|> DateTime.from_unix()
|> then(fn {:ok, time} -> time end)
|> Calendar.strftime("%c")} UTC"}
class="translate-y-px"
/>
</div>
</div>
</div>
Expand Down
14 changes: 13 additions & 1 deletion lib/starknet_explorer_web/live/messages/message_info.html.heex
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,19 @@
text="The date and time when the message log was validated."
/> Timestamp
</div>
<div><%= Utils.get_block_age_from_timestamp(@message.timestamp) %></div>
<div>
<div class="flex items-center gap-2">
<%= Utils.get_block_age_from_timestamp(@message.timestamp) %>
<CoreComponents.tooltip
id="message-timestamp-tooltip"
text={"#{@message.timestamp
|> DateTime.from_unix()
|> then(fn {:ok, time} -> time end)
|> Calendar.strftime("%c")} UTC"}
class="translate-y-px"
/>
</div>
</div>
</div>
<%= if !Message.is_l2_to_l1(@message.type) do %>
<div class="custom-list-item grid-4 w-full">
Expand Down
24 changes: 22 additions & 2 deletions lib/starknet_explorer_web/live/pages/block_detail.ex
Original file line number Diff line number Diff line change
Expand Up @@ -631,7 +631,17 @@ defmodule StarknetExplorerWeb.BlockDetailLive do
</div>
<div>
<div class="list-h">Age</div>
<div><%= Utils.get_block_age_from_timestamp(@block.timestamp) %></div>
<div class="flex items-center gap-2">
<%= Utils.get_block_age_from_timestamp(@block.timestamp) %>
<CoreComponents.tooltip
id="transaction-timestamp-tooltip"
text={"#{@block.timestamp
|> DateTime.from_unix()
|> then(fn {:ok, time} -> time end)
|> Calendar.strftime("%c")} UTC"}
class="translate-y-px"
/>
</div>
</div>
</div>
<% end %>
Expand Down Expand Up @@ -904,7 +914,17 @@ defmodule StarknetExplorerWeb.BlockDetailLive do
</div>
<div>
<div class="list-h">Age</div>
<div><%= @block_age %></div>
<div class="flex items-center gap-2">
<%= @block_age %>
<CoreComponents.tooltip
id="event-timestamp-tooltip"
text={"#{event.age
|> DateTime.from_unix()
|> then(fn {:ok, time} -> time end)
|> Calendar.strftime("%c")} UTC"}
class="translate-y-px"
/>
</div>
</div>
</div>
<% end %>
Expand Down
24 changes: 22 additions & 2 deletions lib/starknet_explorer_web/live/pages/home/index.ex
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,17 @@ defmodule StarknetExplorerWeb.HomeLive.Index do
</div>
<div>
<div class="list-h">Age</div>
<%= Utils.get_block_age(block) %>
<div class="flex items-center gap-2">
<%= Utils.get_block_age(block) %>
<CoreComponents.tooltip
id="tps-tooltip"
text={"#{block.timestamp
|> DateTime.from_unix()
|> then(fn {:ok, time} -> time end)
|> Calendar.strftime("%c")} UTC"}
class="translate-y-px"
/>
</div>
</div>
</div>
<% end %>
Expand Down Expand Up @@ -264,7 +274,17 @@ defmodule StarknetExplorerWeb.HomeLive.Index do
</div>
<div>
<div class="list-h">Age</div>
<%= Utils.get_block_age_from_timestamp(transaction.block_timestamp) %>
<div class="flex items-center gap-2">
<%= Utils.get_block_age_from_timestamp(transaction.block_timestamp) %>
<CoreComponents.tooltip
id="transaction-timestamp-tooltip"
text={"#{transaction.block_timestamp
|> DateTime.from_unix()
|> then(fn {:ok, time} -> time end)
|> Calendar.strftime("%c")} UTC"}
class="translate-y-px"
/>
</div>
</div>
</div>
<% end %>
Expand Down
12 changes: 11 additions & 1 deletion lib/starknet_explorer_web/live/transaction_index_live.ex
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,17 @@ defmodule StarknetExplorerWeb.TransactionIndexLive do
</div>
<div>
<div class="list-h">Age</div>
<%= Utils.get_block_age_from_timestamp(transaction.timestamp) %>
<div class="flex items-center gap-2">
<%= Utils.get_block_age_from_timestamp(transaction.timestamp) %>
<CoreComponents.tooltip
id="transaction-timestamp-tooltip"
text={"#{transaction.timestamp
|> DateTime.from_unix()
|> then(fn {:ok, time} -> time end)
|> Calendar.strftime("%c")} UTC"}
class="translate-y-px"
/>
</div>
</div>
</div>
<% end %>
Expand Down
12 changes: 11 additions & 1 deletion lib/starknet_explorer_web/live/transaction_live.ex
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,17 @@ defmodule StarknetExplorerWeb.TransactionLive do
</div>
<div>
<div class="list-h">Age</div>
<div><%= Utils.get_block_age_from_timestamp(event.age) %></div>
<div class="flex items-center gap-2">
<%= Utils.get_block_age_from_timestamp(event.age) %>
<CoreComponents.tooltip
id="event-timestamp-tooltip"
text={"#{event.age
|> DateTime.from_unix()
|> then(fn {:ok, time} -> time end)
|> Calendar.strftime("%c")} UTC"}
class="translate-y-px"
/>
</div>
</div>
</div>
<% end %>
Expand Down

0 comments on commit 4b4a07c

Please sign in to comment.