Expand search panel if any options active

This commit is contained in:
Zed 2019-09-19 23:47:05 +02:00
parent 62df60be78
commit 1a356bc51d

View file

@ -1,4 +1,4 @@
import strutils, strformat, unicode, tables
import strutils, strformat, sequtils, unicode, tables
import karax/[karaxdsl, vdom, vstyles]
import renderutils, timeline
@ -55,6 +55,10 @@ proc renderSearchTabs*(query: Query): VNode =
q.kind = users
a(href=genQueryUrl(q)): text "Users"
proc isPanelOpen(q: Query): bool =
q.filters.len > 0 or q.excludes.len > 0 or
@[q.near, q.until, q.since].anyIt(it.len > 0)
proc renderSearchPanel*(query: Query): VNode =
let user = query.fromUser.join(",")
let action = if user.len > 0: &"/{user}/search" else: "/search"
@ -63,6 +67,9 @@ proc renderSearchPanel*(query: Query): VNode =
genInput("text", "", query.text, "Enter search...",
class="pref-inline", autofocus=true)
button(`type`="submit"): icon "search"
if isPanelOpen(query):
input(id="search-panel-toggle", `type`="checkbox", checked="")
else:
input(id="search-panel-toggle", `type`="checkbox")
label(`for`="search-panel-toggle"):
icon "down"