File tree Expand file tree Collapse file tree 4 files changed +63
-0
lines changed
Expand file tree Collapse file tree 4 files changed +63
-0
lines changed Original file line number Diff line number Diff line change 1414 - [ Loops] ( ./templates/loops.md )
1515 - [ If / Else] ( ./templates/if-else.md )
1616 - [ Switch / Case] ( ./templates/switch-case.md )
17+ - [ With] ( ./templates/with.md )
1718 - [ Functions] ( ./templates/functions.md )
1819 - [ Custom functions] ( ./templates/functions/custom.md )
1920 - [ Elements] ( ./templates/elements.md )
3536 - [ container] ( ./templates/elements/container.md )
3637- [ Inputs and other components] ( ./anathema-extras.md )
3738 - [ Input] ( ./anathema-extras/input.md )
39+ - [ Recipes] ( ./recipes.md )
40+ - [ Routing] ( ./recipes/routing.md )
Original file line number Diff line number Diff line change 1+ # Recipes
2+
3+ * Themeing
4+ * Async
5+ * [ Routing] ( ./recipes/routing.md )
6+
7+ ``` rust,ignore
8+ #[derive(State)]
9+ struct MyState {
10+ value: Value<bool>,
11+ }
12+ ```
13+
14+ ``` aml
15+ border
16+ vstack
17+ text "Hello world"
18+ ```
Original file line number Diff line number Diff line change 1+ # Routing
2+
3+ Routing can be done with a combination of state and ` switch ` .
4+
5+ TODO
6+ THIS IS UNFINISHED
7+
8+ ``` rust,ignore
9+ struct Router;
10+
11+ impl Component for Router {
12+ State = String;
13+ Message = String;
14+ }
15+ ```
16+
17+ ``` aml
18+ text "hello"
19+ span "sausage"
20+ ```
Original file line number Diff line number Diff line change 1+ # With
2+
3+ A ` with ` makes it possible to scope an expression for nodes
4+
5+ ## Example
6+
7+ ```
8+ let THEME = [
9+ { fg: "red", bool: true },
10+ { fg: "green", bool: false },
11+ { fg: "blue", bool: true },
12+ ];
13+
14+
15+ border
16+ with theme as colors[state.some_count % 2 == 0]
17+ // Refering to `theme` instead of repeating `colors[state.some_count % 2 == 0]`
18+
19+ text [foreground: theme.fg] "hello "
20+ span [bold: theme.bold] "world"
21+
22+ ```
You can’t perform that action at this time.
0 commit comments