diff options
author | Guillermo Ramos | 2025-02-16 14:45:55 +0100 |
---|---|---|
committer | Guillermo Ramos | 2025-02-16 19:36:23 +0100 |
commit | 7d80d3d2be3e0f8e36be66a08879b1f04a381e88 (patch) | |
tree | 39c8958afe98ecc518aa0b51bf2665fe31b4ab5e /front/src | |
parent | 93e1545fb7da1f54fcc3dade596185ffe6c7a17d (diff) | |
download | hiccup-7d80d3d2be3e0f8e36be66a08879b1f04a381e88.tar.gz |
Basic Elm application
Diffstat (limited to 'front/src')
-rw-r--r-- | front/src/Main.elm | 64 |
1 files changed, 64 insertions, 0 deletions
diff --git a/front/src/Main.elm b/front/src/Main.elm new file mode 100644 index 0000000..fdf2fc4 --- /dev/null +++ b/front/src/Main.elm @@ -0,0 +1,64 @@ +module Main exposing (..) + +-- Press buttons to increment and decrement a counter. +-- +-- Read how it works: +-- https://guide.elm-lang.org/architecture/buttons.html +-- + + +import Browser +import Html exposing (Html, button, div, text) +import Html.Events exposing (onClick) + + + +-- MAIN + + +main = + Browser.sandbox { init = init, update = update, view = view } + + + +-- MODEL + + +type alias Model = Int + + +init : Model +init = + 0 + + + +-- UPDATE + + +type Msg + = Increment + | Decrement + + +update : Msg -> Model -> Model +update msg model = + case msg of + Increment -> + model + 1 + + Decrement -> + model - 1 + + + +-- VIEW + + +view : Model -> Html Msg +view model = + div [] + [ button [ onClick Decrement ] [ text "-" ] + , div [] [ text (String.fromInt model) ] + , button [ onClick Increment ] [ text "+" ] + ] |