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
|
|
@ -13,6 +13,24 @@ export property UiTpl {
|
|||
sheet: UiSheet = null # the styles of the file it was written in
|
||||
style: UiRule = null # its style="..." attribute, read as declarations
|
||||
raw: string = "" # a <style>'s text, which is not a template's
|
||||
where: string = "" # file:line, for an error
|
||||
}
|
||||
# the text being read, and where its lines start, so an element can say which line it is on
|
||||
var tp_nl: []int = new []int
|
||||
function tp_lines(src: string) -> void {
|
||||
tp_nl = new []int
|
||||
for i in 0 .. len(src) {
|
||||
if src[i] == 10 { push(tp_nl, i) }
|
||||
}
|
||||
}
|
||||
function tp_line(at: int) -> int {
|
||||
var lo = 0
|
||||
var hi = len(tp_nl)
|
||||
while lo < hi {
|
||||
let mid = (lo + hi) / 2
|
||||
if tp_nl[mid] < at { lo = mid + 1 } else { hi = mid }
|
||||
}
|
||||
return lo + 1
|
||||
}
|
||||
|
||||
function tpl_read(x: Xml, file: string) -> UiTpl {
|
||||
|
|
@ -23,6 +41,7 @@ function tpl_read(x: Xml, file: string) -> UiTpl {
|
|||
t.on_keys = new []string
|
||||
t.on_acts = new []UiAct
|
||||
t.kids = new []UiTpl
|
||||
t.where = `{file}:{tp_line(x.at)}`
|
||||
let err = new []string
|
||||
for i in 0 .. len(x.akeys) {
|
||||
let k: string = x.akeys[i]
|
||||
|
|
@ -45,7 +64,7 @@ function tpl_read(x: Xml, file: string) -> UiTpl {
|
|||
}
|
||||
let words = tpl_words(Xml.text(x))
|
||||
if len(words) > 0 and len(t.kids) == 0 { t.text = ex_text(words, err) }
|
||||
for i in 0 .. len(err) { ui_err(`{file}: <{t.tag}> {err[i]}`) }
|
||||
for i in 0 .. len(err) { ui_err(`{t.where}: <{t.tag}> {err[i]}`) }
|
||||
return t
|
||||
}
|
||||
# on-click is on-press, as a browser would have it
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue