forked from jaywcjlove/iNotify
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathApp.js
181 lines (177 loc) · 5.13 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
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
import React, { Component } from 'react';
import Markdown from './components/Markdown';
import GithubCorner from './components/GithubCorner';
import DocumentStr from '../README.md';
import GithubShields from './components/GithubShields';
import Button from './components/Button';
import Footer from './components/Footer';
import styles from './styles/index.less';
import './styles/reset.less';
import Notify from '../src/main';
import notifyImg from './assets/iNotify.png';
import mp4 from './assets/msg.mp4';
import mp3 from './assets/msg.mp3';
import wav from './assets/msg.wav';
export default class App extends Component {
constructor() {
super();
this.state = {
button: [
{
label: 'Popup box',
onClick: () => {
this.iN.notify({
title: 'Welcome to iNotify!',
body: 'You are opening the iNotify website!',
});
},
},
{
label: 'Play sound',
onClick: () => {
this.iN.player();
},
},
{
label: 'Stop playing sound',
onClick: () => {
this.iN.stopPlay();
},
},
{
label: 'Stop title animation',
onClick: () => {
this.iN.setTitle();
},
},
{
label: 'Play title animation',
onClick: () => {
this.iN.setTitle(true);
},
},
{
label: 'Title animation, update title',
onClick: () => {
this.iN.setTitle('Title animation, update title.');
},
},
{
label: 'Number of messages',
onClick: () => {
const num = Math.floor(Math.random() * 10) || 2;
this.iN.faviconClear().setFavicon(num + 1);
},
},
{
label: 'Clear the messages number',
onClick: () => {
this.iN.faviconClear();
},
},
{
label: 'Open website.',
onClick: () => {
this.iN.notify({
title: 'Welcome to iNotify!',
body: 'You are opening the iNotify website!',
openurl: 'https://github.com/jaywcjlove/iNotify',
onclick: () => {
console.log('on click');
this.iN.close();
},
onshow: () => {
console.log('on show');
},
});
},
},
{
label: 'Favicon Font color',
onClick: () => {
this.iN.setFaviconColor('#0043ff');
},
},
{
label: 'Favicon Background color',
onClick: () => {
this.iN.setFaviconColor('#f5ff00').setFaviconBackgroundColor('red');
},
},
],
};
}
componentDidMount() {
this.iN = new Notify({
// effect: 'flash',
effect: 'scroll',
interval: 300,
message: '有消息拉!',
audio: {
file: [mp4, mp3, wav],
},
notification: {
title: '通知!',
body: '您来了一条新消息',
},
onclick: () => {
console.log('on click');
this.iN.close();
},
});
this.iN.setTitle('New news, welcome to iNotify!')
.notify({
title: 'Welcome to iNotify!',
body: 'You are opening the iNotify website!',
openurl: 'https://github.com/jaywcjlove/iNotify',
})
.player();
}
render() {
const { button } = this.state;
let DocumentStrSource = DocumentStr;
if (DocumentStrSource) DocumentStrSource = DocumentStr.replace(/([\s\S]*)<!--dividing-->/, '');
return (
<div className={styles.wapper}>
<GithubCorner url="https://github.com/jaywcjlove/iNotify" />
<div className={styles.panel}>
<h1>
iNotify
</h1>
<img src={notifyImg} alt="iNotify" />
</div>
<div className={styles.button}>
{button.map((item, key) => {
return (
<Button key={key} onClick={item.onClick}>
{item.label}
</Button>
);
})}
</div>
<Markdown source={DocumentStrSource} />
<GithubShields
source={[
{
href: 'https://github.com/jaywcjlove/iNotify/stargazers',
img: 'https://img.shields.io/github/stars/jaywcjlove/iNotify.svg?style=social',
},
{
href: 'https://github.com/jaywcjlove/iNotify/network',
img: 'https://img.shields.io/github/forks/jaywcjlove/iNotify.svg?style=social',
},
{
href: 'https://github.com/jaywcjlove/iNotify/watchers',
img: 'https://img.shields.io/github/watchers/jaywcjlove/iNotify.svg?style=social&label=Watch',
},
{
href: 'https://github.com/jaywcjlove/followers',
img: 'https://img.shields.io/github/followers/jaywcjlove.svg?style=social',
},
]}
/>
<Footer name="Kenny Wong" href="http://jaywcjlove.github.io" year="2015-present" />
</div>
);
}
}