diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml
new file mode 100644
index 0000000..5e6c415
--- /dev/null
+++ b/.github/workflows/ci.yml
@@ -0,0 +1,31 @@
+# This is a basic workflow to help you get started with Actions
+
+name: CI
+
+# Controls when the action will run.
+on:
+ # Triggers the workflow on push or pull request events but only for the master branch
+ push:
+ branches: [ master ]
+ pull_request:
+ branches: [ master ]
+
+ # Allows you to run this workflow manually from the Actions tab
+ workflow_dispatch:
+
+# A workflow run is made up of one or more jobs that can run sequentially or in parallel
+jobs:
+ # This workflow contains a single job called "build"
+ build:
+ # The type of runner that the job will run on
+ runs-on: ubuntu-latest
+ container: nimlang/nim
+ # Steps represent a sequence of tasks that will be executed as part of the job
+ steps:
+ # Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
+ - uses: actions/checkout@v2
+ # Runs a single command using the runners shell
+ - name: Tests
+ run: |
+ nimble develop -y
+ nim c -r tests/tester.nim
diff --git a/.gitignore b/.gitignore
index acb4ec1..842e140 100644
--- a/.gitignore
+++ b/.gitignore
@@ -3,3 +3,5 @@ nimcache/
karax/tools/karun
*.code-workspace
*.exe
+app.js
+app.html
diff --git a/.travis.yml b/.travis.yml
deleted file mode 100644
index 6e03ea9..0000000
--- a/.travis.yml
+++ /dev/null
@@ -1,20 +0,0 @@
-sudo: false
-language: c
-os: linux
-install:
- - git clone https://github.com/nim-lang/nim
- - cd nim
- - git clone --depth 1 https://github.com/nim-lang/csources.git
- - cd csources
- - sh build.sh
- - cd ../
- - bin/nim c koch
- - ./koch boot -d:release
- - ./koch tools
- - cd ..
-before_script:
- - set -e
- - export PATH=$(pwd)/nim/bin:$(pwd):$PATH
-script:
- - nimble develop
- - nim c -r tests/tester.nim
diff --git a/docs/docs.rst b/docs/docs.rst
index 8298ba9..3eec1a4 100644
--- a/docs/docs.rst
+++ b/docs/docs.rst
@@ -10,17 +10,17 @@ and some extensions that allow for an efficient component system.
These extensions are:
``VNodeKind.int``
- The node havs a single integer field.
+ The node has a single integer field.
``VNodeKind.bool``
The node has a single boolean field.
-``VNodeKint.vthunk``
+``VNodeKind.vthunk``
The node is a `virtual thunk`:idx:. This means there is a
function attached to it that produces the ``VNode`` structure
on demand.
-``VNodeKint.dthunk``
+``VNodeKind.dthunk``
The node is a `DOM thunk`:idx:. This means there is a
function attached to it that produces the ``Node`` DOM structure
on demand.
@@ -53,6 +53,6 @@ Event system
Karax does not abstract over the event system the DOM offers much: The same
``Event`` structure is used. Every callback has the
-signature ``proc (ev: Event; n: VNode)``.
+signature ``proc (ev: Event; n: VNode)`` or empty ``proc ()``.
diff --git a/examples/button.nim b/examples/button.nim
index bd49dc3..d86fa82 100644
--- a/examples/button.nim
+++ b/examples/button.nim
@@ -1,4 +1,3 @@
-
include karax / prelude
var lines: seq[kstring] = @[]
diff --git a/examples/carousel/carousel.html b/examples/carousel/carousel.html
index 979dd38..500e73a 100644
--- a/examples/carousel/carousel.html
+++ b/examples/carousel/carousel.html
@@ -1,15 +1,15 @@
-
- Carousel app
-
+
+ Carousel app
+
-
+
-
+
-
+
-
+
diff --git a/examples/hellostyle.nim b/examples/hellostyle.nim
new file mode 100644
index 0000000..716c2f0
--- /dev/null
+++ b/examples/hellostyle.nim
@@ -0,0 +1,17 @@
+include karax / prelude
+import karax / vstyles
+
+proc createDom(): VNode =
+ result = buildHtml(tdiv):
+ tdiv(style = style(StyleAttr.color, "red".cstring)):
+ text "red"
+ tdiv(style = style(StyleAttr.color, "blue")):
+ text "blue"
+ # explicit `kstring` required for varargs overload
+ tdiv(style = style((fontStyle, "italic".kstring), (color, "orange".kstring))):
+ text "italic orange"
+ # can use a string directly
+ tdiv(style = "font-style: oblique; color: pink".toCss):
+ text "oblique pink"
+
+setRenderer createDom
diff --git a/examples/hellouniverse.nim b/examples/hellouniverse.nim
index 9d6ebc6..8343d07 100644
--- a/examples/hellouniverse.nim
+++ b/examples/hellouniverse.nim
@@ -1,10 +1,9 @@
-
include karax / prelude
import random
proc createDom(): VNode =
result = buildHtml(tdiv):
- if random(100) <= 50:
+ if rand(100) <= 50:
text "Hello World!"
else:
text "Hello Universe"
diff --git a/examples/login.nim b/examples/login.nim
index 6cc38b1..0350e23 100644
--- a/examples/login.nim
+++ b/examples/login.nim
@@ -1,6 +1,5 @@
-
include karax / prelude
-from future import `=>`
+from sugar import `=>`
import karax / errors
proc loginField(desc, field, class: kstring;
@@ -18,7 +17,7 @@ const
proc validateNotEmpty(field: kstring): proc () =
result = proc () =
let x = getVNodeById(field)
- if x.text.isNil or x.text == "":
+ if x.text == "":
errors.setError(field, field & " must not be empty")
else:
errors.setError(field, "")
@@ -28,7 +27,7 @@ var loggedIn: bool
proc loginDialog(): VNode =
result = buildHtml(tdiv):
if not loggedIn:
- loginField("Name :", username, "input", validateNotEmpty)
+ loginField("Name: ", username, "input", validateNotEmpty)
loginField("Password: ", password, "password", validateNotEmpty)
button(onclick = () => (loggedIn = true), disabled = errors.disableOnError()):
text "Login"
diff --git a/examples/mediaplayer/playerapp.html b/examples/mediaplayer/playerapp.html
index 9e076e6..a45a2e8 100644
--- a/examples/mediaplayer/playerapp.html
+++ b/examples/mediaplayer/playerapp.html
@@ -1,15 +1,15 @@
-
- Player app
-
+
+ Player app
+
-
+
-
+
-
+
-
+
diff --git a/examples/scrollapp/scrollapp.html b/examples/scrollapp/scrollapp.html
index 1ff8b1b..44d657e 100644
--- a/examples/scrollapp/scrollapp.html
+++ b/examples/scrollapp/scrollapp.html
@@ -1,15 +1,15 @@
-
- Todo app
-
+
+ Todo app
+
-
+
-
+
-
+
-
+
diff --git a/examples/todoapp/todoapp.html b/examples/todoapp/todoapp.html
index 488a3bf..ab3daa7 100644
--- a/examples/todoapp/todoapp.html
+++ b/examples/todoapp/todoapp.html
@@ -1,16 +1,16 @@
-
- Todo app
-
-
+
+ Todo app
+
+
-
+
-
+
-
+
-
+
diff --git a/examples/todoapp/todoapp.nim b/examples/todoapp/todoapp.nim
index b944de5..e3720fd 100644
--- a/examples/todoapp/todoapp.nim
+++ b/examples/todoapp/todoapp.nim
@@ -9,7 +9,7 @@ var
selectedEntry = -1
filter: Filter
entriesLen: int
-
+ doneswitch = true
const
contentSuffix = cstring"content"
completedSuffix = cstring"completed"
@@ -62,9 +62,9 @@ proc toggleEntry(ev: Event; n: VNode) =
markAsCompleted(id, not isCompleted(id))
proc onAllDone(ev: Event; n: VNode) =
- clear()
- selectedEntry = -1
-
+ for i in 0..
-
+