-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapp-root.ts
More file actions
89 lines (85 loc) · 2.34 KB
/
app-root.ts
File metadata and controls
89 lines (85 loc) · 2.34 KB
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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
import { html, css, LitElement } from 'lit';
import { customElement } from 'lit/decorators.js';
import '../src/iaux-notification-toast';
import type {
aNotification,
IauxNotificationToast,
} from '../src/iaux-notification-toast';
@customElement('app-root')
export class AppRoot extends LitElement {
successNotif(message?: string): aNotification {
return {
message: message ?? 'Default success message',
status: 'success',
};
}
errorNotif(message?: string): aNotification {
return {
message: message ?? 'Default error message',
status: 'fail',
};
}
render() {
return html`
<section id="demo-controls">
<button
@click="${() => {
const toast = this.shadowRoot!.querySelector(
'iaux-notification-toast'
) as IauxNotificationToast;
toast.addNotification(this.successNotif());
}}"
>
Add Success Notification
</button>
<button
@click="${() => {
const toast = this.shadowRoot!.querySelector(
'iaux-notification-toast'
) as IauxNotificationToast;
toast.addNotification(this.errorNotif());
}}"
>
Add Error Notification
</button>
<button
@click="${() => {
const toast = this.shadowRoot!.querySelector(
'iaux-notification-toast'
) as IauxNotificationToast;
const notif =
Math.random() > 0.5
? this.successNotif('Randomized notif success')
: this.errorNotif('Randomized notif error');
toast.addNotification(notif);
}}"
>
Add Random Notification
</button>
<button
@click="${() => {
const toast = this.shadowRoot!.querySelector(
'iaux-notification-toast'
) as IauxNotificationToast;
toast.clear();
}}"
>
Clear Notifications
</button>
</section>
<iaux-notification-toast title="Hello"> </iaux-notification-toast>
`;
}
static styles = css`
:host {
display: block;
}
section#demo-controls {
background-color: aliceblue;
width: 100%;
min-height: 50px;
display: flex;
padding-bottom: 50px;
}
`;
}