developit / preact-mdl

:boom: A collection of Preact Components that encapsulate Google's Material Design Lite.
MIT License
187 stars 20 forks source link

Simplify Snackbar component #9

Closed unindented closed 8 years ago

unindented commented 8 years ago

I realized it makes no sense to expose Snackbar.Text and Snackbar.Action, as MDL always expects them to be there, and they can't have user-specified children. Users should always do:

snackbarContainer.MaterialSnackbar.showSnackbar({
      message: 'Your message has been deleted.',
      timeout: 2000,
      actionHandler: handler,
      actionText: 'Undo'
});

Sorry. 😓

developit commented 8 years ago

@unindented what about passing text and actionText as props?

unindented commented 8 years ago

According to the docs, the data should be passed when calling showSnackbar. Adding them at render time doesn't seem to do anything...

unindented commented 8 years ago

The showSnackbar method has logic around queueing notifications, activating the element, etc., so we probably wouldn't want to bypass it: https://github.com/google/material-design-lite/blob/027e05164202d938571c358565b14528d74ed792/src/snackbar/snackbar.js#L100-L126

developit commented 8 years ago

Makes sense to me, though they could still be props but not in the DOM. I guess less is better here though, avoids invention.

developit commented 8 years ago

@unindented once refs are released in Preact proper, might be good for us to provide an alias for show() -> showSnackbar() on the component.

unindented commented 8 years ago

Tru.