diff --git a/app.scm b/app.scm index 096294a..e595078 100644 --- a/app.scm +++ b/app.scm @@ -1,15 +1,13 @@ -(define root document.body) +(load "lib/mithril.scm") (define click-count 0) -(m.mount - root - `&(:view - ,(lambda () - (m "main" - (vector - (m "h1" "LIPS! PWA!") - (m "button" - `&(:onclick - ,(lambda () (set! click-count (+ click-count 1)))) - (format "~a clicks" click-count))))))) +(mount-root + (component + (sxml + (main + (h1 "LIPS! PWA!") + (button (@ (onclick (lambda () + (set! click-count (+ 1 click-count)) + (print click-count)))) + ~(format "~a clicks" click-count)))))) diff --git a/lib/mithril.scm b/lib/mithril.scm new file mode 100644 index 0000000..7d15a5a --- /dev/null +++ b/lib/mithril.scm @@ -0,0 +1,11 @@ +(pragma->sxml m) + +(define (mount-root component) + (m.mount + document.body + component)) + +(define-macro (component view) + `(object + :view + (lambda () (,@view))))