Skip to content

Commit 53d54e6

Browse files
author
Daniel Jorgensen
committed
added props.show
1 parent 6734e76 commit 53d54e6

File tree

4 files changed

+22
-5
lines changed

4 files changed

+22
-5
lines changed

README.md

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -36,15 +36,16 @@ Changes in version 4.0
3636
-----
3737

3838
* Added `prop-types` as peer dependency
39-
* Added props.showConfirm to allow hiding the confirm button
39+
* Added `props.showConfirm` to allow hiding the confirm button
40+
* Added `props.show` to allow hiding the confirm button
4041

4142
Changes in version 3.0
4243
-----
4344

44-
* You no longer need to inlcude lib/css/animations.css in your app.
45-
* Removed props.content (use props.children)
46-
* Removed props.inputPlaceHolder (use props.placeholder)
47-
* Removed props.inputValidationMsg (use props.validationMsg)
45+
* You no longer need to inlcude `lib/css/animations.css` in your app.
46+
* Removed `props.content` (use `props.children`)
47+
* Removed `props.inputPlaceHolder` (use `props.placeholder`)
48+
* Removed `props.inputValidationMsg` (use `props.validationMsg`)
4849

4950
Examples
5051
--------
@@ -170,6 +171,7 @@ Configuration
170171
| confirmBtnBsStyle | no | string | 'primary' | Bootstrap style of confirm button. Allowed values: 'default', 'primary', 'link', 'info', 'success', 'warning', 'danger' |
171172
| customIcon | no | string, node | undefined | Either a string url for an image to use as the icon, or JSX/ReactNode. |
172173
| placeholder | no | string | undefined | If type is input, this is the placeholder for the input field. |
174+
| show | no | bool | true | If false, the alert will not be rendered. |
173175
| required | no | bool | true | If true, requires the input field to have a value. |
174176
| validationMsg | no | string | 'Please enter a response!' | If type is input, this is the message to diplay when the user clicks confirm without entering a value. |
175177
| defaultValue | no | string | undefined | If type is input, this is the default value for the input field. |

