Last active
May 20, 2016 10:53
-
-
Save jinjor/cc9b74ccf0b24eb60dd2ed33e7b41d49 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 Html exposing (Html, text, button, div, p, ul, li) | |
import Html.Attributes exposing (style) | |
import Html.Events exposing (onClick) | |
type OuterMsg = | |
ContainerMsg InnerMsg | View1Click | View2Click | |
main : Html OuterMsg | |
main = container ContainerMsg [ view1, view2 ] | |
view1 : Html OuterMsg | |
view1 = button [ onClick View1Click ] [ text "button" ] | |
view2 : Html OuterMsg | |
view2 = p [ onClick View2Click ] [ text "bla bla" ] | |
-- CONTAINER | |
type InnerMsg = ItemSelected | |
container : (InnerMsg -> msg) -> List (Html msg) -> Html msg | |
container transformMsg children = | |
let | |
itemView inner = | |
li | |
[ onClick (transformMsg ItemSelected) | |
, style | |
[ ("padding", "10px") | |
, ("margin-bottom", "10px") | |
, ("border", "solid 1px gray") ] | |
] | |
[ inner ] | |
in | |
ul | |
[ style [ ("padding", "20px") ] ] | |
(List.map itemView children) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment