@@ -22,10 +22,11 @@ templ Layout(loggedUser nostr.PubKey, currentPage string) {
2222 " --header-transparency:" + global.Settings .Theme .HeaderTransparency + " % ;" +
2323 " --primary-font:" + global.Settings .Theme .PrimaryFont + " ;" +
2424 " --secondary-font:" + global.Settings .Theme .SecondaryFont + " ;" ) }
25+ class =" themed"
2526 } else {
2627 x-data =" { darkMode: localStorage.getItem('darkMode') === 'true' }"
2728 x-init =" $watch('darkMode', val => localStorage.setItem('darkMode', val))"
28- :class =" { 'dark': darkMode }"
29+ :class =" { 'unthemed': true, ' dark': darkMode, 'light': ! darkMode }"
2930 }
3031 >
3132 <head >
@@ -55,16 +56,10 @@ templ Layout(loggedUser nostr.PubKey, currentPage string) {
5556 <script src =" https://cdn.jsdelivr.net/npm/nostr-web-components@0.0.12/dist/nostr-name.js" ></script >
5657 </head >
5758 <body
58- class ={ " min-h-screen flex flex-col" ,
59- templ.KV (" bg-[var(--bg-color)] text-[var(--base-color)] font-[family-name:var(--secondary-font)]" , global.Settings .HasThemeColors ()),
60- templ.KV (" bg-stone-50 dark:bg-stone-900 text-stone-900 dark:text-stone-100" , !global.Settings .HasThemeColors ()) }
59+ class =" min-h-screen flex flex-col themed:bg-[var(--bg-color)] themed:text-[var(--base-color)] themed:font-[family-name:var(--secondary-font)] light:bg-stone-50 dark:bg-stone-900 light:text-stone-900 dark:text-stone-100"
6160 >
6261 <header
63- class ={
64- " backdrop-blur-sm sticky top-0 z-50 shadow-sm border-b border-stone-300" ,
65- templ.KV (" bg-[rgb(from_var(--secondary-bg-color)_r_g_b_/_var(--header-transparency))]" , global.Settings .HasThemeColors ()),
66- templ.KV (" bg-white/60 dark:bg-stone-800/90" , !global.Settings .HasThemeColors ()),
67- }
62+ class =" backdrop-blur-sm sticky top-0 z-50 shadow-sm border-b border-stone-300 themed:bg-[rgb(from_var(--secondary-bg-color)_r_g_b_/_var(--header-transparency))] light:bg-white/60 dark:bg-stone-800/90"
6863 >
6964 <div class =" max-w-7xl mx-auto px-4 sm:px-6 lg:px-8" >
7065 <div class =" flex items-center justify-between py-6" >
@@ -76,11 +71,7 @@ templ Layout(loggedUser nostr.PubKey, currentPage string) {
7671 <div class =" flex-1 mr-auto" >
7772 <a href =" /" >
7873 <h1
79- class ={
80- " font-bold text-3xl font-[family-name:var(--primary-font)]" ,
81- templ.KV (" text-[var(--accent-color)]" , global.Settings .HasThemeColors ()),
82- templ.KV (" text-blue-600 dark:text-blue-400" , !global.Settings .HasThemeColors ()),
83- }
74+ class =" font-bold text-3xl font-[family-name:var(--primary-font)] themed:text-[var(--accent-color)] light:text-blue-600 dark:text-blue-400"
8475 >{ global.Settings .RelayName }</h1 >
8576 </a >
8677 if global.Settings .RelayDescription != " " {
@@ -92,53 +83,30 @@ templ Layout(loggedUser nostr.PubKey, currentPage string) {
9283 }
9384 </div >
9485 if !global.Settings .HasThemeColors () {
95- <button @click =" darkMode = !darkMode" class =" ml-auto p-2.5 rounded-lg bg-stone-100 hover:bg-stone-200 dark:bg-stone-700 dark:hover:bg-stone-600" aria-label =" Toggle dark mode" >
86+ <button @click =" darkMode = !darkMode" class =" cursor-pointer ml-auto p-2.5 rounded-lg bg-stone-100 hover:bg-stone-200 dark:bg-stone-700 dark:hover:bg-stone-600" aria-label =" toggle dark mode" >
9687 <svg x-show =" darkMode" class =" w-5 h-5" fill =" none" viewBox =" 0 0 24 24" stroke =" currentColor" ><path stroke-linecap =" round" stroke-linejoin =" round" stroke-width =" 2" d =" M20.354 15.354A9 9 0 018.646 3.646 9.003 9.003 0 0012 21a9.003 9.003 0 008.354-5.646z" ></path ></svg >
9788 <svg x-show =" !darkMode" class =" w-5 h-5" fill =" none" viewBox =" 0 0 24 24" stroke =" currentColor" ><path stroke-linecap =" round" stroke-linejoin =" round" stroke-width =" 2" d =" M12 3v1m0 16v1m9-9h-1M4 12H3m15.364 6.364l-.707-.707M6.343 6.343l-.707-.707m12.728 0l-.707.707M6.343 17.657l-.707.707M16 12a4 4 0 11-8 0 4 4 0 018 0z" ></path ></svg >
9889 </button >
9990 }
10091 </div >
10192 <nav class =" flex flex-wrap gap-2 items-center justify-center pb-4" >
102- <a
103- href =" /"
104- class ={
105- " rounded-lg px-4 py-2 font-medium" ,
106- templ.KV (" text-[var(--text-color)]" , global.Settings .HasThemeColors ()),
107- templ.KV (" hover:bg-stone-100 dark:hover:bg-stone-700" , !global.Settings .HasThemeColors ()),
108- templ.KV (" bg-stone-200 dark:bg-stone-700" , currentPage == " invite-tree" ),
109- }
110- >invite tree</a >
111- <a
112- class ={
113- " rounded-lg px-4 py-2 font-medium" ,
114- templ.KV (" text-[var(--text-color)]" , global.Settings .HasThemeColors ()),
115- templ.KV (" hover:bg-stone-100 dark:hover:bg-stone-700" , !global.Settings .HasThemeColors ()),
116- }
117- target =" _blank"
118- href ={ global.Settings .BrowseURI }
119- x-init =" $el.href = $el.href.replace('__URL__', encodeURIComponent(location.href.replace('http', 'ws').split('/').slice(0, 3).join('/')))"
120- >browse</a >
93+ @ NavLink (" /" , currentPage == " invite-tree" ) {
94+ invite tree
95+ }
96+ @ NavLink (global.Settings .BrowseURI , false ) {
97+ <span x-init =" $el.parentNode.setAttribute('href', $el.parentNode.href.replace('__URL__', encodeURIComponent(location.href.replace('http', 'ws').split('/').slice(0, 3).join('/')))); $el.parentNode.setAttribute('target', '_blank')" >
98+ browse
99+ </span >
100+ }
121101 if global.Settings .Groups .Enabled || pyramid.IsRoot (loggedUser) {
122- <a
123- href =" /groups/"
124- class ={
125- " rounded-lg px-4 py-2 font-medium" ,
126- templ.KV (" text-[var(--text-color)]" , global.Settings .HasThemeColors ()),
127- templ.KV (" hover:bg-stone-100 dark:hover:bg-stone-700" , !global.Settings .HasThemeColors ()),
128- templ.KV (" bg-stone-200 dark:bg-stone-700" , currentPage == " groups" ),
129- }
130- >groups</a >
102+ @ NavLink (" /groups/" , currentPage == " groups" ) {
103+ groups
104+ }
131105 }
132106 if global.Settings .Grasp .Enabled || pyramid.IsRoot (loggedUser) {
133- <a
134- href =" /grasp/"
135- class ={
136- " rounded-lg px-4 py-2 font-medium" ,
137- templ.KV (" text-[var(--text-color)]" , global.Settings .HasThemeColors ()),
138- templ.KV (" hover:bg-stone-100 dark:hover:bg-stone-700" , !global.Settings .HasThemeColors ()),
139- templ.KV (" bg-stone-200 dark:bg-stone-700" , currentPage == " grasp" ),
140- }
141- >grasp</a >
107+ @ NavLink (" /grasp/" , currentPage == " grasp" ) {
108+ grasp
109+ }
142110 }
143111 <div
144112 x-data =" { open: false }"
@@ -147,11 +115,9 @@ templ Layout(loggedUser nostr.PubKey, currentPage string) {
147115 >
148116 <button
149117 @click =" open = !open"
150- class ={ " rounded-lg px-4 py-2 font-medium flex items-center gap-1" ,
151- templ.KV (" text-[var(--text-color)]" , global.Settings .HasThemeColors ()),
152- templ.KV (" hover:bg-stone-100 dark:hover:bg-stone-700" , !global.Settings .HasThemeColors ()),
153- templ.KV (" bg-stone-200 dark:bg-stone-700" , currentPage == " favorites" || currentPage == " uppermost" || currentPage == " popular" || currentPage == " inbox" || currentPage == " internal" || currentPage == " moderated" ),
154- templ.KV (" hidden" , !pyramid.IsRoot (loggedUser) && !global.Settings .Favorites .Enabled && !global.Settings .Uppermost .Enabled && !global.Settings .Popular .Enabled && !global.Settings .Inbox .Enabled && !(global.Settings .Internal .Enabled && pyramid.IsMember (loggedUser)) && !global.Settings .Moderated .Enabled ) }
118+ class ={ " cursor-pointer rounded-lg px-4 py-2 font-medium flex items-center gap-1 themed:text-[var(--text-color)] themed:hover:bg-[rgb(from_var(--text-color)_r_g_b_/10% )] light:hover:bg-stone-100 dark:hover:bg-stone-700" ,
119+ templ.KV (" themed:bg-[rgb(from_var(--text-color)_r_g_b_/15% )] light:bg-stone-200 dark:bg-stone-700" , currentPage == " favorites" || currentPage == " uppermost" || currentPage == " popular" || currentPage == " inbox" || currentPage == " internal" || currentPage == " moderated" ),
120+ templ.KV (" hidden" , !pyramid.IsRoot (loggedUser) && !global.Settings .Favorites .Enabled && !global.Settings .Uppermost .Enabled && !global.Settings .Popular .Enabled && !global.Settings .Inbox .Enabled && !(global.Settings .Internal .Enabled && pyramid.IsMember (loggedUser)) && !global.Settings .Moderated .Enabled ) }
155121 >
156122 switch currentPage {
157123 case " favorites" :
@@ -203,45 +169,27 @@ case "uppermost":
203169}
204170 }}
205171 if enabled || pyramid.IsRoot (loggedUser) {
206- <a
207- href ={ templ.SafeURL (" /" + path + " /" ) }
208- class ={
209- " block px-4 py-2 text-sm" ,
210- templ.KV (" text-[var(--text-color)]" , global.Settings .HasThemeColors ()),
211- templ.KV (" hover:bg-stone-100 dark:hover:bg-stone-700" , !global.Settings .HasThemeColors ()),
212- templ.KV (" bg-stone-100 dark:bg-stone-700" , currentPage == page),
213- }
214- >
172+ @ NavLink (" /" +path+" /" , currentPage == page) {
215173 { path }
216174 if path != page {
217175 <span class =" text-sm opacity-70" > ({ page })</span >
218176 }
219- </ a >
177+ }
220178 }
221179 }
222180 </div >
223181 </div >
224182 if pyramid.IsRoot (loggedUser) {
225- <a
226- href =" /settings"
227- class ={
228- " rounded-lg px-4 py-2 font-medium" ,
229- templ.KV (" text-[var(--text-color)]" , global.Settings .HasThemeColors ()),
230- templ.KV (" hover:bg-stone-100 dark:hover:bg-stone-700" , !global.Settings .HasThemeColors ()),
231- templ.KV (" bg-stone-200 dark:bg-stone-700" , currentPage == " settings" ),
232- }
233- >settings</a >
183+ @ NavLink (" /settings" , currentPage == " settings" ) {
184+ settings
185+ }
234186 }
235187 if loggedUser != nostr.ZeroPK {
236188 <div class =" flex items-center gap-3" >
237189 <div x-data =" authButton()" >
238190 <button
239191 @click =" handleAuth($event)"
240- class ={
241- " px-4 py-2 rounded-lg font-semibold text-white shadow-md hover:shadow-lg" ,
242- templ.KV (" bg-[var(--accent-color)]" , global.Settings .HasThemeColors ()),
243- templ.KV (" bg-blue-500 hover:bg-blue-600" , !global.Settings .HasThemeColors ()),
244- }
192+ class =" px-4 py-2 rounded-lg font-semibold text-white shadow-md hover:shadow-lg themed:bg-[var(--accent-color)] light:bg-blue-500 hover:bg-blue-600"
245193 >
246194 logout
247195 </button >
@@ -262,11 +210,7 @@ case "uppermost":
262210 <div x-data =" authButton()" >
263211 <button
264212 @click =" handleAuth($event)"
265- class ={
266- " px-4 py-2 rounded-lg font-semibold text-white shadow-md hover:shadow-lg" ,
267- templ.KV (" bg-[var(--accent-color)]" , global.Settings .HasThemeColors ()),
268- templ.KV (" bg-blue-500 hover:bg-blue-600" , !global.Settings .HasThemeColors ()),
269- }
213+ class =" px-4 py-2 rounded-lg font-semibold text-white shadow-md hover:shadow-lg themed:bg-[var(--accent-color)] light:bg-blue-500 hover:bg-blue-600"
270214 >
271215 login
272216 </button >
@@ -279,9 +223,7 @@ case "uppermost":
279223 { children... }
280224 </main >
281225 <footer
282- class ={ " mt-auto backdrop-blur-sm" ,
283- templ.KV (" bg-[rgb(from_var(--secondary-bg-color)_r_g_b_/_var(--header-transparency))]" , global.Settings .HasThemeColors ()),
284- templ.KV (" bg-white/50 dark:bg-stone-800/50" , !global.Settings .HasThemeColors ()) }
226+ class =" mt-auto backdrop-blur-sm themed:bg-[rgb(from_var(--secondary-bg-color)_r_g_b_/_var(--header-transparency))] light:bg-white/50 dark:bg-stone-800/50"
285227 >
286228 <div class =" max-w-7xl mx-auto px-4 py-6 text-center" >
287229 <p class =" text-sm" >
0 commit comments