lib/components/SweetAlert.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ export default class SweetAlert extends React.Component {
4040
cancelBtnBsStyle : PropTypes.oneOf(['default', 'primary', 'link', 'info', 'success', 'warning', 'danger']),
4141
confirmBtnBsStyle : PropTypes.oneOf(['default', 'primary', 'link', 'info', 'success', 'warning', 'danger']),
4242
customIcon : PropTypes.oneOfType([PropTypes.node, PropTypes.string]),
43+
show : PropTypes.bool,
4344
required : PropTypes.bool,
4445
placeholder : PropTypes.string,
4546
validationMsg : PropTypes.string,
@@ -65,6 +66,7 @@ export default class SweetAlert extends React.Component {
6566
inputType : 'text',
6667
customClass : '',
6768
hideOverlay : false,
69+
show : true,
6870
required : true,
6971
disabled : false,
7072
beforeMount : () => {},
@@ -229,6 +231,9 @@ export default class SweetAlert extends React.Component {
229231
};
230232

231233
render() {
234+
if (!this.props.show) {
235+
return false;
236+
}
232237
return (
233238
<div>
234239

lib/demo/dist/demo.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22633,6 +22633,9 @@
2263322633
}, {
2263422634
key: 'render',
2263522635
value: function render() {
22636+
if (!this.props.show) {
22637+
return false;
22638+
}
2263622639
return _react2.default.createElement('div', null, _react2.default.createElement('style', { type: 'text/css', scoped: true }, '@-webkit-keyframes showSweetAlert {\n 0% {\n transform: scale(0.7);\n -webkit-transform: scale(0.7);\n }\n 45% {\n transform: scale(1.05);\n -webkit-transform: scale(1.05);\n }\n 80% {\n transform: scale(0.95);\n -webkit-tranform: scale(0.95);\n }\n 100% {\n transform: scale(1);\n -webkit-transform: scale(1);\n }\n }\n @keyframes showSweetAlert {\n 0% {\n transform: scale(0.7);\n -webkit-transform: scale(0.7);\n }\n 45% {\n transform: scale(1.05);\n -webkit-transform: scale(1.05);\n }\n 80% {\n transform: scale(0.95);\n -webkit-tranform: scale(0.95);\n }\n 100% {\n transform: scale(1);\n -webkit-transform: scale(1);\n }\n }\n @-webkit-keyframes hideSweetAlert {\n 0% {\n transform: scale(1);\n -webkit-transform: scale(1);\n }\n 100% {\n transform: scale(0.5);\n -webkit-transform: scale(0.5);\n }\n }\n @keyframes hideSweetAlert {\n 0% {\n transform: scale(1);\n -webkit-transform: scale(1);\n }\n 100% {\n transform: scale(0.5);\n -webkit-transform: scale(0.5);\n }\n }\n @-webkit-keyframes animateSuccessTip {\n 0% {\n width: 0;\n left: 1px;\n top: 19px;\n }\n 54% {\n width: 0;\n left: 1px;\n top: 19px;\n }\n 70% {\n width: 50px;\n left: -8px;\n top: 37px;\n }\n 84% {\n width: 17px;\n left: 21px;\n top: 48px;\n }\n 100% {\n width: 25px;\n left: 14px;\n top: 45px;\n }\n }\n @keyframes animateSuccessTip {\n 0% {\n width: 0;\n left: 1px;\n top: 19px;\n }\n 54% {\n width: 0;\n left: 1px;\n top: 19px;\n }\n 70% {\n width: 50px;\n left: -8px;\n top: 37px;\n }\n 84% {\n width: 17px;\n left: 21px;\n top: 48px;\n }\n 100% {\n width: 25px;\n left: 14px;\n top: 45px;\n }\n }\n @-webkit-keyframes animateSuccessLong {\n 0% {\n width: 0;\n right: 46px;\n top: 54px;\n }\n 65% {\n width: 0;\n right: 46px;\n top: 54px;\n }\n 84% {\n width: 55px;\n right: 0px;\n top: 35px;\n }\n 100% {\n width: 47px;\n right: 8px;\n top: 38px;\n }\n }\n @keyframes animateSuccessLong {\n 0% {\n width: 0;\n right: 46px;\n top: 54px;\n }\n 65% {\n width: 0;\n right: 46px;\n top: 54px;\n }\n 84% {\n width: 55px;\n right: 0px;\n top: 35px;\n }\n 100% {\n width: 47px;\n right: 8px;\n top: 38px;\n }\n }\n @-webkit-keyframes rotatePlaceholder {\n 0% {\n transform: rotate(-45deg);\n -webkit-transform: rotate(-45deg);\n }\n 5% {\n transform: rotate(-45deg);\n -webkit-transform: rotate(-45deg);\n }\n 12% {\n transform: rotate(-405deg);\n -webkit-transform: rotate(-405deg);\n }\n 100% {\n transform: rotate(-405deg);\n -webkit-transform: rotate(-405deg);\n }\n }\n @keyframes rotatePlaceholder {\n 0% {\n transform: rotate(-45deg);\n -webkit-transform: rotate(-45deg);\n }\n 5% {\n transform: rotate(-45deg);\n -webkit-transform: rotate(-45deg);\n }\n 12% {\n transform: rotate(-405deg);\n -webkit-transform: rotate(-405deg);\n }\n 100% {\n transform: rotate(-405deg);\n -webkit-transform: rotate(-405deg);\n }\n }\n @-webkit-keyframes animateErrorIcon {\n 0% {\n transform: rotateX(100deg);\n -webkit-transform: rotateX(100deg);\n opacity: 0;\n }\n 100% {\n transform: rotateX(0deg);\n -webkit-transform: rotateX(0deg);\n opacity: 1;\n }\n }\n @keyframes animateErrorIcon {\n 0% {\n transform: rotateX(100deg);\n -webkit-transform: rotateX(100deg);\n opacity: 0;\n }\n 100% {\n transform: rotateX(0deg);\n -webkit-transform: rotateX(0deg);\n opacity: 1;\n }\n }\n @-webkit-keyframes animateXMark {\n 0% {\n transform: scale(0.4);\n -webkit-transform: scale(0.4);\n margin-top: 26px;\n opacity: 0;\n }\n 50% {\n transform: scale(0.4);\n -webkit-transform: scale(0.4);\n margin-top: 26px;\n opacity: 0;\n }\n 80% {\n transform: scale(1.15);\n -webkit-transform: scale(1.15);\n margin-top: -6px;\n }\n 100% {\n transform: scale(1);\n -webkit-transform: scale(1);\n margin-top: 0;\n opacity: 1;\n }\n }\n @keyframes animateXMark {\n 0% {\n transform: scale(0.4);\n -webkit-transform: scale(0.4);\n margin-top: 26px;\n opacity: 0;\n }\n 50% {\n transform: scale(0.4);\n -webkit-transform: scale(0.4);\n margin-top: 26px;\n opacity: 0;\n }\n 80% {\n transform: scale(1.15);\n -webkit-transform: scale(1.15);\n margin-top: -6px;\n }\n 100% {\n transform: scale(1);\n -webkit-transform: scale(1);\n margin-top: 0;\n opacity: 1;\n }\n }\n @-webkit-keyframes pulseWarning {\n 0% {\n border-color: #F8D486;\n }\n 100% {\n border-color: #F8BB86;\n }\n }\n @keyframes pulseWarning {\n 0% {\n border-color: #F8D486;\n }\n 100% {\n border-color: #F8BB86;\n }\n }\n @-webkit-keyframes pulseWarningIns {\n 0% {\n background-color: #F8D486;\n }\n 100% {\n background-color: #F8BB86;\n }\n }\n @keyframes pulseWarningIns {\n 0% {\n background-color: #F8D486;\n }\n 100% {\n background-color: #F8BB86;\n }\n }'), !this.props.hideOverlay && _react2.default.createElement('div', { style: _SweetAlertStyles2.default.overlay }), _react2.default.createElement('div', {
2263722640
style: (0, _objectAssign2.default)({}, style, this.props.style),
2263822641
tabIndex: '0',
@@ -22663,6 +22666,7 @@
2266322666
cancelBtnBsStyle: _propTypes2.default.oneOf(['default', 'primary', 'link', 'info', 'success', 'warning', 'danger']),
2266422667
confirmBtnBsStyle: _propTypes2.default.oneOf(['default', 'primary', 'link', 'info', 'success', 'warning', 'danger']),
2266522668
customIcon: _propTypes2.default.oneOfType([_propTypes2.default.node, _propTypes2.default.string]),
22669+
show: _propTypes2.default.bool,
2266622670
required: _propTypes2.default.bool,
2266722671
placeholder: _propTypes2.default.string,
2266822672
validationMsg: _propTypes2.default.string,
@@ -22687,6 +22691,7 @@
2268722691
inputType: 'text',
2268822692
customClass: '',
2268922693
hideOverlay: false,
22694+
show: true,
2269022695
required: true,
2269122696
disabled: false,
2269222697
beforeMount: function beforeMount() {},

lib/dist/SweetAlert.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -237,6 +237,9 @@ var SweetAlert = function (_React$Component) {
237237
}, {
238238
key: 'render',
239239
value: function render() {
240+
if (!this.props.show) {
241+
return false;
242+
}
240243
return _react2.default.createElement(
241244
'div',
242245
null,
@@ -294,6 +297,7 @@ SweetAlert.propTypes = {
294297
cancelBtnBsStyle: _propTypes2.default.oneOf(['default', 'primary', 'link', 'info', 'success', 'warning', 'danger']),
295298
confirmBtnBsStyle: _propTypes2.default.oneOf(['default', 'primary', 'link', 'info', 'success', 'warning', 'danger']),
296299
customIcon: _propTypes2.default.oneOfType([_propTypes2.default.node, _propTypes2.default.string]),
300+
show: _propTypes2.default.bool,
297301
required: _propTypes2.default.bool,
298302
placeholder: _propTypes2.default.string,
299303
validationMsg: _propTypes2.default.string,
@@ -318,6 +322,7 @@ SweetAlert.defaultProps = {
318322
inputType: 'text',
319323
customClass: '',
320324
hideOverlay: false,
325+
show: true,
321326
required: true,
322327
disabled: false,
323328
beforeMount: function beforeMount() {},

0 commit comments

Comments
 (0)