mirror of
https://github.com/sonr-io/sonr.git
synced 2026-08-02 17:31:39 +00:00
47 lines
1.1 KiB
Templ
47 lines
1.1 KiB
Templ
package details
|
|
|
|
import "strings"
|
|
|
|
// Helper function to shorten address
|
|
func shortenAddress(address string) string {
|
|
if len(address) <= 12 {
|
|
return address
|
|
}
|
|
return address[:8] + "..." + address[len(address)-4:]
|
|
}
|
|
|
|
func formatValue(value string) string {
|
|
if value == "" {
|
|
return "N/A"
|
|
}
|
|
return value
|
|
}
|
|
|
|
templ Property(name string, value string, icon string) {
|
|
<div class="flex items-center w-full gap-4">
|
|
<div class="flex items-center gap-1">
|
|
<sl-icon name={ icon } library="sonr"></sl-icon>
|
|
<span class="min-w-[64px]">{ name }</span>
|
|
</div>
|
|
<div class="w-[40px] border-b border-dotted border-gray-400"></div>
|
|
<span>
|
|
<sl-badge variant="neutral" class="ml-2 text-right flex-grow" pill>
|
|
<p class="font-mono">
|
|
if strings.HasPrefix(strings.ToLower(name), "address") {
|
|
{ shortenAddress(value) }
|
|
<sl-copy-button value={ value }></sl-copy-button>
|
|
} else {
|
|
{ formatValue(value) }
|
|
}
|
|
</p>
|
|
</sl-badge>
|
|
</span>
|
|
</div>
|
|
}
|
|
|
|
templ PropertyList() {
|
|
<div class="flex flex-col space-y-4 w-full">
|
|
{ children... }
|
|
</div>
|
|
}
|