File tree 1 file changed +57
-0
lines changed
1 file changed +57
-0
lines changed Original file line number Diff line number Diff line change
1
+ module Main exposing (main )
2
+
3
+ import Browser
4
+ import Html exposing (Html , button , div , text )
5
+ import Html.Events exposing (onClick )
6
+
7
+
8
+
9
+ -- MAIN
10
+
11
+
12
+ main =
13
+ Browser . sandbox { init = init, update = update, view = view }
14
+
15
+
16
+
17
+ -- MODEL
18
+
19
+
20
+ type alias Model = Int
21
+
22
+
23
+ init : Model
24
+ init =
25
+ 0
26
+
27
+
28
+
29
+ -- UPDATE
30
+
31
+
32
+ type Msg
33
+ = Increment
34
+ | Decrement
35
+
36
+
37
+ update : Msg -> Model -> Model
38
+ update msg model =
39
+ case msg of
40
+ Increment ->
41
+ model + 1
42
+
43
+ Decrement ->
44
+ model - 1
45
+
46
+
47
+
48
+ -- VIEW
49
+
50
+
51
+ view : Model -> Html Msg
52
+ view model =
53
+ div []
54
+ [ button [ onClick Decrement ] [ text " -" ]
55
+ , div [] [ text ( String . fromInt model) ]
56
+ , button [ onClick Increment ] [ text " +" ]
57
+ ]
You can’t perform that action at this time.
0 commit comments