Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

react-notification-center

Package Overview
Dependencies
Maintainers
1
Versions
15
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

react-notification-center - npm Package Compare versions

Comparing version 1.0.1 to 1.1.0

53

lib/index.js

@@ -18,4 +18,2 @@ 'use strict';

var _emitter = require('./emitter');
var _Item = require('./Item');

@@ -43,4 +41,2 @@

function _toConsumableArray(arr) { if (Array.isArray(arr)) { for (var i = 0, arr2 = Array(arr.length); i < arr.length; i++) { arr2[i] = arr[i]; } return arr2; } else { return Array.from(arr); } }
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }

@@ -70,3 +66,2 @@

_this.getUnreadLength = _this.getUnreadLength.bind(_this);
_this.renderNotificationItem = _this.renderNotificationItem.bind(_this);
_this.toggleNotification = _this.toggleNotification.bind(_this);

@@ -77,17 +72,2 @@ return _this;

ReduxnotificationCenter.prototype.componentDidMount = function componentDidMount() {
var _this2 = this;
_emitter.EE.on('add/notification', function (data) {
_this2.setState({
notifications: [data].concat(_toConsumableArray(_this2.state.notifications))
});
});
_emitter.EE.on('clear/all', function () {
_this2.setState({
notifications: [],
showNotification: false,
current: null
});
});
if (document) {

@@ -109,4 +89,2 @@ document.addEventListener('click', this.toggleNotification);

ReduxnotificationCenter.prototype.componentWillUnmount = function componentWillUnmount() {
_emitter.EE.off('add/notification');
_emitter.EE.off('clear/all');
if (document) {

@@ -118,6 +96,6 @@ document.removeEventListener('click', this.toggleNotification);

ReduxnotificationCenter.prototype.getUnreadLength = function getUnreadLength() {
var _this3 = this;
var _this2 = this;
return this.state.notifications.filter(function (item) {
return !item[_this3.mapOptions().new];
return !item[_this2.mapOptions().new];
}).length;

@@ -167,13 +145,13 @@ };

ReduxnotificationCenter.prototype.onItemClick = function onItemClick(item) {
var _this4 = this;
var _this3 = this;
this.setState({
notifications: this.state.notifications.map(function (notification) {
if (!notification[_this4.mapOptions().id]) {
console.error('React Notification ERROR: For more information about this issue http://localhost:4001/');
if (!notification[_this3.mapOptions().id]) {
console.error('React Notification ERROR: You need an id');
return notification;
}
if (notification[_this4.mapOptions().id] == item[_this4.mapOptions().id]) {
notification[_this4.mapOptions().new] = true;
if (notification[_this3.mapOptions().id] == item[_this3.mapOptions().id]) {
notification[_this3.mapOptions().new] = true;
}

@@ -196,14 +174,4 @@ return notification;

ReduxnotificationCenter.prototype.renderNotificationItem = function renderNotificationItem(item, i) {
if (this.props.customItemComponent) {
return _react2.default.createElement(this.props.customItemComponent, _extends({ key: i }, item));
}
return _react2.default.createElement(_Item2.default, _extends({
key: i, onClick: this.onItemClick.bind(this, item),
options: this.mapOptions()
}, item));
};
ReduxnotificationCenter.prototype.render = function render() {
var _this5 = this;
var _this4 = this;

@@ -244,3 +212,6 @@ return _react2.default.createElement(

this.state.notifications.map(function (item, i) {
return _this5.renderNotificationItem(item, i);
return _react2.default.createElement(_Item2.default, _extends({
key: i, onClick: _this4.onItemClick.bind(_this4, item),
options: _this4.mapOptions()
}, item));
})

@@ -247,0 +218,0 @@ )

{
"name": "react-notification-center",
"version": "1.0.1",
"version": "1.1.0",
"description": "react-notification-center keep all your notification in a single place",

@@ -5,0 +5,0 @@ "main": "lib/index.js",

@@ -50,3 +50,2 @@ ## NOTE:

onScroll={e => console.log('You are scrolling', e)}
customItemComponent={ReactComponent} // In case you don't wanna use the default item component
</div>

@@ -84,3 +83,3 @@ </div>

Clone the repo and run a local demo
```

@@ -93,5 +92,5 @@ git clone https://github.com/diegoddox/react-notification-center.git

and take a look at the file `developement/App.js`
open your browser att `http://localhost:4001` and take a look at the file `developement/App.js`
### TODO:
improve documentation.
import React, {Component, PropTypes} from 'react';
import cn from 'classnames';
import {EE} from './emitter';
import NotificationItem from './Item';

@@ -47,3 +46,2 @@ import Header from './header';

this.getUnreadLength = this.getUnreadLength.bind(this);
this.renderNotificationItem = this.renderNotificationItem.bind(this);
this.toggleNotification = this.toggleNotification.bind(this);

@@ -53,18 +51,2 @@ }

componentDidMount() {
EE.on('add/notification', (data) => {
this.setState({
notifications: [
data,
...this.state.notifications
]
});
});
EE.on('clear/all', () => {
this.setState({
notifications: [],
showNotification: false,
current: null
});
});
if (document) {

@@ -87,4 +69,2 @@ document.addEventListener('click', this.toggleNotification);

componentWillUnmount() {
EE.off('add/notification');
EE.off('clear/all');
if (document) {

@@ -143,3 +123,3 @@ document.removeEventListener('click', this.toggleNotification);

if (!notification[this.mapOptions().id]) {
console.error('React Notification ERROR: For more information about this issue http://localhost:4001/');
console.error('React Notification ERROR: You need an id');
return notification;

@@ -167,14 +147,2 @@ }

renderNotificationItem(item, i) {
if (this.props.customItemComponent) {
return <this.props.customItemComponent key={i} {...item} />;
}
return (
<NotificationItem
key={i} onClick={this.onItemClick.bind(this, item)}
options={this.mapOptions()}
{...item}/>
);
}
render() {

@@ -198,3 +166,8 @@ return (

{this.state.notifications.map((item, i) => {
return this.renderNotificationItem(item, i);
return (
<NotificationItem
key={i} onClick={this.onItemClick.bind(this, item)}
options={this.mapOptions()}
{...item}/>
);
})}

@@ -201,0 +174,0 @@ </ul>

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc