Add preference for configuring sticky navbar

Fixes #1354
This commit is contained in:
Zed
2026-02-09 17:32:03 +01:00
parent 0a6e79e626
commit 5d28bd18c6
9 changed files with 26 additions and 15 deletions

View File

@@ -66,10 +66,10 @@ settings:
routes: routes:
get "/": get "/":
resp renderMain(renderSearch(), request, cfg, themePrefs()) resp renderMain(renderSearch(), request, cfg, cookiePrefs())
get "/about": get "/about":
resp renderMain(renderAbout(), request, cfg, themePrefs()) resp renderMain(renderAbout(), request, cfg, cookiePrefs())
get "/explore": get "/explore":
redirect("/about") redirect("/about")

View File

@@ -60,6 +60,9 @@ genPrefs:
stickyProfile(checkbox, true): stickyProfile(checkbox, true):
"Make profile sidebar stick to top" "Make profile sidebar stick to top"
stickyNav(checkbox, true):
"Keep navbar fixed to top"
bidiSupport(checkbox, false): bidiSupport(checkbox, false):
"Support bidirectional text (makes clicking on tweets harder)" "Support bidirectional text (makes clicking on tweets harder)"

View File

@@ -17,13 +17,8 @@ template cookiePrefs*(): untyped {.dirty.} =
template cookiePref*(pref): untyped {.dirty.} = template cookiePref*(pref): untyped {.dirty.} =
getPref(cookies(request), pref) getPref(cookies(request), pref)
template themePrefs*(): Prefs =
var res = defaultPrefs
res.theme = cookiePref(theme)
res
template showError*(error: string; cfg: Config): string = template showError*(error: string; cfg: Config): string =
renderMain(renderError(error), request, cfg, themePrefs(), "Error") renderMain(renderError(error), request, cfg, cookiePrefs(), "Error")
template getPath*(): untyped {.dirty.} = template getPath*(): untyped {.dirty.} =
$(parseUri(request.path) ? filterParams(request.params)) $(parseUri(request.path) ? filterParams(request.params))

View File

@@ -10,7 +10,7 @@ export feature
proc createUnsupportedRouter*(cfg: Config) = proc createUnsupportedRouter*(cfg: Config) =
router unsupported: router unsupported:
template feature {.dirty.} = template feature {.dirty.} =
resp renderMain(renderFeature(), request, cfg, themePrefs()) resp renderMain(renderFeature(), request, cfg, cookiePrefs())
get "/about/feature": feature() get "/about/feature": feature()
get "/login/?@i?": feature() get "/login/?@i?": feature()

View File

@@ -115,11 +115,14 @@ ul {
display: flex; display: flex;
flex-wrap: wrap; flex-wrap: wrap;
box-sizing: border-box; box-sizing: border-box;
padding-top: 50px;
margin: auto; margin: auto;
min-height: 100vh; min-height: 100vh;
} }
body.fixed-nav .container {
padding-top: 50px;
}
.icon-container { .icon-container {
display: inline; display: inline;
} }

View File

@@ -3,7 +3,6 @@
nav { nav {
display: flex; display: flex;
align-items: center; align-items: center;
position: fixed;
background-color: var(--bg_overlays); background-color: var(--bg_overlays);
box-shadow: 0 0 4px $shadow; box-shadow: 0 0 4px $shadow;
padding: 0; padding: 0;
@@ -16,6 +15,10 @@ nav {
.icon-button button { .icon-button button {
color: var(--fg_nav); color: var(--fg_nav);
} }
body.fixed-nav & {
position: fixed;
}
} }
.inner-nav { .inner-nav {

View File

@@ -39,7 +39,11 @@
text-align: left; text-align: left;
vertical-align: top; vertical-align: top;
max-width: 32%; max-width: 32%;
top: 50px; top: 0;
body.fixed-nav & {
top: 50px;
}
} }
.profile-result { .profile-result {

View File

@@ -16,8 +16,10 @@
.main-tweet, .main-tweet,
.replies { .replies {
padding-top: 50px; body.fixed-nav & {
margin-top: -50px; padding-top: 50px;
margin-top: -50px;
}
} }
.main-tweet .tweet-content { .main-tweet .tweet-content {

View File

@@ -131,7 +131,8 @@ proc renderMain*(body: VNode; req: Request; cfg: Config; prefs=defaultPrefs;
renderHead(prefs, cfg, req, titleText, desc, video, images, banner, ogTitle, renderHead(prefs, cfg, req, titleText, desc, video, images, banner, ogTitle,
rss, twitterLink) rss, twitterLink)
body: let bodyClass = if prefs.stickyNav: "fixed-nav" else: ""
body(class=bodyClass):
renderNavbar(cfg, req, rss, twitterLink) renderNavbar(cfg, req, rss, twitterLink)
tdiv(class="container"): tdiv(class="container"):