Skip to main content

CODE_WEB_COUNTER

Constant CODE_WEB_COUNTER 

Source
pub const CODE_WEB_COUNTER: &str = r##"# Counter — a LOGOS page

A page owns a URL and mounts itself: no `## Main`, no `Mount`. One click is one TURN —
the action runs, the page repaints once.

## Page /

State:
    Let count be 0.

Actions:
    To bump:
        Set count to count + 1.

    To reset:
        Set count to 0.

View:
    <h1 id="count">Count: {count}</h1>
    <button id="bump" on-click={bump}>+1</button>
    <button id="reset" on-click={reset}>reset</button>

## Test: each click is one turn

Click "#bump".
Click "#bump".
Expect that the text of "#count" is equal to "Count: 2".
Click "#reset".
Expect that the text of "#count" is equal to "Count: 0".
"##;
Expand description

Web page: a counter. A .logos file that declares a ## Page opens in the Web tab, where it is compiled to WebAssembly and runs live.