Add search button and fix unset timeline beginning

This commit is contained in:
Zed
2019-09-19 04:51:17 +02:00
parent 19659de410
commit 70c42dd05a
6 changed files with 11 additions and 7 deletions

View File

@@ -14,6 +14,7 @@ proc renderNavbar*(title, path, rss: string): VNode =
a(href="/"): img(class="site-logo", src="/logo.png")
tdiv(class="nav-item right"):
icon "search", title="Search", href="/search"
if rss.len > 0:
icon "rss", title="RSS Feed", href=rss
icon "info-circled", title="About", href="/about"

View File

@@ -65,13 +65,14 @@ proc genCheckbox*(pref, label: string; state: bool): VNode =
else: input(name=pref, `type`="checkbox")
span(class="checkbox")
proc genInput*(pref, label, state, placeholder: string; class=""): VNode =
proc genInput*(pref, label, state, placeholder: string; class=""; autofocus=false): VNode =
let s = xmltree.escape(state)
let p = xmltree.escape(placeholder)
let a = if autofocus: "autofocus" else: ""
buildHtml(tdiv(class=("pref-group pref-input " & class))):
if label.len > 0:
label(`for`=pref): text label
verbatim &"<input name={pref} type=\"text\" placeholder=\"{p}\" value=\"{s}\"/>"
verbatim &"<input name={pref} type=\"text\" placeholder=\"{p}\" value=\"{s}\" {a}/>"
proc genSelect*(pref, label, state: string; options: seq[string]): VNode =
buildHtml(tdiv(class="pref-group")):

View File

@@ -60,7 +60,8 @@ proc renderSearchPanel*(query: Query): VNode =
let action = if user.len > 0: &"/{user}/search" else: "/search"
buildHtml(form(`method`="get", action=action, class="search-field")):
hiddenField("kind", "custom")
genInput("text", "", query.text, "Enter search...", class="pref-inline")
genInput("text", "", query.text, "Enter search...",
class="pref-inline", autofocus=true)
button(`type`="submit"): icon "search"
input(id="search-panel-toggle", `type`="checkbox")
label(`for`="search-panel-toggle"):