ember flash notifications
v0.1.4
Addon ได้รับการออกแบบมาเพื่อแสดงการแจ้งเตือนแฟลชภายในแอปพลิเคชัน ember.js ขับเคลื่อนโดย Popover 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