Skip to content

Commit 19232e1

Browse files
committed
#56, #52, #46 fixes and refactoring
1 parent 1aa9e30 commit 19232e1

20 files changed

+116
-92
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,7 @@ You have in total 6 containers for desktop and 2 for mobile, if component is set
126126
* `top-left`
127127
* `top-right`
128128
* `top-center`
129+
* `center`
129130
* `bottom-left`
130131
* `bottom-right`
131132
* `bottom-center`

samples/js/components/App.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import React from 'react';
2-
import ReactNotification from 'rc-notifications/react-notification-component';
2+
import ReactNotification from 'rc-notifications';
33
import Header from 'components/Header';
44
import Content from 'components/Content';
55
import GithubCorner from 'react-github-corner';

samples/js/components/examples/AnimationExample.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import React from 'react';
22
import notification from 'helpers/notification';
3-
import { store } from 'rc-notifications/react-notification-component';
3+
import { store } from 'rc-notifications';
44
import { getContainer, getType, getMessage } from 'helpers/randomize';
55

66
function AnimationInExample() {

samples/js/components/examples/ContainerExample.js

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import React from 'react';
22
import notification from 'helpers/notification';
3-
import { store } from 'rc-notifications/react-notification-component';
3+
import { store } from 'rc-notifications';
44
import { getType, getMessage, getTitle } from 'helpers/randomize';
55

66
export default class ContainerExample extends React.Component {
@@ -58,6 +58,13 @@ export default class ContainerExample extends React.Component {
5858
>
5959
Top Center
6060
</button>{' '}
61+
<button
62+
type="button"
63+
className="btn btn-outline-secondary"
64+
onClick={() => this.add('center')}
65+
>
66+
Center
67+
</button>{' '}
6168
<button
6269
type="button"
6370
className="btn btn-outline-secondary"

samples/js/components/examples/CustomContentExample.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import React from 'react';
22
import notification from 'helpers/notification';
33
import reactImage from 'images/react.png';
44
import { getContainer } from 'helpers/randomize';
5-
import { store } from 'rc-notifications/react-notification-component';
5+
import { store } from 'rc-notifications';
66

77
export default class CustomContentExample extends React.Component {
88
constructor(props) {

samples/js/components/examples/InsertExample.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import React from 'react';
22
import notification from 'helpers/notification';
3-
import { store } from 'rc-notifications/react-notification-component';
3+
import { store } from 'rc-notifications';
44
import { getType, getMessage, getTitle } from 'helpers/randomize';
55

66
export default function InsertExample() {

samples/js/components/examples/TypeExample.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import React from 'react';
22
import notification from 'helpers/notification';
3-
import { store } from 'rc-notifications/react-notification-component';
3+
import { store } from 'rc-notifications';
44
import { getContainer, getMessage, getTitle } from 'helpers/randomize';
55

66
export default class TypeExample extends React.Component {

samples/js/helpers/randomize.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ const containers = [
22
'top-left',
33
'top-right',
44
'top-center',
5+
'center',
56
'bottom-left',
67
'bottom-right',
78
'bottom-center'

samples/styles/stylesheet.scss

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ body {
1313

1414
html,
1515
body,
16-
.n-parent,
16+
.notification-parent,
1717
.notification-title,
1818
.notification-message,
1919
.notification-item {

src/react-notification-component.js renamed to src/components/Container.js

Lines changed: 18 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
import React from 'react';
22
import PropTypes from 'prop-types';
3-
import store from './store';
4-
import ReactNotification from './react-notification';
5-
import { getNotificationsForEachContainer, getNotificationsForMobileView } from './utils/helpers';
3+
import store from '../store';
4+
import ReactNotification from './Notification';
5+
import { getNotificationsForEachContainer, getNotificationsForMobileView } from '../utils/helpers';
66

77
import 'src/scss/notification.scss';
88

9-
export default class ReactNotificationComponent extends React.Component {
9+
class Container extends React.Component {
1010
constructor(props) {
1111
super(props);
1212

@@ -107,11 +107,7 @@ export default class ReactNotificationComponent extends React.Component {
107107
const bottom = this.renderNotifications(mobileNotifications.bottom);
108108

109109
return (
110-
<div
111-
id={id}
112-
key='mobile'
113-
className={`react-notification-root ${className || ''}`}
114-
>
110+
<div id={id} key="mobile" className={`react-notification-root ${className || ''}`}>
115111
<div className="notification-container-mobile-top">{top}</div>
116112
<div className="notification-container-mobile-bottom">{bottom}</div>
117113
</div>
@@ -121,25 +117,25 @@ export default class ReactNotificationComponent extends React.Component {
121117
renderScreenNotifications(props) {
122118
const { className, id } = props;
123119
const { notifications } = this.state;
124-
const notificationsPerContainer = getNotificationsForEachContainer(notifications);
125-
const topLeft = this.renderNotifications(notificationsPerContainer.topLeft);
126-
const topRight = this.renderNotifications(notificationsPerContainer.topRight);
127-
const topCenter = this.renderNotifications(notificationsPerContainer.topCenter);
128-
const bottomLeft = this.renderNotifications(notificationsPerContainer.bottomLeft);
129-
const bottomRight = this.renderNotifications(notificationsPerContainer.bottomRight);
130-
const bottomCenter = this.renderNotifications(notificationsPerContainer.bottomCenter);
120+
const items = getNotificationsForEachContainer(notifications);
121+
const topLeft = this.renderNotifications(items.topLeft);
122+
const topRight = this.renderNotifications(items.topRight);
123+
const topCenter = this.renderNotifications(items.topCenter);
124+
const bottomLeft = this.renderNotifications(items.bottomLeft);
125+
const bottomRight = this.renderNotifications(items.bottomRight);
126+
const bottomCenter = this.renderNotifications(items.bottomCenter);
127+
const center = this.renderNotifications(items.center);
131128

132129
return (
133-
<div
134-
id={id}
135-
key='screen'
136-
className={`react-notification-root ${className || ''}`}
137-
>
130+
<div id={id} key="screen" className={`react-notification-root ${className || ''}`}>
138131
<div className="notification-container-top-left">{topLeft}</div>
139132
<div className="notification-container-top-right">{topRight}</div>
140133
<div className="notification-container-bottom-left">{bottomLeft}</div>
141134
<div className="notification-container-bottom-right">{bottomRight}</div>
142135
<div className="notification-container-top-center">{topCenter}</div>
136+
<div className="notification-container-center">
137+
<div className="center-inner">{center}</div>
138+
</div>
143139
<div className="notification-container-bottom-center">{bottomCenter}</div>
144140
</div>
145141
);
@@ -157,4 +153,4 @@ export default class ReactNotificationComponent extends React.Component {
157153
}
158154
}
159155

160-
export { store };
156+
export default Container;

0 commit comments

Comments
 (0)