-
Notifications
You must be signed in to change notification settings - Fork 0
/
app.js
153 lines (132 loc) · 3.46 KB
/
app.js
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
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
import React, { Component } from 'react';
import ReactDOM from 'react-dom';
import styled from 'styled-components';
import NotificationSystem from './src/NotificationSystem';
import 'styles/example.css';
import 'styles/base.css';
const Layout = styled.div`
width: 1000px;
margin: 0 auto;
padding-top:30px;
`;
const Overlay = styled.div`
background: url(${require('./assets/images/congruent_pentagon.png')}) top left repeat;
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
opacity: 0.3;
background-attachment: fixed;
`;
const Content = styled.div`
text-align: center;
margin-bottom: 20px;
`;
const Title = styled.h1`
font-size: 64px;
letter-spacing: -1px;
color: #FFF;
margin-top: 15px;
margin-bottom: 15px;
`;
const TitleH2 = Title.extend`
font-size: 28px;
`;
const Button = styled.span`
font-size: 16px;
text-align: center;
color: #fff;
padding: 10px;
background-color: #6060e8;
margin-bottom: 15px;
margin-right: 15px;
display: inline-block;
width: 100px;
cursor: pointer;
`;
const Buttons = styled.div`
position: relative;
text-align: center;
`;
const ConfirmNotify = () => (
<div>ConfirmNotify test</div>
);
class App extends Component {
NOTIFY = null
static defaultProps = {
notifySettings: {
base : {
level : 'warning',
position : 'tr',
message : 'base notification',
autoDismiss: 20
},
success: {
level : 'success',
message : 'success notification',
position: 'tr',
},
error : {
level : 'error',
message : 'error notification',
position : 'tr',
autoDismiss: 20,
},
warning: {
level : 'warning',
message : <ConfirmNotify />,
position : 'tr',
allowHTML: true,
autoDismiss: 10000,
},
confirm: {
level : 'success',
message : 'custom notification',
position : 'tr',
autoDismiss : 10,
getContentComponent: () => <ConfirmNotify />
}
}
}
addNotify = (type) => {
const { notifySettings } = this.props;
if (type && notifySettings[type]) {
const settings = notifySettings[type];
this.NOTIFY.addNotification({
...settings
});
}
}
render() {
return (
<Layout>
<Overlay />
<NotificationSystem
noAnimation
ref={el => (this.NOTIFY = el)}
/>
<Content>
<Title>React Notification System</Title>
<TitleH2>A complete and totally customizable component for notifications in React.</TitleH2>
</Content>
<Buttons>
<Button onClick={() => this.addNotify('base')}>add base</Button>
<Button onClick={() => this.addNotify('success')}>add success</Button>
<Button onClick={() => this.addNotify('error')}>add error</Button>
<Button onClick={() => this.addNotify('warning')}>add warning</Button>
<Button onClick={() => this.addNotify('confirm')}>add confirm</Button>
</Buttons>
</Layout>
);
}
}
function initApp() {
ReactDOM.render(
<App />,
document.querySelector('#MAIN_CONTENT')
);
}
document.addEventListener('DOMContentLoaded', () => {
initApp();
});