-
Notifications
You must be signed in to change notification settings - Fork 24
/
details.templ
100 lines (98 loc) · 3.87 KB
/
details.templ
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
package main
import (
"strconv"
)
templ detailsTemplate(details DetailsParams) {
<div class="-ml-4 mb-6 h-1.5 w-1/3 bg-zinc-100 dark:bg-zinc-700 sm:-ml-2.5"></div>
if details.Metadata.Npub() != "" {
<div class="mb-6 break-all leading-5">
<div class="text-sm text-strongpink">Author Public Key</div>
<span class="text-neutral-500 dark:text-neutral-300 text-[16px]">{ details.Metadata.Npub() }</span>
</div>
}
if details.Extra != nil {
@details.Extra
}
<span></span>
if len(details.SeenOn) != 0 {
<div class="mb-6 leading-5 text-neutral-500 dark:text-neutral-300 text-[16px]">
<div class="text-sm text-strongpink">Seen on</div>
for _, v := range details.SeenOn {
<a
href={ templ.URL("/r/" + v) }
class="underline-none pr-2 decoration-neutral-200 decoration-1 underline-offset-[6px] hover:underline"
>{ v }</a>
}
</div>
}
<!-- details hidden behind a toggle -->
if details.HideDetails {
<div class="mb-6 flex items-center print:hidden">
<input
type="checkbox"
id="advanced-switch"
class="hidden"
_="on load make a URLSearchParams from location.search then get it.get('details') then if it is 'yes' set my.checked to true then trigger switch on me end
on change or switch log my checked then if my checked is true
remove .hidden from #hidden-fields
tell the next <label /> from me
add .bg-strongpink .after:translate-x-full
remove .bg-gray-300 .dark:bg-zinc-800
end
otherwise
add .hidden to #hidden-fields
tell the next <label /> from me
remove .bg-strongpink .after:translate-x-full
add .bg-gray-300 .dark:bg-zinc-800
end
end
"
/>
<label for="advanced-switch" class="after:content-[''] relative mr-2 inline-block h-5 w-9 cursor-pointer rounded-full bg-gray-300 -indent-96 after:absolute after:inset-0.5 after:h-4 after:w-4 after:rounded-2xl after:bg-zinc-50 after:transition dark:bg-zinc-800 dark:after:bg-gray-700">
</label>
<label
for="advanced-switch"
class="cursor-pointer leading-4 underline text-neutral-500 dark:text-neutral-300 text-[16px] decoration-neutral-200 dark:decoration-neutral-500 decoration-1 underline-offset-[6px]"
>Show more details</label>
</div>
}
<div id="hidden-fields" class={ templ.KV("hidden", details.HideDetails) }>
<div class="mb-6 leading-5">
<div class="text-sm text-strongpink">Published at</div>
<span class="text-neutral-500 dark:text-neutral-300 text-[16px]">{ details.CreatedAt }</span>
</div>
<div class="mb-6 leading-5">
<div class="text-sm text-strongpink">Kind type</div>
<span class="text-neutral-500 dark:text-neutral-300 text-[16px]">{ strconv.Itoa(details.Kind) }</span>
if details.KindNIP != "" {
<a
href={ templ.URL("https://github.com/nostr-protocol/nips/blob/master/" + details.KindNIP + ".md") }
class="underline decoration-neutral-200 dark:decoration-neutral-500 decoration-1 underline-offset-[6px] text-neutral-500 dark:text-neutral-300 text-[16px]"
>{ details.KindDescription }</a>
}
</div>
if details.Nevent != "" {
<div class="mb-6 leading-5">
<div class="text-sm text-strongpink">Address Code</div>
<span class="text-[16px] text-neutral-500 dark:text-neutral-300">{ details.Nevent }</span>
</div>
}
<div class="-mx-4 my-8 bg-neutral-100 px-4 pb-4 leading-5 dark:bg-neutral-700">
<div
class="-mx-4 bg-neutral-300 px-4 py-1 text-neutral-100 dark:bg-neutral-800 dark:text-neutral-400"
>
Event JSON
</div>
<div class="mt-4 whitespace-pre-wrap break-all font-mono text-sm">
@templ.Raw(details.EventJSON)
</div>
</div>
if details.Nprofile != "" {
<div class="mb-6 break-all leading-5">
<div class="text-sm text-strongpink">Author Profile Code</div>
<span class="text-neutral-500 dark:text-neutral-300 text-[16px]">{ details.Nprofile }</span>
</div>
}
</div>
}