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",
color: "white",
display: "flex",
flexWrap: "wrap",
justifyContent: "space-between",
left: "0",
padding: "15px",
position: "fixed",
width: "100%",
zIndex: "999"
@ -735,11 +735,13 @@ var CookieConsent = function (_Component) {
boxShadow: "none",
color: "black",
flex: "0 0 auto",
marginLeft: "15px",
padding: "5px 10px",
marginRight: "25px"
margin: "15px"
},
contentStyle: {}
contentStyle: {
flex: "1 0 300px",
margin: "15px"
}
};
return _this;
}
@ -747,10 +749,13 @@ var CookieConsent = function (_Component) {
_createClass(CookieConsent, [{
key: "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 });
}
}
@ -778,14 +783,14 @@ var CookieConsent = function (_Component) {
return null;
}
var _props = this.props,
location = _props.location,
style = _props.style,
buttonStyle = _props.buttonStyle,
contentStyle = _props.contentStyle,
disableStyles = _props.disableStyles,
onAccept = _props.onAccept,
buttonText = _props.buttonText;
var _props2 = this.props,
location = _props2.location,
style = _props2.style,
buttonStyle = _props2.buttonStyle,
contentStyle = _props2.contentStyle,
disableStyles = _props2.disableStyles,
onAccept = _props2.onAccept,
buttonText = _props2.buttonText;
var myStyle = {};
@ -850,14 +855,17 @@ CookieConsent.propTypes = {
disableStyles: _propTypes2.default.bool,
onAccept: _propTypes2.default.func,
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 = {
disableStyles: false,
location: OPTIONS.BOTTOM,
onAccept: function onAccept() {},
cookieName: "CookieConsent",
buttonText: "I understand"
buttonText: "I understand",
debug: false
};
exports.default = CookieConsent;

View File

@ -4,7 +4,7 @@
"name": "Rick van Lieshout",
"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.",
"main": "build/index.js",
"dependencies": {

View File

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