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) (define click-count 0)
(m.mount (mount-root
root (component
`&(:view (sxml
,(lambda () (main
(m "main" (h1 "LIPS! PWA!")
(vector (button (@ (onclick (lambda ()
(m "h1" "LIPS! PWA!") (set! click-count (+ 1 click-count))
(m "button" (print click-count))))
`&(:onclick ~(format "~a clicks" click-count))))))
,(lambda () (set! click-count (+ click-count 1))))
(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))))