default debug prop and new build

This commit is contained in:
Rick van Lieshout 2018-05-31 20:00:26 +02:00
parent 456d5b4fa0
commit 26cde73055
3 changed files with 32 additions and 23 deletions

View File

@ -721,9 +721,9 @@ var CookieConsent = function (_Component) {
background: "#353535", background: "#353535",
color: "white", color: "white",
display: "flex", display: "flex",
flexWrap: "wrap",
justifyContent: "space-between", justifyContent: "space-between",
left: "0", left: "0",
padding: "15px",
position: "fixed", position: "fixed",
width: "100%", width: "100%",
zIndex: "999" zIndex: "999"
@ -735,11 +735,13 @@ var CookieConsent = function (_Component) {
boxShadow: "none", boxShadow: "none",
color: "black", color: "black",
flex: "0 0 auto", flex: "0 0 auto",
marginLeft: "15px",
padding: "5px 10px", padding: "5px 10px",
marginRight: "25px" margin: "15px"
}, },
contentStyle: {} contentStyle: {
flex: "1 0 300px",
margin: "15px"
}
}; };
return _this; return _this;
} }
@ -747,10 +749,13 @@ var CookieConsent = function (_Component) {
_createClass(CookieConsent, [{ _createClass(CookieConsent, [{
key: "componentWillMount", key: "componentWillMount",
value: function componentWillMount() { value: function componentWillMount() {
var cookieName = this.props.cookieName; var _props = this.props,
cookieName = _props.cookieName,
debug = _props.debug;
// debug not desired and cookieName not undefined
if (_jsCookie2.default.get(cookieName) != undefined) { if (!debug && _jsCookie2.default.get(cookieName) !== undefined) {
this.setState({ visible: false }); this.setState({ visible: false });
} }
} }
@ -778,14 +783,14 @@ var CookieConsent = function (_Component) {
return null; return null;
} }
var _props = this.props, var _props2 = this.props,
location = _props.location, location = _props2.location,
style = _props.style, style = _props2.style,
buttonStyle = _props.buttonStyle, buttonStyle = _props2.buttonStyle,
contentStyle = _props.contentStyle, contentStyle = _props2.contentStyle,
disableStyles = _props.disableStyles, disableStyles = _props2.disableStyles,
onAccept = _props.onAccept, onAccept = _props2.onAccept,
buttonText = _props.buttonText; buttonText = _props2.buttonText;
var myStyle = {}; var myStyle = {};
@ -850,14 +855,17 @@ CookieConsent.propTypes = {
disableStyles: _propTypes2.default.bool, disableStyles: _propTypes2.default.bool,
onAccept: _propTypes2.default.func, onAccept: _propTypes2.default.func,
buttonText: _propTypes2.default.oneOfType([_propTypes2.default.string, _propTypes2.default.func, _propTypes2.default.element]), buttonText: _propTypes2.default.oneOfType([_propTypes2.default.string, _propTypes2.default.func, _propTypes2.default.element]),
cookieName: _propTypes2.default.string cookieName: _propTypes2.default.string,
debug: _propTypes2.default.bool
}; };
CookieConsent.defaultProps = { CookieConsent.defaultProps = {
disableStyles: false, disableStyles: false,
location: OPTIONS.BOTTOM, location: OPTIONS.BOTTOM,
onAccept: function onAccept() {}, onAccept: function onAccept() {},
cookieName: "CookieConsent", cookieName: "CookieConsent",
buttonText: "I understand" buttonText: "I understand",
debug: false
}; };
exports.default = CookieConsent; exports.default = CookieConsent;

View File

@ -4,7 +4,7 @@
"name": "Rick van Lieshout", "name": "Rick van Lieshout",
"email": "info@rickvanlieshout.com" "email": "info@rickvanlieshout.com"
}, },
"version": "1.1.1", "version": "1.1.2",
"description": "A small, simple and customizable cookie consent bar for use in React applications.", "description": "A small, simple and customizable cookie consent bar for use in React applications.",
"main": "build/index.js", "main": "build/index.js",
"dependencies": { "dependencies": {

View File

@ -19,7 +19,7 @@ class CookieConsent extends Component {
background: "#353535", background: "#353535",
color: "white", color: "white",
display: "flex", display: "flex",
flexWrap: "wrap" flexWrap: "wrap",
justifyContent: "space-between", justifyContent: "space-between",
left: "0", left: "0",
position: "fixed", position: "fixed",
@ -33,7 +33,6 @@ class CookieConsent extends Component {
boxShadow: "none", boxShadow: "none",
color: "black", color: "black",
flex: "0 0 auto", flex: "0 0 auto",
marginLeft: "15px",
padding: "5px 10px", padding: "5px 10px",
margin: "15px" margin: "15px"
}, },
@ -48,8 +47,7 @@ class CookieConsent extends Component {
const { cookieName, debug } = this.props; const { cookieName, debug } = this.props;
// debug not desired and cookieName not undefined // debug not desired and cookieName not undefined
if ( if (!debug &&
!(debug !== undefined && debug) &&
Cookies.get(cookieName) !== undefined Cookies.get(cookieName) !== undefined
) { ) {
this.setState({ visible: false }); this.setState({ visible: false });
@ -145,14 +143,17 @@ CookieConsent.propTypes = {
PropTypes.func, PropTypes.func,
PropTypes.element PropTypes.element
]), ]),
cookieName: PropTypes.string cookieName: PropTypes.string,
debug: PropTypes.bool
}; };
CookieConsent.defaultProps = { CookieConsent.defaultProps = {
disableStyles: false, disableStyles: false,
location: OPTIONS.BOTTOM, location: OPTIONS.BOTTOM,
onAccept: () => {}, onAccept: () => {},
cookieName: "CookieConsent", cookieName: "CookieConsent",
buttonText: "I understand" buttonText: "I understand",
debug: false
}; };
export default CookieConsent; export default CookieConsent;