Skip to content

Commit a18e8dd

Browse files
committed
feature: add onClick function
Closes #7
1 parent b011f4a commit a18e8dd

1 file changed

Lines changed: 32 additions & 32 deletions

File tree

index.js

Lines changed: 32 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -90,21 +90,15 @@ class NotificationAlert extends React.Component {
9090
if(options.closeButton !== false){
9191
toggle = () => this.onDismiss(nNumber, options.place);
9292
}
93-
var notification = React.createElement(
94-
Alert,
95-
{
96-
color: options.type,
97-
className: "alert-with-icon animated fadeInDown",
98-
toggle,
99-
key: nNumber
100-
},
101-
options.icon !== undefined
102-
? React.createElement("span", {
103-
"data-notify": "icon",
104-
className: options.icon
105-
})
106-
: null,
107-
React.createElement("span", { "data-notify": "message" }, options.message)
93+
var notification = (
94+
<Alert color={options.type} className="alert-with-icon animated fadeInDown" toggle={toggle} key={nNumber} onClick={this.props.onClick}>
95+
{
96+
options.icon !== undefined && (
97+
<span data-notify="icon" className={options.icon}></span>
98+
)
99+
}
100+
<span data-notify="message">{options.message}</span>
101+
</Alert>
108102
);
109103
if (options.place.indexOf("b") !== -1) {
110104
notify.unshift(notification);
@@ -169,35 +163,41 @@ class NotificationAlert extends React.Component {
169163
break;
170164
}
171165
}
172-
return React.createElement(
173-
Col,
174-
{ xs: 11, sm: 4, style: style },
175-
this.state["notify" + place.toUpperCase()].map((prop, key) => {
176-
return prop;
177-
})
166+
return (
167+
<>
168+
<Col xs="11" sm="4" style={style}>
169+
{this.state["notify" + place.toUpperCase()].map((prop, key) => {
170+
return prop;
171+
})}
172+
</Col>
173+
</>
178174
);
179175
}
180176
}
181177
render() {
182-
return React.createElement(
183-
"div",
184-
{ ref: this.refNotification },
185-
this.showAllNotifications("tl"),
186-
this.showAllNotifications("tc"),
187-
this.showAllNotifications("tr"),
188-
this.showAllNotifications("bl"),
189-
this.showAllNotifications("bc"),
190-
this.showAllNotifications("br")
178+
return (
179+
<>
180+
<div ref={this.refNotification}>
181+
{this.showAllNotifications("tl")}
182+
{this.showAllNotifications("tc")}
183+
{this.showAllNotifications("tr")}
184+
{this.showAllNotifications("bl")}
185+
{this.showAllNotifications("bc")}
186+
{this.showAllNotifications("br")}
187+
</div>
188+
</>
191189
);
192190
}
193191
}
194192

195193
NotificationAlert.defaultProps = {
196-
zIndex: 9999
194+
zIndex: 9999,
195+
onClick: () => {},
197196
};
198197

199198
NotificationAlert.propTypes = {
200-
zIndex: PropTypes.number
199+
zIndex: PropTypes.number,
200+
onClick: PropTypes.func,
201201
}
202202

203203
export default NotificationAlert;

0 commit comments

Comments
 (0)