Skip to content

Commit

Permalink
Fix tx links
Browse files Browse the repository at this point in the history
  • Loading branch information
heppu committed Jun 3, 2024
1 parent 601992e commit 37cf740
Show file tree
Hide file tree
Showing 3 changed files with 58 additions and 14 deletions.
8 changes: 8 additions & 0 deletions api/assets/style.css
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,10 @@
font-family: Inter;
}

a {
all: unset;
}

body {
text-transform: uppercase;
margin: 0;
Expand Down Expand Up @@ -1030,6 +1034,10 @@ body.dark .tx-id-block-copy svg path {
min-width: 0px;
}

.tr>.end {
display: none;
}

.tx-id-block-value {
margin-bottom: 10px;
}
Expand Down
24 changes: 17 additions & 7 deletions api/templates/index.templ
Original file line number Diff line number Diff line change
Expand Up @@ -99,8 +99,8 @@ templ Table(events []model.Event, query url.Values) {
}

templ Row(e model.Event) {
<div id={ e.TxID } class="tr" hx-get={ "/tx/" + e.TxID } hx-trigger="click" sse-swap={ e.TxID } hx-swap="outerHTML">
<div class="left">
<div id={ e.TxID } class="tr" sse-swap={ e.TxID } hx-swap="outerHTML">
<a class="left" { txLinkAttrs(e.TxID)... }>
<div class="td">
<div class="mobile-label">State</div>
<div>
Expand All @@ -111,8 +111,8 @@ templ Row(e model.Event) {
<div class="mobile-label">Transaction ID</div>
<div>{ e.TxID }</div>
</div>
</div>
<div class="right">
</a>
<a class="right" { txLinkAttrs(e.TxID)... }>
<div class="td">
<div class="mobile-label">Prover ID</div>
<div>
Expand All @@ -128,10 +128,10 @@ templ Row(e model.Event) {
<span class="datetime">{ e.Timestamp.Format("03:04 PM, 02/01/06") }</span>
</div>
</div>
</div>
<div class="end">
</a>
<a class="end" { txLinkAttrs(e.TxID)... }>
<span class="arrow">→</span>
</div>
</a>
</div>
}

Expand Down Expand Up @@ -332,3 +332,13 @@ func formatDuration(d time.Duration) string {
second := int(d.Seconds()) % 60
return fmt.Sprintf("%02dH:%02dM:%02dS", hour, minute, second)
}

func txLinkAttrs(txID string) templ.Attributes {
return templ.Attributes{
"href": "/tx/" + txID,
"hx-trigger": "click",
"hx-get": "/tx/" + txID,
"hx-swap": "outerHTML",
"hx-target": "#table",
}
}
40 changes: 33 additions & 7 deletions api/templates/index_templ.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 37cf740

Please sign in to comment.