-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathCounter.elm
More file actions
54 lines (34 loc) · 862 Bytes
/
Counter.elm
File metadata and controls
54 lines (34 loc) · 862 Bytes
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
module Task.Counter exposing (Model, Msg, init, update, view)
import Html as H
import Html.Attributes as HA
import Support.View.Button as Button
import Support.View.Frame as Frame
-- MODEL
type Model
= Model Int
init : Model
init =
Model 0
-- UPDATE
type Msg
= ClickedIncrement
update : Msg -> Model -> Model
update msg (Model n) =
case msg of
ClickedIncrement ->
Model <| n + 1
-- VIEW
view : Model -> H.Html Msg
view (Model n) =
Frame.view
{ modifier = Frame.Default
, title = "Counter"
, body =
H.div [ HA.class "counter" ]
[ H.output [] [ H.text <| String.fromInt n ]
, Button.view
{ type_ = Button.Button ClickedIncrement
, text = "Count"
}
]
}