Figure out sxml (this took longer than I'd like to admit)

This commit is contained in:
BirDt_ 2026-07-10 21:39:51 +08:00
parent 85e9e1f5f1
commit 2ffabddba4
2 changed files with 21 additions and 12 deletions

22
app.scm
View file

@ -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))))))

11
lib/mithril.scm Normal file
View file

@ -0,0 +1,11 @@
(pragma->sxml m)
(define (mount-root component)
(m.mount
document.body
component))
(define-macro (component view)
`(object
:view
(lambda () (,@view))))