Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Using a modifier for flash-message component #344

Open
Techn1x opened this issue Dec 12, 2020 · 0 comments
Open

Using a modifier for flash-message component #344

Techn1x opened this issue Dec 12, 2020 · 0 comments

Comments

@Techn1x
Copy link
Contributor

Techn1x commented Dec 12, 2020

Would there be any interest in moving the current flash logic from the flash-message component, into a modifier?

Thinking it could be (somewhat) backwards compatible, the current flash-message component would end up looking like this;

// flash-message.hbs
<div
  ...attributes
  {{flash-modifier @flash}} // applies all the classes, attributes, event handlers, flash logic. The component JS would be mostly empty.
>
  {{#if hasBlock}}
    {{yield this @flash (action "onClose")}}
  {{else}}
    {{@flash.message}}
    <FlashMessage::Progress @showProgress={{this.showProgressBar}} @duration={{this.progressDuration}} />
  {{/if}}
</div>

It would also allow users of this addon to make custom flash components with relative ease if they wish to do so, without having to implement all of the logic from the flash message component.

{{#each flashMessages.queue as |flash|}}
  <my-flash class="abc" {{flash-modifier flash}}>
    wow, that's all I have to do, don't even need a component
  </my-flash>
{{/each}}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant