Tutorial 2 · Build a Styled Task Tracker (5 Visual Steps)#
Now that you know the core MVU + Lean 4 loop from Tutorial 1, let's build a richer real-world app — StyledTaskTracker — using typed record Collections (List TaskItem), list capacity invariants, WCAG AAA StyleTokens, EN/DE Resource Dictionaries, sortable Data Tables, and 3D Isometric Orbit Timeline inspection.
Follow along live in your browser: https://wieslawsoltes.github.io/LeanUI/ Every step snapshot below is auto-generated directly from the live LeanUI SVG engine on each deployment. Click any figure to zoom (
⤢ Zoom).
Step 1 · Define a Typed Collection (List TaskItem) & Draft State#
Collections model typed tables/lists (List Row) with compile-time field schemas checked in both TypeScript and Lean 4.
How to Do This in LeanUI Studio#
- Create a new module named
StyledTaskTrackervia⊞ Solution → + Module. - Drag a
Collectionnode from the Node Palette onto the canvas and configure it in the Node Inspector:- Name:
tasks· Item Type Name:TaskItem - Schema Columns:
title : String,priority : Nat,done : Bool - Seed Rows: add 2 initial tasks (
"Verify Lean proofs","Ship responsive UI").
- Name:
- Drag a
Statenode (draftTitle : String, init:"Write docs") for the new-task form input. - Drag a
Computednode (taskCount : Nat, expression:tasks.length) and wiretasks.items→taskCount.in.
Step 2 · Add Collection Actions & Prove List Capacity Bounds#
Add safe list mutations (AddTask, ClearAll) and a Lean 4 Invariant ensuring the task list never grows unboundedly.
How to Do This in LeanUI Studio#
- Add an
Actionnode namedAddTask:- Expression:
tasks = tasks.length < 20 ? tasks.concat([{ title: draftTitle, priority: 1, done: false }]) : tasks - Wire
AddTask.effect→tasks.mutate.
- Expression:
- Add a second
Actionnode namedClearAll:- Expression:
tasks = [] - Wire
ClearAll.effect→tasks.mutate.
- Expression:
- Add an
Invariantnode namedboundedList:- Expression:
tasks.length <= 20 - Wire
tasks.items→boundedList.check.
- Expression:
Checkpoint: Verify the Console shows
0 errors— LeanUI statically type-checks the record literal{ title, priority, done }againstTaskItem's schema!
Step 3 · Add a WCAG AAA StyleToken & EN/DE Resource Bundle#
LeanUI verifies your visual design system with the exact same mathematical rigor as your application logic.
How to Do This in LeanUI Studio#
- Drag a
Style Token(style) node from the Design System section of the Palette:- Name:
TaskSurface - Background:
#0f172a· Foreground:#f8fafc· Accent:#38bdf8 - Look at the node's preview strip — LeanUI computes the exact WCAG contrast ratio (
17.8:1 ✓ AAA) automatically!
- Name:
- Drag a
Resource Bundle(resource) node next to it:- Name:
TaskStrings· Locales:en, de - Add localized entries (
title,add) and a theme token (surfaceBgwith Light#ffffff/ Dark#0f172a).
- Name:
Inspect & Tune Contrast Live in the Property Inspector#
- Click
TaskSurfaceon the canvas and inspect its live WCAG contrast badge (17.8:1 ✓ AAA), border radius, padding, and device sizing controls in the⚙ Inspectorpanel.
Tip: Want reusable multi-part controls? Add a
Control Template(control_template) node and double-click it to enter the unified❖ ControlTemplatevisual graph editor (see Control Templates & Design).
Step 4 · Wire the Styled Card, Form Input, Button & Sortable Table#
Connect your design tokens, draft form state, and typed collection into an interactive UI.
How to Do This in LeanUI Studio#
- Add a
Card(TaskBoard, Title:"Task Tracker") and wire:TaskSurface.style→TaskBoard.styleTaskStrings.res→TaskBoard.res
- Add four children wired from
TaskBoard.children→parent:Stat(OpenTasksStat) ←taskCount.out→valueInput(DraftInput, Label:"New Task") ←draftTitle.val→valueButton(AddTaskBtn, Label:"+ Add Task") →onClick→AddTask.triggerTable(TaskTable, columns:Title | Priority | Done, Striped & Removable) ←tasks.items→rows
- Click
Layout(DAG Layered) and⊡ Size(Auto-Size All) to make every card crisp and spacious.
Test the Live App End-to-End Across All Studio Panels#
- Type a new task into New Task inside the right-hand
▶ Previewpanel, click+ Add Task, scrub the⏱ Timelineslider below it, and verify0 errorsin▤ Console.
Try it live: Click column headers in the rendered
TaskTableto sort rows, click row remove icons, and toggle the Locale dropdown (EN↔DE)!
Step 5 · Inspect in 3D Orbit & Export Diagrams or Multi-Screen Prototype#
- Dispatch 2–3
AddTaskclicks in Live Preview, then switch to🧊 3D Orbitin the center stage bar to watch each new task stack as a 3D frame linked by state-diff arcs. - Click
λ Proveto machine-check all state, collection, WCAG contrast, and i18n theorems in Lean 4. - Click
⤓ Exportin the Canvas HUD to export your app as:- Crisp SVG or 2×/3× Retina PNG (with Auto-Annotate Help Callouts), or
- A Multi-Page PDF Architecture Deck containing Clean Graph, Live State, Timeline Storyboard, CAD Explode, 3D Orbit, and App Flow!
Continue Learning#
- Connect live external REST APIs, Firebase, or SQL/MS Access JOIN queries in Connect Real Data & Tables.
- Wire multiple modules together into a clickable multi-screen app in Multi-Screen Apps & Prototypes.