debois / elm-mdl

Elm-port of the Material Design Lite CSS/JS library
Apache License 2.0
965 stars 133 forks source link

Tabs Overcomplexity #363

Open hickscorp opened 6 years ago

hickscorp commented 6 years ago

I'm rather new to the whole Elm thing, so please bare with me.

The fact that the tabs trigger a selected index message is IMO a source of over-complexifying most of the MDL layouts. If you have only one tab bar, it's easy and fun. But if you have as many tab bars as you have contexts (Eg General Page has 3 tabs Home, Contact, About. Dashboard Page has tabs Profile and Friends, etc).

A very good addition to elm-mdl would probably be a way to have a onSelect action assigned to each tab, to remove the need of mapping from / to Int indices eg:

view model =
    Layout.render Mat
        model.mdl
        [ ... ]
        { header = ...
        , drawer = ...
        , tabs = ( [ Tab.item [onClick (NavMsg (GeneralPage Home))] [ text "Home" ] ], [] )
        , main = ...
        }

Again, I'm pretty new to this, so if I missed something feel free to close this enhancement request issue.