summaryrefslogtreecommitdiff
path: root/node_modules/shiki/samples/elm.sample
diff options
context:
space:
mode:
Diffstat (limited to 'node_modules/shiki/samples/elm.sample')
-rw-r--r--node_modules/shiki/samples/elm.sample66
1 files changed, 66 insertions, 0 deletions
diff --git a/node_modules/shiki/samples/elm.sample b/node_modules/shiki/samples/elm.sample
new file mode 100644
index 0000000..8b008c8
--- /dev/null
+++ b/node_modules/shiki/samples/elm.sample
@@ -0,0 +1,66 @@
+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 "+" ]
+ ]
+
+-- From https://elm-lang.org/examples/buttons \ No newline at end of file