-
Notifications
You must be signed in to change notification settings - Fork 20
/
Copy pathMain.elm
48 lines (34 loc) · 946 Bytes
/
Main.elm
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
module Main exposing (main)
import Browser
import Html exposing (Html, text)
import Material.Button as Button
import Material.Typography as Typography
type alias Model =
{ count : Int }
initialModel : Model
initialModel =
{ count = 0 }
type Msg
= Increment
| Decrement
update : Msg -> Model -> Model
update msg model =
case msg of
Increment ->
{ model | count = model.count + 1 }
Decrement ->
{ model | count = model.count - 1 }
view : Model -> Html Msg
view model =
Html.div [ Typography.typography ]
[ Button.raised (Button.config |> Button.setOnClick Increment) "+1"
, Html.div [] [ text <| String.fromInt model.count ]
, Button.raised (Button.config |> Button.setOnClick Decrement) "-1"
]
main : Program () Model Msg
main =
Browser.sandbox
{ init = initialModel
, view = view
, update = update
}