Update karax, cleanup input code

This commit is contained in:
Zed 2019-11-12 10:57:28 +01:00
parent a63368e871
commit a419f6c996
3 changed files with 8 additions and 11 deletions

View file

@ -17,7 +17,7 @@ requires "jester >= 0.4.3"
requires "regex >= 0.11.2" requires "regex >= 0.11.2"
requires "q >= 0.0.7" requires "q >= 0.0.7"
requires "nimcrypto >= 0.3.9" requires "nimcrypto >= 0.3.9"
requires "karax#b99a543" requires "karax#f6bda9a"
requires "sass" requires "sass"
requires "markdown" requires "markdown"

View file

@ -1,5 +1,5 @@
import strutils, strformat, xmltree import strutils, xmltree
import karax/[karaxdsl, vdom] import karax/[karaxdsl, vdom, vstyles]
import ../types, ../utils import ../types, ../utils
@ -37,7 +37,7 @@ proc linkText*(text: string; class=""): VNode =
proc hiddenField*(name, value: string): VNode = proc hiddenField*(name, value: string): VNode =
buildHtml(): buildHtml():
verbatim "<input name=\"$1\" style=\"display: none\" value=\"$2\"/>" % [name, value] input(name=name, style={display: "none"}, value=value)
proc refererField*(path: string): VNode = proc refererField*(path: string): VNode =
hiddenField("referer", path) hiddenField("referer", path)
@ -68,7 +68,7 @@ proc genInput*(pref, label, state, placeholder: string; class=""; autofocus=fals
buildHtml(tdiv(class=("pref-group pref-input " & class))): buildHtml(tdiv(class=("pref-group pref-input " & class))):
if label.len > 0: if label.len > 0:
label(`for`=pref): text label label(`for`=pref): text label
verbatim &"<input name={pref} type=\"text\" placeholder=\"{p}\" value=\"{s}\" {a}/>" input(name=pref, `type`="text", placeholder=p, value=s): text a
proc genSelect*(pref, label, state: string; options: seq[string]): VNode = proc genSelect*(pref, label, state: string; options: seq[string]): VNode =
buildHtml(tdiv(class="pref-group pref-input")): buildHtml(tdiv(class="pref-group pref-input")):
@ -82,10 +82,7 @@ proc genSelect*(pref, label, state: string; options: seq[string]): VNode =
proc genDate*(pref, state: string): VNode = proc genDate*(pref, state: string): VNode =
buildHtml(span(class="date-input")): buildHtml(span(class="date-input")):
if state.len > 0: input(name=pref, `type`="date", value=state)
verbatim &"<input name={pref} type=\"date\" value=\"{state}\"/>"
else:
verbatim &"<input name={pref} type=\"date\"/>"
icon "calendar" icon "calendar"
proc genImg*(url: string; class=""): VNode = proc genImg*(url: string; class=""): VNode =

View file

@ -100,8 +100,8 @@ proc renderVideo(video: Video; prefs: Prefs; path: string): VNode =
of m3u8, vmap: of m3u8, vmap:
video(poster=thumb, data-url=source, data-autoload="false") video(poster=thumb, data-url=source, data-autoload="false")
verbatim "<div class=\"video-overlay\" onclick=\"playVideo(this)\">" verbatim "<div class=\"video-overlay\" onclick=\"playVideo(this)\">"
verbatim "<div class=\"overlay-circle\">" tdiv(class="overlay-circle"): span(class="overlay-triangle")
verbatim "<span class=\"overlay-triangle\"</span></div></div>" verbatim "</div>"
if container.len > 0: if container.len > 0:
tdiv(class="card-content"): tdiv(class="card-content"):
h2(class="card-title"): text video.title h2(class="card-title"): text video.title