Skip to content

Instantly share code, notes, and snippets.

@gdotdesign
Last active May 5, 2016 04:34
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 gdotdesign/cc924f6e591efec979524fe643ee5c12 to your computer and use it in GitHub Desktop.
Save gdotdesign/cc924f6e591efec979524fe643ee5c12 to your computer and use it in GitHub Desktop.
Attribute unexpectedly removed
module Main exposing (..)
import Html.Attributes exposing (style)
import Html.Events exposing (onClick)
import Html exposing (node, text)
import Html.App
type alias Model =
{ color : String
, clicks : Int
}
type Msg
= Click
init : Model
init =
{ clicks = 0
, color = "black"
}
update : Msg -> Model -> ( Model, Cmd Msg )
update msg model =
case msg of
Click ->
( { model | clicks = model.clicks + 1, color = "red" }, Cmd.none )
view : Model -> Html.Html Msg
view model =
node
"div"
[ style [ ( "color", model.color )
, ( "font-size", "30px" )
]
, onClick Click
]
[ text (toString model.clicks) ]
main =
Html.App.program
{ init = ( init, Cmd.none )
, view = view
, update = update
, subscriptions = \model -> Sub.none
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment