mirror of
https://github.com/sonr-io/sonr.git
synced 2026-08-04 10:21:40 +00:00
refactor: improve address display in property details
This commit is contained in:
@@ -0,0 +1,46 @@
|
||||
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>
|
||||
}
|
||||
Reference in New Issue
Block a user