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.
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?
-- 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
]
Any feedback would be welcome!
You're trading one set of boilerplate for another.
Both your versions are almost as bad as you are forcing internal details of the functioning of the dropdown onto the user of the dropdown.
The pure version is indeed more aligned with the current recommendations but it is almost as bad from a library user point of view.
In order to have a full treatment of the issue, implement a webcomponents/polymer version of the same functionality and then argue that the "pure" version is better.
--
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 elm-discuss+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
--
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 elm-discuss+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
After I found out about elm-polymer library, I tried to reimplement your example but, I've run into issues.
This is as far as I got
https://github.com/pdamoc/polymer-exploration
The problems are due to the way children are handled.
I tried a fix that I remembered from a previous exploration (lazyRegister) but, the rendering is still bad.
Not sure what the problem is, perhaps just styling? I have defeintely been able to get paper-listbox and paper-item working. See:
--
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 elm-discuss+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
I have to do some more digging, but I like the fact that there's a ton of event handlers, that you can simply include in your elm view render.
I just pushed the latest changes and the functionality should be equivalent.
https://github.com/pdamoc/polymer-exploration
CountryPicked country -> { model | country = Just country , city = if model.country /= Nothing && model.country /= Just country then Nothing else model.city }
Peter, did you deliberately choose to put everything (including items) in a single config record?Just curious.
--
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 elm-discuss...@googlegroups.com.
Looks great! I would suggest a small change in the country update: to only reset the city selector if the country selected is different from the previous selection.
CountryPicked country ->{ model| country = Just country, city =if model.country /= Nothing && model.country /= Just country thenNothingelsemodel.city}
You cannot use comparison on tags.
-- is this not allowed?
if someMaybe == Just 42 then
...
--
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 elm-discuss+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
if someMaybe == ... then
And use
case someMaybe of
(Or .map)
instead. Gives us more protection from the compiler to get all branches covered...