1+ import React from "react" ;
2+
3+ class NotificationBuilder {
4+ removeNotification ( element ) {
5+ setTimeout ( function ( ) {
6+ element . style . opacity = 1
7+ } , 10 )
8+ setTimeout ( function ( ) {
9+ element . style . opacity = 0
10+ setTimeout ( function ( ) {
11+ element . remove ( )
12+ } , 300 )
13+ } , 5000 )
14+ }
15+ constructor ( ) {
16+ this . notifications = [ ]
17+ }
18+ create ( config = { text : "" } ) {
19+ var notifications = document . getElementById ( "notifications" )
20+
21+ var notification = document . createElement ( "div" )
22+ notification . className = "notification"
23+
24+ var notificationText = document . createElement ( "div" )
25+ notificationText . className = "notification-text"
26+ notificationText . innerText = config . text
27+
28+ notification . appendChild ( notificationText )
29+
30+ notifications . appendChild ( notification )
31+
32+ notifications . style . transition = "bottom 0.3s cubic-bezier(0.6, 0.4, 0, 1)"
33+ notifications . setAttribute ( "new" , "" )
34+
35+ setTimeout ( function ( ) {
36+ notifications . style . transition = "none"
37+ notifications . appendChild ( notification )
38+ notifications . removeAttribute ( "new" )
39+ notification . style . marginBottom = 0
40+ } , 300 )
41+
42+ this . removeNotification ( notification )
43+
44+ this . notifications . push ( notification )
45+ }
46+ }
47+
48+ var Notifications = new NotificationBuilder ( )
49+
50+ function NotificationsMain ( ) {
51+ return (
52+ < div id = "notifications" > </ div >
53+ )
54+ }
55+
56+ export { NotificationsMain , Notifications } ;
0 commit comments