UNPKG

6.35 kBMarkdownView Raw
1# rc-notification
2---
3
4React Notification UI Component
5
6[![NPM version][npm-image]][npm-url]
7[![build status][travis-image]][travis-url]
8[![Test coverage][coveralls-image]][coveralls-url]
9[![Dependencies][david-image]][david-url]
10[![DevDependencies][david-dev-image]][david-dev-url]
11[![npm download][download-image]][download-url]
12[![bundle size][bundlephobia-image]][bundlephobia-url]
13
14[npm-image]: http://img.shields.io/npm/v/rc-notification.svg?style=flat-square
15[npm-url]: http://npmjs.org/package/rc-notification
16[travis-image]: https://img.shields.io/travis/react-component/notification/master?style=flat-square
17[travis-url]: https://travis-ci.org/react-component/notification
18[coveralls-image]: https://img.shields.io/coveralls/react-component/notification.svg?style=flat-square
19[coveralls-url]: https://coveralls.io/r/react-component/notification?branch=master
20[david-url]: https://david-dm.org/react-component/notification
21[david-image]: https://david-dm.org/react-component/notification/status.svg?style=flat-square
22[david-dev-url]: https://david-dm.org/react-component/notification?type=dev
23[david-dev-image]: https://david-dm.org/react-component/notification/dev-status.svg?style=flat-square
24[download-image]: https://img.shields.io/npm/dm/rc-notification.svg?style=flat-square
25[download-url]: https://npmjs.org/package/rc-notification
26[bundlephobia-url]: https://bundlephobia.com/result?p=rc-notification
27[bundlephobia-image]: https://badgen.net/bundlephobia/minzip/rc-notification
28
29## Install
30
31[![rc-notification](https://nodei.co/npm/rc-notification.png)](https://npmjs.org/package/rc-notification)
32
33## Usage
34
35```js
36import Notification from 'rc-notification';
37
38Notification.newInstance({}, notification => {
39 notification.notice({
40 content: 'content'
41 });
42});
43```
44
45## Compatibility
46
47| [<img src="https://raw.githubusercontent.com/alrra/browser-logos/master/src/edge/edge_48x48.png" alt="IE / Edge" width="24px" height="24px" />](http://godban.github.io/browsers-support-badges/)<br>IE / Edge | [<img src="https://raw.githubusercontent.com/alrra/browser-logos/master/src/firefox/firefox_48x48.png" alt="Firefox" width="24px" height="24px" />](http://godban.github.io/browsers-support-badges/)<br>Firefox | [<img src="https://raw.githubusercontent.com/alrra/browser-logos/master/src/chrome/chrome_48x48.png" alt="Chrome" width="24px" height="24px" />](http://godban.github.io/browsers-support-badges/)<br>Chrome | [<img src="https://raw.githubusercontent.com/alrra/browser-logos/master/src/safari/safari_48x48.png" alt="Safari" width="24px" height="24px" />](http://godban.github.io/browsers-support-badges/)<br>Safari | [<img src="https://raw.githubusercontent.com/alrra/browser-logos/master/src/electron/electron_48x48.png" alt="Electron" width="24px" height="24px" />](http://godban.github.io/browsers-support-badges/)<br>Electron |
48| --- | --- | --- | --- | --- |
49| IE11, Edge | last 2 versions | last 2 versions | last 2 versions | last 2 versions |
50
51## Example
52
53http://localhost:8001
54
55online example: http://react-component.github.io/notification/
56
57## API
58
59### Notification.newInstance(props, (notification) => void) => void
60
61props details:
62
63<table class="table table-bordered table-striped">
64 <thead>
65 <tr>
66 <th style="width: 100px;">name</th>
67 <th style="width: 50px;">type</th>
68 <th style="width: 50px;">default</th>
69 <th>description</th>
70 </tr>
71 </thead>
72 <tbody>
73 <tr>
74 <td>prefixCls</td>
75 <td>String</td>
76 <td></td>
77 <td>prefix class name for notification container</td>
78 </tr>
79 <tr>
80 <td>style</td>
81 <td>Object</td>
82 <td>{'top': 65, left: '50%'}</td>
83 <td>additional style for notification container.</td>
84 </tr>
85 <tr>
86 <td>getContainer</td>
87 <td>getContainer(): HTMLElement</td>
88 <td></td>
89 <td>function returning html node which will act as notification container</td>
90 </tr>
91 <tr>
92 <td>maxCount</td>
93 <td>number</td>
94 <td></td>
95 <td>max notices show, drop first notice if exceed limit</td>
96 </tr>
97 </tbody>
98</table>
99
100### notification.notice(props)
101
102props details:
103
104<table class="table table-bordered table-striped">
105 <thead>
106 <tr>
107 <th style="width: 100px;">name</th>
108 <th style="width: 50px;">type</th>
109 <th style="width: 50px;">default</th>
110 <th>description</th>
111 </tr>
112 </thead>
113 <tbody>
114 <tr>
115 <td>content</td>
116 <td>React.Element</td>
117 <td></td>
118 <td>content of notice</td>
119 </tr>
120 <tr>
121 <td>key</td>
122 <td>String</td>
123 <td></td>
124 <td>id of this notice</td>
125 </tr>
126 <tr>
127 <td>closable</td>
128 <td>Boolean</td>
129 <td></td>
130 <td>whether show close button</td>
131 </tr>
132 <tr>
133 <td>onClose</td>
134 <td>Function</td>
135 <td></td>
136 <td>called when notice close</td>
137 </tr>
138 <tr>
139 <td>duration</td>
140 <td>number</td>
141 <td>1.5</td>
142 <td>after duration of time, this notice will disappear.(seconds)</td>
143 </tr>
144 <tr>
145 <td>style</td>
146 <td>Object</td>
147 <td> { right: '50%' } </td>
148 <td>additional style for single notice node.</td>
149 </tr>
150 <tr>
151 <td>closeIcon</td>
152 <td>ReactNode</td>
153 <td></td>
154 <td>specific the close icon.</td>
155 </tr>
156 <tr>
157 <td>props</td>
158 <td>Object</td>
159 <td></td>
160 <td>An object that can contain <code>data-*</code>, <code>aria-*</code>, or <code>role</code> props, to be put on the notification <code>div</code>. This currently only allows <code>data-testid</code> instead of <code>data-*</code> in TypeScript. See https://github.com/microsoft/TypeScript/issues/28960.</td>
161 </tr>
162 </tbody>
163</table>
164
165### notification.removeNotice(key:string)
166
167remove single notice with specified key
168
169### notification.destroy()
170
171destroy current notification
172
173## Test Case
174
175```
176npm test
177npm run chrome-test
178```
179
180## Coverage
181
182```
183npm run coverage
184```
185
186open coverage/ dir
187
188## License
189
190rc-notification is released under the MIT license.