Skip to content

Commit be92f45

Browse files
authored
Merge pull request #13 from togglebyte/dev
mention anathema-extras
2 parents e39468e + 6e8f12b commit be92f45

File tree

3 files changed

+77
-0
lines changed

3 files changed

+77
-0
lines changed

src/SUMMARY.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,3 +30,5 @@
3030
- [padding](./templates/elements/padding.md)
3131
- [canvas](./templates/elements/canvas.md)
3232
- [container](./templates/elements/container.md)
33+
- [Inputs and other components](./anathema-extras.md)
34+
- [Inputs and other components](./anathema-extras/input.md)

src/anathema-extras.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
# Some generic components are worked on and maintained by core developers
2+
3+
To use these components add `anathema-extras` as a dependency to `Cargo.toml`
4+
5+
```
6+
[dependencies]
7+
anathema-extras = { version = "0.1" }
8+
```
9+
10+
* [Input (single line)](./anathema-extras/input.md)
11+

src/anathema-extras/input.md

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
# Input
2+
3+
A single line input field.
4+
5+
```rust
6+
builder
7+
.default::<Input>("input", Input::template())
8+
.unwrap();
9+
10+
```
11+
12+
The input component can be registered as a prototype as well.
13+
14+
```rust
15+
builder
16+
.prototype("input", Input::template(), Input::new, InputState::new)
17+
.unwrap();
18+
19+
```
20+
21+
## Supported events:
22+
23+
The following events are provided:
24+
25+
### `on_enter`
26+
27+
The enter key was pressed.
28+
This event publishes `anathema_extras::Text`, which implements `Deref<str>`.
29+
30+
### `on_change`
31+
32+
A change was made to the text (insert or remove).
33+
This event publishes `anathema_extras::InputChange`.
34+
35+
### `on_focus`
36+
37+
The input component gained focus.
38+
This event publishes `()`.
39+
40+
### `on_blur`
41+
42+
The input component lost focus.
43+
This event publishes `()`.
44+
45+
## Attributes
46+
47+
### `clear_on_enter`
48+
49+
If the desired outcome is to retain the text when the enter key is pressed set
50+
this attribute to false.
51+
52+
```
53+
@input [clear_on_enter: false]
54+
```
55+
56+
## Example
57+
58+
```
59+
vstack
60+
@input (on_enter->update_label_a)
61+
@input (on_enter->update_label_b)
62+
```
63+
64+
# Button

0 commit comments

Comments
 (0)