ember flash notifications
v0.1.4
アドオンは、ember.jsアプリケーション内にフラッシュ通知を表示するように設計されています。ポップオーバーAPIを搭載しています。
ember install ember-flash-notifications
FlashNotificationsの呼び出しをテンプレートに追加します。
<FlashNotifications as |notification|>
<FlashNotification @notification={{notification}}>
<div class={{notification.type}}>{{notification.message}}</div>
</FlashNotification>
</FlashNotifications>
通知要素に必要なスタイルを最小限に抑える(TailWindCSSは依存関係ではなく、プレーンCSSも使用できます):
[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;
}
}
...そして通知の呼び出しを行います:
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!');
}
}
ここでは、詳細な例、APIドキュメット、ライブの例を参照してください
詳細については、寄稿ガイドを参照してください。
このプロジェクトは、MITライセンスの下でライセンスされています。