-
Notifications
You must be signed in to change notification settings - Fork 11
/
Copy pathau-toaster.gjs
46 lines (42 loc) · 1.3 KB
/
au-toaster.gjs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
import { AuAlert } from '@appuniversum/ember-appuniversum';
import { fn } from '@ember/helper';
import { inject as service } from '@ember/service';
import Component from '@glimmer/component';
export default class AuToaster extends Component {
@service toaster;
get position() {
if (this.args.position == 'bottom') return 'au-c-toaster--bottom';
else return 'au-c-toaster--top';
}
closeToast = (toast) => {
this.toaster.close(toast);
};
<template>
{{#if this.toaster.toasts.length}}
<div class="au-c-toaster {{this.position}}" ...attributes>
{{#each this.toaster.toasts as |toast|}}
{{#if toast.component}}
<toast.component
@options={{toast.options}}
@close={{fn this.closeToast toast}}
/>
{{else}}
<AuAlert
@title={{toast.title}}
@skin={{toast.options.type}}
@icon={{toast.options.icon}}
@size="small"
@closable={{toast.options.closable}}
@onClose={{fn this.closeToast toast}}
data-test-toast
>
{{#if toast.message}}
<p>{{toast.message}}</p>
{{/if}}
</AuAlert>
{{/if}}
{{/each}}
</div>
{{/if}}
</template>
}