mirror of
https://github.com/Mastermindzh/react-cookie-consent.git
synced 2025-01-21 02:50:58 +01:00
Default visibility should be false (#11)
* Default visibility should be false * .prettierrc
This commit is contained in:
parent
dd350edfbd
commit
66d6aaa57d
5
.prettierrc
Normal file
5
.prettierrc
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
{
|
||||||
|
"printWidth": 100,
|
||||||
|
"semi": true,
|
||||||
|
"single-quote": false
|
||||||
|
}
|
26
src/index.js
26
src/index.js
@ -13,7 +13,7 @@ class CookieConsent extends Component {
|
|||||||
this.accept.bind(this);
|
this.accept.bind(this);
|
||||||
|
|
||||||
this.state = {
|
this.state = {
|
||||||
visible: true,
|
visible: false,
|
||||||
style: {
|
style: {
|
||||||
alignItems: "baseline",
|
alignItems: "baseline",
|
||||||
background: "#353535",
|
background: "#353535",
|
||||||
@ -46,11 +46,9 @@ class CookieConsent extends Component {
|
|||||||
componentWillMount() {
|
componentWillMount() {
|
||||||
const { cookieName, debug } = this.props;
|
const { cookieName, debug } = this.props;
|
||||||
|
|
||||||
// debug not desired and cookieName not undefined
|
// if debug desired or cookieName undefined
|
||||||
if (!debug &&
|
if (debug || Cookies.get(cookieName) === undefined) {
|
||||||
Cookies.get(cookieName) !== undefined
|
this.setState({ visible: true });
|
||||||
) {
|
|
||||||
this.setState({ visible: false });
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -92,14 +90,8 @@ class CookieConsent extends Component {
|
|||||||
} else {
|
} else {
|
||||||
// if styles aren't disabled merge them with the styles that are provided (or use default styles)
|
// if styles aren't disabled merge them with the styles that are provided (or use default styles)
|
||||||
myStyle = Object.assign({}, { ...this.state.style, ...style });
|
myStyle = Object.assign({}, { ...this.state.style, ...style });
|
||||||
myButtonStyle = Object.assign(
|
myButtonStyle = Object.assign({}, { ...this.state.buttonStyle, ...buttonStyle });
|
||||||
{},
|
myContentStyle = Object.assign({}, { ...this.state.contentStyle, ...contentStyle });
|
||||||
{ ...this.state.buttonStyle, ...buttonStyle }
|
|
||||||
);
|
|
||||||
myContentStyle = Object.assign(
|
|
||||||
{},
|
|
||||||
{ ...this.state.contentStyle, ...contentStyle }
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// syntactic sugar to enable user to easily select top / bottom
|
// syntactic sugar to enable user to easily select top / bottom
|
||||||
@ -138,11 +130,7 @@ CookieConsent.propTypes = {
|
|||||||
children: PropTypes.any, // eslint-disable-line react/forbid-prop-types
|
children: PropTypes.any, // eslint-disable-line react/forbid-prop-types
|
||||||
disableStyles: PropTypes.bool,
|
disableStyles: PropTypes.bool,
|
||||||
onAccept: PropTypes.func,
|
onAccept: PropTypes.func,
|
||||||
buttonText: PropTypes.oneOfType([
|
buttonText: PropTypes.oneOfType([PropTypes.string, PropTypes.func, PropTypes.element]),
|
||||||
PropTypes.string,
|
|
||||||
PropTypes.func,
|
|
||||||
PropTypes.element
|
|
||||||
]),
|
|
||||||
cookieName: PropTypes.string,
|
cookieName: PropTypes.string,
|
||||||
debug: PropTypes.bool
|
debug: PropTypes.bool
|
||||||
};
|
};
|
||||||
|
Loading…
Reference in New Issue
Block a user