From cdbb6f1f42896f00ec04a92f902b97725549cdb8 Mon Sep 17 00:00:00 2001 From: Gabor Kiss-Vamosi Date: Thu, 6 Aug 2026 16:09:22 +0200 Subject: [PATCH 1/6] basic docs, needs review --- AGENTS.md | 66 +++++++++++++++-- docs/syntax/animations.mdx | 43 +++++++++++ docs/syntax/data-binding.mdx | 93 +++++++++++++++++++++++ docs/syntax/evaluate.mdx | 68 ++++++++++++++--- docs/syntax/index.mdx | 6 ++ docs/syntax/meta.json | 1 + docs/syntax/styles.mdx | 79 ++++++++++++++++++++ docs/syntax/variants.mdx | 138 +++++++++++++++++++++++++++++++++++ 8 files changed, 480 insertions(+), 14 deletions(-) create mode 100644 docs/syntax/variants.mdx diff --git a/AGENTS.md b/AGENTS.md index df3a4009..577eaca6 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -62,15 +62,16 @@ my_project/ ``` -### The three sigils +### The sigils | Prefix | Means | Example | | --- | --- | --- | | `$name` | An `` property of this element | `` | | `#name` | A constant from `` or `globals.xml` | `pad="#space_md"` | | `{ ... }` | An expression, evaluated once at creation | `hidden="{!icon}"` | +| `@{ ... }` | The same expression as a binding: re-evaluated whenever a subject or variant in it changes | `hidden="@{subject_count == 0}"` | -Inside `{ }` you write bare identifiers, no `$` or `#`. +Inside `{ }` and `@{ }` you write bare identifiers, no `$` or `#`. ### `view` and `extends` @@ -123,6 +124,12 @@ Three ways, in order of preference: + + + + + + ``` Prefix style names with `style_`. Selectors combine parts and states with `|`. @@ -140,6 +147,19 @@ But constants can be used: Pass the property to a *local* style property instead: ``. +A `` child animates a style's properties on state changes. It animates *into* the state of the style holding it, so for both directions add one to the default style too: + +```xml + + +``` + +One transition per style, numeric and color properties only, and `` never animates. + ## Data binding Subjects are the interface between the UI and the application. Define them in `globals.xml`: @@ -161,6 +181,10 @@ Only `int`, `string` and `float` are supported. + + + + ``` `bind_flag_*` takes a `flag`, `bind_state_*` takes a `state`. Both come in `_eq`, `_not_eq`, `_gt`, `_ge`, `_lt`, `_le`. The `lv_obj-` prefix is optional. @@ -168,8 +192,35 @@ Only `int`, `string` and `float` are supported. States: `default`, `checked`, `focused`, `focus_key`, `edited`, `hovered`, `pressed`, `scrolled`, `disabled`. Common flags: `hidden`, `clickable`, `checkable`, `scrollable`, `floating`, `ignore_layout`. +`@{ }` is `{ }` that re-runs whenever a referenced subject or variant changes. It works on **widget** attributes (including `style_*` locals) and on a component instance's **variant** attributes — not in `` (initialized once) and not on a component's own props or slots. It must reference at least one subject or variant, and inside it only `type="subject"` props may appear; other props are an error. A failed re-evaluation (e.g. `/0`) keeps the previous value. + +To give each instance its own data, declare `` and pass a subject name at the call site: ``. + **Binding beats callbacks.** A radio group, a theme switch, or a value readout needs no C at all: write the subject with `subject_set_int_event`, read it with `bind_state_if_eq`. +## Variants + +A component's named visual states, declared in ``. Per-instance and reactive, so they are the component-scoped counterpart of global subjects. + +```xml + + + + + + + + + + + + + + + + + + + + + + + + + +``` + +A **property**, **subject** or **variant** has no value at that point: a property has no instance to take it from, and a subject or variant would have to be read again later, which these sections can't do. Using one is reported. + +An `if_target` block is filtered before its content is processed, so an expression there sees the constants of the current target. + ## Value types Each term has a type, inferred from how it is written: diff --git a/docs/syntax/fonts.mdx b/docs/syntax/fonts.mdx index a3873a18..44003ea1 100644 --- a/docs/syntax/fonts.mdx +++ b/docs/syntax/fonts.mdx @@ -86,7 +86,7 @@ even `api` properties: - +