diff options
| author | eunhhu <[email protected]> | 2026-09-26 11:33:31 +0100 |
|---|---|---|
| committer | eunhhu <[email protected]> | 2026-09-26 11:33:31 +0100 |
| commit | 0d5effd6afe8808296a01db102ca4c247cdcd1af (patch) | |
| tree | 4f1113880606fb6dda861fd846f8ff40d5c17a63 /examples | |
| parent | 3b3e4a221fa47d0109c6ab99be65b5ba48bae254 (diff) | |
| download | vega-0d5effd6afe8808296a01db102ca4c247cdcd1af.tar.gz vega-0d5effd6afe8808296a01db102ca4c247cdcd1af.zip | |
Show filtered lists and their shared focus
A list may now be filtered (each t in tasks where !t.done), and several
filtered lists over one list share one focus: the focus view names an
item, so Vega asks Pure which row shows it and highlights it only in the
list that holds it; the other lists have no focus (null in the web
surface's JSON, and the spoken surface names the item where it is). A
click or point on a row points at the item that row shows, and the wheel
on a list without the focus focuses the row under it. Pure's rows now
take a mutable app.
examples/today.aup shows what is open and what is done; its CLI output
matches a model over random adds, moves, toggles and points into either
list, and the web surface leaves the other list without a focus.
Diffstat (limited to 'examples')
| -rw-r--r-- | examples/today.aup | 39 |
1 files changed, 39 insertions, 0 deletions
diff --git a/examples/today.aup b/examples/today.aup new file mode 100644 index 0000000..e5db53b --- /dev/null +++ b/examples/today.aup @@ -0,0 +1,39 @@ +# Two lists over one list state: what is open and what is done. Each shows +# the items its where keeps; the focus (at) is one item, shown in whichever +# list holds it, and a click in either list points at that item. +use vega + +record Task { + title: text + done = 0 +} + +state tasks: list of Task +state at: index of tasks + +input add = text +input up = key ArrowUp +input down = key ArrowDown +input toggle = key Space + +on add { + tasks.append(Task { title: add }) + at = tasks.last +} +on up.down { at = at - 1 } +on down.down { at = at + 1 } +on toggle.down { at.done = !at.done } + +view title = "Today" +view left = "{count(t in tasks where !t.done)} open" + +view open = each t in tasks where !t.done { + label = t.title +} +view open_focus = at.position + +view done = each t in tasks where t.done { + label = t.title + tone = vega.muted +} +view done_focus = at.position |
