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
packages/ludic.ui/reload.ludic
Normal file
27
packages/ludic.ui/reload.ludic
Normal file
|
|
@ -0,0 +1,27 @@
|
|||
# reload.ludic - a developer's templates and stylesheets read again when they change on disk: every
|
||||
# file is re-read in the order it was first loaded (so an import is there before its importer), and
|
||||
# the screens' state is kept, as React's fast refresh keeps it. True when anything changed.
|
||||
export function ui_reload() -> bool {
|
||||
var changed = false
|
||||
for i in 0 .. len(lib_files) {
|
||||
let f = lib_files[i]
|
||||
if f.disk and lib_text(f.path) != f.src { changed = true }
|
||||
}
|
||||
if not changed { return false }
|
||||
let old = lib_files
|
||||
lib_files = new []UiFile
|
||||
lib_screen_names = new []string
|
||||
lib_screens = new []UiTpl
|
||||
ui_errs = new []string
|
||||
for i in 0 .. len(old) {
|
||||
let f = old[i]
|
||||
var have = false
|
||||
for k in 0 .. len(lib_files) {
|
||||
if lib_files[k].path == f.path { have = true }
|
||||
}
|
||||
if have { continue }
|
||||
if f.disk { lib_file(f.path) } else { ui_load_text(f.src, f.path) }
|
||||
}
|
||||
print(`ui: templates reloaded`)
|
||||
return true
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue