styling fix by Karland, small readme changes and a version update

This commit is contained in:
Rick van Lieshout 2018-05-30 14:10:47 +02:00
parent 30214d5411
commit 1ea07ba29f
3 changed files with 31 additions and 20 deletions

View File

@ -88,9 +88,9 @@ One of the props (onAccept) is a function, this function will be called after th
## Styling it ## Styling it
You can provide styling for the bar, for the button and the content. Note that the bar has a `display: flex` property as default and is parent to its children content and button. You can provide styling for the bar, the button and the content. Note that the bar has a `display: flex` property as default and is parent to its children "content" and "button".
You can style each component with using the `style`, `buttonStyle` and `contentStyle` prop. These will append / replace the default styles of the components. You can style each component by using the `style`, `buttonStyle` and `contentStyle` prop. These will append / replace the default styles of the components.
You can use `disableStyles={true}` to disable any built-in styling. You can use `disableStyles={true}` to disable any built-in styling.

View File

@ -717,26 +717,28 @@ var CookieConsent = function (_Component) {
_this.state = { _this.state = {
visible: true, visible: true,
style: { style: {
position: "fixed", alignItems: "baseline",
width: "100%",
padding: "15px",
background: "#353535", background: "#353535",
color: "white", color: "white",
display: "flex",
justifyContent: "space-between",
left: "0", left: "0",
zIndex: "999", padding: "15px",
lineHeight: "30px", position: "fixed",
textAlign: "left" width: "100%",
zIndex: "999"
}, },
buttonStyle: { buttonStyle: {
position: "absolute",
right: "50px",
border: "0",
background: "#ffd42d", background: "#ffd42d",
boxShadow: "none", border: "0",
borderRadius: "0px", borderRadius: "0px",
padding: "5px", boxShadow: "none",
color: "black" color: "black",
} flex: "0 0 auto",
marginLeft: "15px",
padding: "5px 10px"
},
contentStyle: {}
}; };
return _this; return _this;
} }
@ -779,22 +781,26 @@ var CookieConsent = function (_Component) {
location = _props.location, location = _props.location,
style = _props.style, style = _props.style,
buttonStyle = _props.buttonStyle, buttonStyle = _props.buttonStyle,
contentStyle = _props.contentStyle,
disableStyles = _props.disableStyles, disableStyles = _props.disableStyles,
onAccept = _props.onAccept, onAccept = _props.onAccept,
buttonText = _props.buttonText; buttonText = _props.buttonText;
var myStyle = {}, var myStyle = {};
myButtonStyle = {}; var myButtonStyle = {};
var myContentStyle = {};
if (disableStyles) { if (disableStyles) {
// if styles are disabled use the provided styles (or non) // if styles are disabled use the provided styles (or non)
myStyle = Object.assign({}, style); myStyle = Object.assign({}, style);
myButtonStyle = Object.assign({}, buttonStyle); myButtonStyle = Object.assign({}, buttonStyle);
myContentStyle = Object.assign({}, contentStyle);
} 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({}, _extends({}, this.state.style, style)); myStyle = Object.assign({}, _extends({}, this.state.style, style));
myButtonStyle = Object.assign({}, _extends({}, this.state.buttonStyle, buttonStyle)); myButtonStyle = Object.assign({}, _extends({}, this.state.buttonStyle, buttonStyle));
myContentStyle = Object.assign({}, _extends({}, this.state.contentStyle, contentStyle));
} }
// syntactic sugar to enable user to easily select top / bottom // syntactic sugar to enable user to easily select top / bottom
@ -811,7 +817,11 @@ var CookieConsent = function (_Component) {
return _react2.default.createElement( return _react2.default.createElement(
"div", "div",
{ className: "cookieConsent", style: myStyle }, { className: "cookieConsent", style: myStyle },
this.props.children, _react2.default.createElement(
"div",
{ style: myContentStyle },
this.props.children
),
_react2.default.createElement( _react2.default.createElement(
"button", "button",
{ {
@ -834,6 +844,7 @@ CookieConsent.propTypes = {
location: _propTypes2.default.oneOf(["top", "bottom"]), location: _propTypes2.default.oneOf(["top", "bottom"]),
style: _propTypes2.default.object, style: _propTypes2.default.object,
buttonStyle: _propTypes2.default.object, buttonStyle: _propTypes2.default.object,
contentStyle: _propTypes2.default.object,
children: _propTypes2.default.any, // eslint-disable-line react/forbid-prop-types children: _propTypes2.default.any, // eslint-disable-line react/forbid-prop-types
disableStyles: _propTypes2.default.bool, disableStyles: _propTypes2.default.bool,
onAccept: _propTypes2.default.func, onAccept: _propTypes2.default.func,

View File

@ -4,12 +4,12 @@
"name": "Rick van Lieshout", "name": "Rick van Lieshout",
"email": "info@rickvanlieshout.com" "email": "info@rickvanlieshout.com"
}, },
"version": "1.0.9", "version": "1.1.0",
"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": {
"js-cookie": "^2.2.0", "js-cookie": "^2.2.0",
"react": "^15.5.4" "react": "^16.4.0"
}, },
"scripts": { "scripts": {
"build": "webpack" "build": "webpack"