Skip to content
This repository has been archived by the owner on Mar 30, 2018. It is now read-only.

Commit

Permalink
pass onClick propse directly:
Browse files Browse the repository at this point in the history
  • Loading branch information
sureshHARDIYA committed Dec 20, 2016
1 parent 954f20f commit f632f43
Show file tree
Hide file tree
Showing 4 changed files with 4 additions and 18 deletions.
10 changes: 2 additions & 8 deletions src/Notify/NotifyMesssage.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,14 +33,8 @@ export default class NotifyMesssage extends Component {
this.setState({ isOpen: false }, () => setTimeout(() => this.setState({ isClosed: true }), 300))
}

handleClick = () => {
if (this.props.onClick) {
this.props.onClick()
}
}

render() {
const { children, type, icon } = this.props
const { children, type, icon, onClick } = this.props
const className = cx('uk-notify-message', {
'uk-notify-message-info': type === 'info',
'uk-notify-message-success': type === 'success',
Expand All @@ -61,7 +55,7 @@ export default class NotifyMesssage extends Component {
style={{ overflow: 'hidden', transition: 'margin ease-out 300ms', ...styles[this.state.isOpen ? 1 : 0] }}
>
<a className="uk-close" onClick={this.handleClose} />
<div onClick={this.handleClick}>
<div onClick={onClick}>
{icon && <i className={`uk-icon-justify uk-icon-${icon}`} /> }
{children}
</div>
Expand Down
8 changes: 0 additions & 8 deletions src/Notify/__tests__/NotifyMessage-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,4 @@ describe('NotifyMesssage', () => {
instance.openNotification()
expect(instance.state.isOpen).toBe(true)
})

it('should handle Message Click', () => {
const instance = component.getInstance()

instance.handleClick()

expect(defaultProps.onClick).toHaveBeenCalled()
})
})
2 changes: 1 addition & 1 deletion src/Notify/__tests__/__snapshots__/index-test.js.snap
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ exports[`Notify should render correctly 1`] = `
className="uk-close"
onClick={[Function]} />
<div
onClick={[Function]}>
onClick={undefined}>
Notification #1
</div>
</div>
Expand Down
2 changes: 1 addition & 1 deletion src/stories/Notify.js
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ storiesOf('Notify', module)
<NotificationsContainer isSticky position="top-right" type="info" />
<NotificationsContainer icon="check" position="bottom-right" type="success" />
<NotificationsContainer icon="check" position="bottom-left" timeout={10000} type="success" />
<NotificationsContainer icon="check" position="bottom-left" type="danger" onClick={action('handleClick')} />
<NotificationsContainer icon="check" position="top-right" timeout={5000} type="danger" onClick={action('handleClick')} />

</div>
), { header: false, inline: true, propTables: [Notify] })

0 comments on commit f632f43

Please sign in to comment.