Skip to content

Instantly share code, notes, and snippets.

@eitoball
Created February 17, 2019 08:21
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save eitoball/9c3e043616f84690ac1216c47bcd2587 to your computer and use it in GitHub Desktop.
Save eitoball/9c3e043616f84690ac1216c47bcd2587 to your computer and use it in GitHub Desktop.
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 "流す" ]
]
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