aforemny/material-components-web-elm

Add `Snackbar.mapMessage : (msg1 -> msg2) -> Message msg1 -> Message msg2`

Opened this issue · 0 comments

Snackbar messages should be able to be mapped if a hierarchically lower component (msg1) fires a snackbar message handled by a hierarchically higher component (application, msg2).

The current design of Snackbar.customIcon makes this infeasible.

As a work-around, do not dispatch Snackbar.Message msg1 from the lower-component, but rather a relevant subset of Snackbar.Message, ie. { label : String, onActionIconClick : Maybe (Icon msg) } that you can map yourself and only turn it into a snackbar message at the top-level.