Op zondag 4 december 2016 15:02:02 UTC+1 schreef Rex van der Spuy:
>
> I found both Evan's sortable table example and your (excellent!) dropdown
> menu just a few levels too advanced for my poor beginner's brain to fully
> grok.
>
Glad you liked it! Were there any particular sections in the article that
you found too advanced?
I'd be happy to make them more clear.
> For example, what would a simple, stand-alone, reusable, "pure" button
> component look like that just triggers a message update in the parent
> module when clicked?
>
A pure reusable button could look like this:
-- the pure button component
type alias Config msg =
{ clickMsg : msg
, buttonText : String
}
myButton : Config msg -> Html msg
myButton config buttonText =
button [ onClick config.clickMsg ] [ text config.ButtonText ]
-- usage in your main module
type Msg =
...
| HandleButtonClick
buttonConfig : Button.Config Msg
buttonConfig =
{ clickMsg = HandleButtonClick
, buttonText = "click me!"
}
view : model -> Html Msg
view model =
div []
[ p [] [ text "this is an example" ]
, Button.myButton buttonConfig
]
I'd put the message and the text both in a config, because I suspect these
would be quite static, meaning the values would not change while running
you app.
--
You received this message because you are subscribed to the Google Groups "Elm
Discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/d/optout.