aboutsummaryrefslogtreecommitdiff
path: root/docs/src/app/page/api/lustre/event.gleam
blob: 4b098e5808644f50f7cdcbadcdefab946b0aa04b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
// IMPORTS ---------------------------------------------------------------------

import app/layout
import gleam/string
import lustre/element.{Element}

// PAGE ------------------------------------------------------------------------

pub fn view() -> Element(msg) {
  [
    title,
    mouse_events,
    keyboard_events,
    form_messages,
    focus_events,
    custom_events,
  ]
  |> string.join("\n")
  |> layout.docs
}

// CONTENT: TITLE --------------------------------------------------------------

const title: String = "
# lustre/event
"

// CONTENT: MOUSE EVENTS -------------------------------------------------------

const mouse_events: String = "
## Mouse events

### on_click | erlang javascript

```gleam
pub fn on_click(msg: msg) -> Attribute(msg)
```

### on_mouse_down | erlang javascript

```gleam
pub fn on_mouse_down(msg: msg) -> Attribute(msg)
```

### on_mouse_up | erlang javascript

```gleam
pub fn on_mouse_up(msg: msg) -> Attribute(msg)
```

### on_mouse_enter | erlang javascript

```gleam
pub fn on_mouse_enter(msg: msg) -> Attribute(msg)
```

### on_mouse_leave | erlang javascript

```gleam
pub fn on_mouse_leave(msg: msg) -> Attribute(msg)
```

### on_mouse_over | erlang javascript

```gleam
pub fn on_mouse_over(msg: msg) -> Attribute(msg)
```

### on_mouse_out | erlang javascript

```gleam
pub fn on_mouse_out(msg: msg) -> Attribute(msg)
```
"

// CONTENT: KEYBOARD EVENTS ----------------------------------------------------

const keyboard_events: String = "
## Keyboard events

### on_keypress | erlang javascript

```gleam
pub fn on_keypress(msg: fn(String) -> msg) -> Attribute(msg)
```

### on_keydown | erlang javascript

```gleam
pub fn on_keydown(msg: fn(String) -> msg) -> Attribute(msg)
```

### on_keyup | erlang javascript

```gleam
pub fn on_keyup(msg: fn(String) -> msg) -> Attribute(msg)
```
"

// CONTENT: FORM MESSAGES ------------------------------------------------------

const form_messages: String = "
## Form messages

### on_input | erlang javascript

```gleam
pub fn on_input(msg: fn(String) -> msg) -> Attribute(msg)
```

### on_change | erlang javascript

```gleam
pub fn on_change(msg: fn(Bool) -> msg) -> Attribute(msg)
```

### on_submit | erlang javascript

```gleam
pub fn on_submit(msg: msg) -> Attribute(msg)
```
"

// CONTENT: FOCUS EVENTS -------------------------------------------------------

const focus_events: String = "
## Focus events

### on_focus | erlang javascript

```gleam
pub fn on_focus(msg: msg) -> Attribute(msg)
```

### on_blur | erlang javascript

```gleam
pub fn on_blur(msg: msg) -> Attribute(msg)
```
"

// CONTENT: CUSTOM EVENTS ------------------------------------------------------

const custom_events: String = "
## Custom events

### on | erlang javascript

```gleam
pub fn on(name: String, handler: fn(Dynamic) -> Option(msg)) -> Attribute(msg)
```

### prevent_default | javascript

```gleam
pub fn prevent_default(event: Dynamic) -> Nil
```

### stop_propagation | javascript

```gleam
pub fn stop_propagation(event: Dynamic) -> Nil
```

### value | erlang javascript

```gleam
pub fn value(event: Dynamic) -> Decoded(String)
```

### checked | erlang javascript

```gleam
pub fn checked(event: Dynamic) -> Decoded(Bool)
```

### mouse_position | erlang javascript

```gleam
pub fn mouse_position(event: Dynamic) -> Decoded(#(Float, Float)) 
```

### emit | javascript

```gleam
pub fn emit(event: String, data: any) -> Effect(msg)
```
"