stateful components now in a workable state; renamed .component macro to .compact which much better captures its meaning

This commit is contained in:
Andreas Rumpf 2017-06-20 00:14:54 +02:00
commit c86916e37d
10 changed files with 185 additions and 291 deletions

View file

@ -1,5 +1,5 @@
import karax, karaxdsl, vdom, kdom, components
import karax, karaxdsl, vdom, kdom, compact
const
Play = 0
@ -12,7 +12,7 @@ proc play(n: Node) {.importcpp.}
proc pause(n: Node) {.importcpp.}
proc `width=`(n: Node, w: int) {.importcpp: "#.width = #".}
proc mplayer*(id, resource: cstring): VNode {.component.} =
proc mplayer*(id, resource: cstring): VNode {.compact.} =
proc handler(ev: Event; n: VNode) =
let myVideo = document.getElementById(id)
case n.key

View file

@ -1,5 +1,5 @@
import vdom, karax, karaxdsl, jstrutils, components, localstorage
import vdom, karax, karaxdsl, jstrutils, compact, localstorage
type
Filter = enum
@ -77,7 +77,7 @@ proc toChecked(checked: bool): cstring =
proc selected(v: Filter): cstring =
(if filter == v: cstring"selected" else: cstring(nil))
proc createEntry(id: int; d: cstring; completed, selected: bool): VNode {.component.} =
proc createEntry(id: int; d: cstring; completed, selected: bool): VNode {.compact.} =
result = buildHtml(tr):
li(class=toClass(completed)):
if not selected:
@ -92,7 +92,7 @@ proc createEntry(id: int; d: cstring; completed, selected: bool): VNode {.compon
onblur = focusLost,
onkeyupenter = editEntry, value = d, setFocus)
proc makeFooter(entriesCount, completedCount: int): VNode {.component.} =
proc makeFooter(entriesCount, completedCount: int): VNode {.compact.} =
result = buildHtml(footer(class = "footer")):
span(class = "todo-count"):
strong:
@ -111,7 +111,7 @@ proc makeFooter(entriesCount, completedCount: int): VNode {.component.} =
button(class = "clear-completed", onclick = clearCompleted):
text "Clear completed (" & &completedCount & ")"
proc makeHeader(): VNode {.component.} =
proc makeHeader(): VNode {.compact.} =
result = buildHtml(header(class = "header")):
h1:
text "todos"