Created
February 17, 2018 06:21
-
-
Save andeemarks/8c1a5adff6799fb197d860c872440810 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, text, input, div) | |
import Html.Attributes exposing (..) | |
import Html.Events exposing (onInput) | |
import String | |
main = Html.program { init = init, | |
view = view, update = update, subscriptions = \_ -> Sub.none } | |
-- Model | |
type alias Model = { content : String } | |
initialModel : Model | |
initialModel = { content = "" } | |
init = (initialModel, Cmd.none) | |
-- Update | |
type Msg = Change String | |
update: Msg -> Model -> ( Model, Cmd Msg) | |
update msg model = case msg of | |
Change c -> ({model | content = c}, Cmd.none) | |
-- View | |
shout text = String.toUpper text | |
whisper text = String.toLower text | |
echo text = (shout text) ++ " " ++ (whisper text) | |
myStyle = style [ ("width", "100%") ] | |
view : Model -> Html Msg | |
view model = div [] [ input [placeholder "Say something", onInput Change, myStyle ] | |
[], div [ myStyle ] [text (echo (toString model.content))] ] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment