ember flash notifications
v0.1.4
O Addon foi projetado para exibir notificações flash nos aplicativos Ember.js. Alimentado pela API de Popover.
ember install ember-flash-notifications
Adicione a invocação do FlashNotifications a um modelo:
<FlashNotifications as |notification|>
<FlashNotification @notification={{notification}}>
<div class={{notification.type}}>{{notification.message}}</div>
</FlashNotification>
</FlashNotifications>
Adicione os estilos mínimos necessários para um elemento de notificação (Tailwindcss não é uma dependência e você também pode usar CSS simples):
[popover] {
@apply my-0 mr-0;
}
.flash {
@apply w-80 border transition-opacity block opacity-0;
}
.flash:popover-open {
@apply opacity-100;
}
.flash .error {
@apply bg-rose-500 text-white p-2 rounded-sm;
}
@starting-style {
.flash:popover-open {
@apply opacity-0;
}
}
... e faça invocação de notificação:
mport { action } from '@ember/object';
import Component from '@glimmer/component';
import { inject as service } from '@ember/service';
export default class FlashComponent extends Component {
@service notifications;
@action
addNotification() {
this.notifications.error('Something is going wrong!');
}
}
Veja exemplos detalhados, documetação da API e exemplos ao vivo aqui
Veja o guia contribuinte para obter detalhes.
Este projeto está licenciado sob a licença do MIT.