react-notification
Advanced tools
Comparing version 6.7.1 to 6.8.0
@@ -24,6 +24,10 @@ 'use strict'; | ||
function defaultStyleFactory(index, style) { | ||
function defaultBarStyleFactory(index, style) { | ||
return _extends({}, style, { bottom: 2 + index * 4 + 'rem' }); | ||
} | ||
function defaultActionStyleFactory(index, style) { | ||
return _extends({}, style, {}); | ||
} | ||
/** | ||
@@ -44,2 +48,3 @@ * The notification list does not have any state, so use a | ||
var barStyle = props.barStyleFactory(index, notification.barStyle, notification); | ||
var actionStyle = props.actionStyleFactory(index, notification.actionStyle, notification); | ||
var activeBarStyle = props.activeBarStyleFactory(index, notification.activeBarStyle, notification); | ||
@@ -67,3 +72,4 @@ | ||
activeBarStyle: activeBarStyle, | ||
barStyle: barStyle | ||
barStyle: barStyle, | ||
actionStyle: actionStyle | ||
})); | ||
@@ -78,2 +84,3 @@ }) | ||
barStyleFactory: _propTypes2.default.func, | ||
actionStyleFactory: _propTypes2.default.func, | ||
dismissInOrder: _propTypes2.default.bool, | ||
@@ -87,4 +94,5 @@ notifications: _propTypes2.default.array.isRequired, | ||
NotificationStack.defaultProps = { | ||
activeBarStyleFactory: defaultStyleFactory, | ||
barStyleFactory: defaultStyleFactory, | ||
activeBarStyleFactory: defaultBarStyleFactory, | ||
barStyleFactory: defaultBarStyleFactory, | ||
actionStyleFactory: defaultActionStyleFactory, | ||
dismissInOrder: true, | ||
@@ -91,0 +99,0 @@ dismissAfter: 1000, |
@@ -30,1 +30,2 @@ ### Props | ||
| activeBarStyleFactory | func | create the style of the active notification | false | fn | | ||
| actionStyleFactory | func | create the style of the actions | false | fn | |
{ | ||
"name": "react-notification", | ||
"version": "6.7.1", | ||
"version": "6.8.0", | ||
"description": "Snackbar style notification component for React", | ||
@@ -5,0 +5,0 @@ "main": "dist/index.js", |
@@ -12,3 +12,4 @@ export default { | ||
actionStyle: { | ||
color: 'rgb(2, 2, 2)' | ||
color: 'rgb(2, 2, 2)', | ||
letterSpacing: '.125ex' | ||
}, | ||
@@ -15,0 +16,0 @@ activeBarStyle: { |
@@ -182,3 +182,3 @@ import React from 'react'; | ||
it('batStyleFactory should have access to notification', () => { | ||
it('barStyleFactory should have access to notification', () => { | ||
const styleFactory = (index, style, notification) => Object.assign( | ||
@@ -263,2 +263,62 @@ {}, | ||
it('actionStyleFactory should set correct style on notification', () => { | ||
const styleFactory = (index, style) => Object.assign( | ||
{}, | ||
style, | ||
{ color: 'blue' } | ||
); | ||
const stack = mount( | ||
<NotificationStack | ||
notifications={[mockNotification]} | ||
actionStyleFactory={styleFactory} | ||
onDismiss={() => {}} | ||
/> | ||
); | ||
const notification = stack.find(Notification); | ||
expect(notification.prop('actionStyle').color).to.equal('blue'); | ||
}); | ||
it('actionStyleFactory should respect notification actionBarStyle', () => { | ||
const styleFactory = (index, style) => Object.assign( | ||
{}, | ||
style, | ||
{ color: 'blue' } | ||
); | ||
const stack = mount( | ||
<NotificationStack | ||
notifications={[mockNotification]} | ||
actionStyleFactory={styleFactory} | ||
onDismiss={() => {}} | ||
/> | ||
); | ||
const notification = stack.find(Notification); | ||
expect(notification.prop('actionStyle').letterSpacing).to.equal('.125ex'); | ||
}); | ||
it('actionStyleFactory should have access to notification', () => { | ||
const styleFactory = (index, style, notification) => Object.assign( | ||
{}, | ||
style, | ||
{ color: notification.key === 1111111 ? 'green' : 'red' } | ||
); | ||
const stack = mount( | ||
<NotificationStack | ||
notifications={[mockNotification]} | ||
actionStyleFactory={styleFactory} | ||
onDismiss={() => {}} | ||
/> | ||
); | ||
const notification = stack.find(Notification); | ||
expect(notification.prop('actionStyle').color).to.equal('green'); | ||
}); | ||
/** | ||
@@ -265,0 +325,0 @@ * Test: Global handling of onClick: |
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
556415
1227