ember flash notifications
v0.1.4
Das Addon ist so konzipiert, dass Flash -Benachrichtigungen in Ember.js -Anwendungen angezeigt werden. Angetrieben von Popover -API.
ember install ember-flash-notifications
Fügen Sie einer Vorlage FlashNotifications -Aufruf hinzu:
<FlashNotifications as |notification|>
<FlashNotification @notification={{notification}}>
<div class={{notification.type}}>{{notification.message}}</div>
</FlashNotification>
</FlashNotifications>
Fügen Sie minimale erforderliche Stile für ein Benachrichtigungselement hinzu (Railwindcss ist keine Abhängigkeit, und Sie können auch einfache CSS verwenden):
[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;
}
}
... und melden Sie eine Benachrichtigungserklärung:
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!');
}
}
Siehe detaillierte Beispiele, API -Dokumente und Live -Beispiele hier
Weitere Informationen finden Sie im beitragenden Leitfaden.
Dieses Projekt ist unter der MIT -Lizenz lizenziert.