react-notification
Advanced tools
Comparing version 6.3.0 to 6.4.0
# Contributing | ||
**Imperative: pull requests must include tests and documentation and issues must follow guidelines.** | ||
**It is imperative that pull requests include tests and documentation and issues follow guidelines.** Please be familar with the [GitHub Community Guidelines](https://help.github.com/articles/github-community-guidelines/) before contributing to this project. If you are new to open source, check out this 38 minute course on [how to contribute to open source on GitHub](https://egghead.io/courses/how-to-contribute-to-an-open-source-project-on-github). It's free! :smile: | ||
@@ -5,0 +5,0 @@ ## Getting Started |
@@ -36,2 +36,3 @@ 'use strict'; | ||
var isLast = index === 0 && props.notifications.length === 1; | ||
var dismissNow = isLast || !props.dismissInOrder; | ||
var barStyle = props.barStyleFactory(index, notification.barStyle); | ||
@@ -44,3 +45,3 @@ var activeBarStyle = props.activeBarStyleFactory(index, notification.activeBarStyle); | ||
action: notification.action || props.action, | ||
dismissAfter: isLast ? dismissAfter : dismissAfter + index * 1000, | ||
dismissAfter: dismissNow ? dismissAfter : dismissAfter + index * 1000, | ||
onDismiss: props.onDismiss.bind(undefined, notification), | ||
@@ -55,2 +56,3 @@ activeBarStyle: activeBarStyle, | ||
NotificationStack.propTypes = { | ||
dismissInOrder: _react.PropTypes.bool, | ||
activeBarStyleFactory: _react.PropTypes.func, | ||
@@ -63,2 +65,3 @@ barStyleFactory: _react.PropTypes.func, | ||
NotificationStack.defaultProps = { | ||
dismissInOrder: true, | ||
dismissAfter: 1000, | ||
@@ -65,0 +68,0 @@ activeBarStyleFactory: defaultStyleFactory, |
{ | ||
"name": "react-notification", | ||
"version": "6.3.0", | ||
"version": "6.4.0", | ||
"description": "Snackbar style notification component for React.", | ||
@@ -5,0 +5,0 @@ "main": "dist/index.js", |
@@ -107,7 +107,8 @@ # react-notification | ||
| Name | Type | Description | Required | Default | | ||
|-----------------------|-------|----------------------------------------------|---------- |----------| | ||
| notifications | array | Array of notifications to render | true | | | ||
| barStyleFactory | func | create the style of the notification | false | fn | | ||
| activeBarStyleFactory | func | create the style of the active notification | false | fn | | ||
| Name | Type | Description | Required | Default | | ||
|-----------------------|-------|----------------------------------------------------------|---------- |----------| | ||
| notifications | array | Array of notifications to render | true | | | ||
| dismissInOrder | bool | If false, notification dismiss timers start immediately | false | true | | ||
| barStyleFactory | func | create the style of the notification | false | fn | | ||
| activeBarStyleFactory | func | create the style of the active notification | false | fn | | ||
@@ -114,0 +115,0 @@ **Update** `v5.0.3`: Now notifications used in a stack _can_ have all properties included in the regular notification component. |
@@ -36,2 +36,26 @@ import React from 'react'; | ||
it('notifications dismissed independently if `dismissInOrder` set to false', done => { | ||
const handleDismiss = spy(); | ||
const wrapper = mount( | ||
<NotificationStack | ||
dismissInOrder={false} | ||
notifications={notifications} | ||
onDismiss={handleDismiss} | ||
/> | ||
); | ||
wrapper.update(); | ||
setTimeout(() => { | ||
try { | ||
expect(handleDismiss.calledTwice).to.equal(true); | ||
done(); | ||
} catch (e) { | ||
done(e); | ||
} | ||
// Add time due to each StackedNotification transition time ( > 300 ) | ||
}, mockNotification.dismissAfter + 340); | ||
}); | ||
it('onDismiss fires after `dismissAfter` value + transition time', done => { | ||
@@ -38,0 +62,0 @@ const handleDismiss = spy(); |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
373196
938
182