Skip to content

Instantly share code, notes, and snippets.

@cstuncsik
Forked from anonymous/Main.elm
Created July 26, 2017 19:51
Show Gist options
  • Save cstuncsik/37a4edbe697c51a01a0f0853ed302d0a to your computer and use it in GitHub Desktop.
Save cstuncsik/37a4edbe697c51a01a0f0853ed302d0a to your computer and use it in GitHub Desktop.
Text Fields
{
"version": "1.0.0",
"summary": "https://guide.elm-lang.org/architecture/user_input/text_fields.html",
"repository": "https://github.com/user/project.git",
"license": "BSD3",
"source-directories": [
"."
],
"exposed-modules": [],
"dependencies": {
"elm-lang/core": "5.1.1 <= v < 5.1.1",
"elm-lang/html": "2.0.0 <= v < 2.0.0"
},
"elm-version": "0.18.0 <= v < 0.19.0"
}
<html>
<body>
<script>
var app = Elm.Main.fullscreen()
</script>
</body>
</html>
module Main exposing (..)
import Html exposing (Html, Attribute, div, input, text)
import Html.Attributes exposing (..)
import Html.Events exposing (onInput)
main : Program Never Model Msg
main =
Html.beginnerProgram { model = model, view = view, update = update }
type alias Model =
{ content : String
}
model : Model
model =
{ content = "" }
type Msg
= Change String
update : Msg -> Model -> Model
update msg model =
case msg of
Change newContent ->
{ model | content = newContent }
view : Model -> Html Msg
view model =
div []
[ input [ placeholder "Text to reverse", onInput Change ] []
, div [] [ text (String.reverse model.content) ]
]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment