Created
February 17, 2019 08:21
-
-
Save eitoball/9c3e043616f84690ac1216c47bcd2587 to your computer and use it in GitHub Desktop.
This file contains hidden or 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 Browser | |
import Html exposing (Attribute, Html, button, div, node, p, text) | |
import Html.Attributes exposing (classList) | |
import Html.Events exposing (onClick) | |
type alias Model = { message : String , flush : Bool } | |
main = | |
Browser.sandbox | |
{ init = { message = "" , flush = False } | |
, update = update | |
, view = view | |
} | |
type Msg = Increment | Flush | |
update : Msg -> Model -> Model | |
update msg model = | |
case msg of | |
Increment -> | |
{ model | message = model.message ++ "💩" } | |
Flush -> | |
{ model | flush = True } | |
marquee : List (Attribute msg) -> List (Html msg) -> Html msg | |
marquee attributes children = | |
node "marquee" attributes children | |
view : Model -> Html Msg | |
view model = | |
div | |
[] | |
[ (if model.flush then marquee else p) [] [ text model.message ] | |
, button [ onClick Increment ] [ text "増える" ] | |
, button [ onClick Flush ] [ text "流す" ] | |
] |
This file contains hidden or 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
npm init -y | |
npm install elm --save-dev | |
$(npm bin elm)/elm init | |
$(npm bin elm)/elm make Main.elm |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment