feat(ui): ludic.ui grows toward HTML, CSS and React (Phase 0.U1-U4)
- Natives: ui_native(tag, measure, draw) makes an element the program draws itself; ui_fire runs its on-<event> with event.value. input, select and textarea have simple defaults. - React: - keyed <each>, <let>, <provide> context through components, <fragment>; - named slots, default props on <component>; - on-mount / on-unmount; - inline text inside text elements. - CSS: - custom properties and var(); - position relative/absolute/fixed with insets and z-index; - em/rem/vw/vh and @media; - wrapping text and ellipsis, overflow; - + and ~ combinators, :nth-child(an+b), :checked, :active. - Developing: errors with file:line, ui_errors(), ui_reload() keeping state, and an inspector-style ui_dump. - view fields infer the type of a literal or a named function's result. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
parent
66a2bc2214
commit
637d07400e
39 changed files with 42012 additions and 40795 deletions
27
examples/library/ui_reload.ludic
Normal file
27
examples/library/ui_reload.ludic
Normal file
|
|
@ -0,0 +1,27 @@
|
|||
# ui_reload.ludic — a template read from disk, changed there, and read again by ui_reload: the new
|
||||
# text shows at once, and the screen's state (a counter pressed before the change) is kept.
|
||||
import "ludic.ui"
|
||||
program UiReload {
|
||||
numbers float
|
||||
view Note {
|
||||
title = "note"
|
||||
}
|
||||
const PATH: string = "build/ui_reload_example.xml"
|
||||
const V1: string = "<ui><screen name='note'><state n='{0}'/><button on-click='set n = n + 1'>{title} {n}</button></screen></ui>"
|
||||
const V2: string = "<ui><screen name='note'><state n='{0}'/><h1>{title} again {n}</h1></screen></ui>"
|
||||
function shown() -> string {
|
||||
let root: UiNode = ui_nodes("note", view_note())
|
||||
return root.children[0].text
|
||||
}
|
||||
entry {
|
||||
Fs.write_text(PATH, V1)
|
||||
ui_load(PATH)
|
||||
let root: UiNode = ui_nodes("note", view_note())
|
||||
ui_press(root.children[0])
|
||||
let before = shown()
|
||||
let same = ui_reload()
|
||||
Fs.write_text(PATH, V2)
|
||||
let changed = ui_reload()
|
||||
print(`{before} | reloaded {same} then {changed} | {shown()}`)
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue