Merge pull request #26 from delaneymethod/feature/button-id

Added new buttonId prop
This commit is contained in:
Rick van Lieshout 2018-10-19 14:22:35 +02:00 committed by GitHub
commit 55267ebfce
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 12 additions and 3 deletions

View File

@ -92,6 +92,7 @@ One of the props (onAccept) is a function, this function will be called after th
| extraCookieOptions | object | `{}` | Extra info (apart from expiry date) to add to the cookie|
| containerClasses| string | "" | CSS classes to apply to the surrounding container |
| buttonClasses | string | "" | CSS classes to apply to the button |
| buttonId | string | "" | Id to apply to the button |
| contentClasses| string | "" | CSS classes to apply to the content |
| style | object | [look at source][style] | React styling object for the bar. |
| buttonStyle | object | [look at source][buttonStyle] | React styling object for the button. |

View File

@ -669,7 +669,8 @@ var CookieConsent = function (_Component) {
buttonText = _props3.buttonText,
containerClasses = _props3.containerClasses,
contentClasses = _props3.contentClasses,
buttonClasses = _props3.buttonClasses;
buttonClasses = _props3.buttonClasses,
buttonId = _props3.buttonId;
var myStyle = {};
@ -714,6 +715,7 @@ var CookieConsent = function (_Component) {
{
style: myButtonStyle,
className: buttonClasses,
id: buttonId,
onClick: function onClick() {
_this2.accept();
}
@ -746,6 +748,7 @@ CookieConsent.propTypes = {
containerClasses: _propTypes2.default.string,
contentClasses: _propTypes2.default.string,
buttonClasses: _propTypes2.default.string,
buttonId: _propTypes2.default.string,
acceptOnScroll: _propTypes2.default.bool,
acceptOnScrollPercentage: _propTypes2.default.number,
extraCookieOptions: _propTypes2.default.object
@ -766,6 +769,7 @@ CookieConsent.defaultProps = {
containerClasses: "",
contentClasses: "",
buttonClasses: "",
buttonId: "",
extraCookieOptions: {}
};

View File

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

View File

@ -118,7 +118,8 @@ class CookieConsent extends Component {
buttonText,
containerClasses,
contentClasses,
buttonClasses
buttonClasses,
buttonId,
} = this.props;
let myStyle = {};
@ -158,6 +159,7 @@ class CookieConsent extends Component {
<button
style={myButtonStyle}
className={buttonClasses}
id={buttonId}
onClick={() => {
this.accept();
}}
@ -194,6 +196,7 @@ CookieConsent.propTypes = {
containerClasses: PropTypes.string,
contentClasses: PropTypes.string,
buttonClasses: PropTypes.string,
buttonId: PropTypes.string,
acceptOnScroll: PropTypes.bool,
acceptOnScrollPercentage: PropTypes.number,
extraCookieOptions: PropTypes.object
@ -214,6 +217,7 @@ CookieConsent.defaultProps = {
containerClasses: "",
contentClasses: "",
buttonClasses: "",
buttonId: "",
extraCookieOptions: {}
};