- 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>
23 lines
1.1 KiB
Text
23 lines
1.1 KiB
Text
# attr_place.ludic - position and its insets, z-index, overflow, white-space and text-overflow
|
|
function el_place_prop(n: UiNode, key: string, v: Val) -> bool {
|
|
let s = vl_text(v)
|
|
if key == "position" {
|
|
n.pos = 0
|
|
if s == "relative" { n.pos = 1 }
|
|
if s == "absolute" { n.pos = 2 }
|
|
if s == "fixed" { n.pos = 3 }
|
|
} else if key == "top" { n.top = el_inset(v) } else if key == "right" { n.right = el_inset(v) } else if key == "bottom" { n.bottom = el_inset(v) } else if key == "left" { n.left = el_inset(v) } else if key == "inset" {
|
|
el_sides(v)
|
|
n.top = el_s0
|
|
n.right = el_s1
|
|
n.bottom = el_s2
|
|
n.left = el_s3
|
|
} else if key == "z-index" { n.z = int(el_num(s)) } else if key == "overflow" or key == "overflow-y" {
|
|
if (s == "auto" or s == "scroll" or s == "hidden") and n.kind == UI_BOX { n.kind = UI_SCROLL }
|
|
} else if key == "white-space" { n.nowrap = s == "nowrap" or s == "pre" } else if key == "text-overflow" { n.ellipsis = s == "ellipsis" } else { return false }
|
|
return true
|
|
}
|
|
function el_inset(v: Val) -> float {
|
|
if vl_text(v) == "auto" { return UI_AUTO }
|
|
return el_len(v)
|
|
}
|