Last active
June 19, 2016 22:45
-
-
Save shamrin/f29672717fc0df775486a7ece0650412 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Html exposing (Html, Attribute, text, div, input) | |
import Html.App exposing (beginnerProgram) | |
import Html.Attributes exposing (..) | |
import Html.Events exposing (onInput, on) | |
import String | |
main = | |
beginnerProgram { model = "", view = view, update = update } | |
-- UPDATE | |
type Msg | |
= NewContent String | |
| NoOp | |
update msg oldContent = | |
case msg of | |
NewContent content -> | |
content | |
NoOp -> | |
oldContent | |
-- VIEW | |
view content = | |
input [ type' "number", onInput handleInput, value content ] [] | |
handleInput : String -> Msg | |
handleInput s = | |
if String.length s <= 2 then NewContent s else NoOp |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment