Skip to content

Commit

Permalink
added aria label capabilities for both buttons
Browse files Browse the repository at this point in the history
  • Loading branch information
Mastermindzh committed Oct 13, 2020
1 parent b1913d2 commit 5e4e840
Show file tree
Hide file tree
Showing 6 changed files with 32 additions and 6 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,12 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [[5.2.0](https://github.com/Mastermindzh/react-cookie-consent/releases/tag/5.2.0)]

### added

Added aria labels for both the decline and accept button

## [[5.1.4](https://github.com/Mastermindzh/react-cookie-consent/releases/tag/5.1.4)]

### changed
Expand Down
2 changes: 2 additions & 0 deletions build/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,8 @@ export interface CookieConsentProps {
overlay?: boolean;
overlayClasses?: string;
overlayStyle?: object;
ariaAcceptLabel?: string;
ariaDeclineLabel?: string;
}

export default class CookieConsent extends React.Component<CookieConsentProps, {}> {}
Expand Down
10 changes: 9 additions & 1 deletion build/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -913,7 +913,9 @@ module.exports = /******/ (function (modules) {
ButtonComponent = _props4.ButtonComponent,
overlay = _props4.overlay,
overlayClasses = _props4.overlayClasses,
overlayStyle = _props4.overlayStyle;
overlayStyle = _props4.overlayStyle,
ariaAcceptLabel = _props4.ariaAcceptLabel,
ariaDeclineLabel = _props4.ariaDeclineLabel;

var myStyle = {};
var myButtonStyle = {};
Expand Down Expand Up @@ -970,6 +972,7 @@ module.exports = /******/ (function (modules) {
style: myDeclineButtonStyle,
className: declineButtonClasses,
id: declineButtonId,
"aria-label": ariaDeclineLabel,
onClick: function onClick() {
_this2.decline();
},
Expand All @@ -987,6 +990,7 @@ module.exports = /******/ (function (modules) {
style: myButtonStyle,
className: buttonClasses,
id: buttonId,
"aria-label": ariaAcceptLabel,
onClick: function onClick() {
_this2.accept({ acceptedByScrolling: false });
},
Expand Down Expand Up @@ -1098,6 +1102,8 @@ module.exports = /******/ (function (modules) {
overlay: _propTypes2.default.bool,
overlayClasses: _propTypes2.default.string,
overlayStyle: _propTypes2.default.object,
ariaAcceptLabel: _propTypes2.default.string,
ariaDeclineLabel: _propTypes2.default.string,
};

CookieConsent.defaultProps = {
Expand Down Expand Up @@ -1137,6 +1143,8 @@ module.exports = /******/ (function (modules) {
},
overlay: false,
overlayClasses: "",
ariaAcceptLabel: "Accept cookies",
ariaDeclineLabel: "Decline cookies",
};

exports.default = CookieConsent;
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"name": "Rick van Lieshout",
"email": "info@rickvanlieshout.com"
},
"version": "5.1.4",
"version": "5.2.0",
"description": "A small, simple and customizable cookie consent bar for use in React applications.",
"main": "build/index.js",
"types": "build/index.d.ts",
Expand Down
10 changes: 6 additions & 4 deletions src/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ export interface CookieConsentProps {
expires?: number;
containerClasses?: string;
contentClasses?: string;
buttonWrapperClasses?: string,
buttonWrapperClasses?: string;
buttonClasses?: string;
declineButtonClasses?: string;
buttonId?: string;
Expand All @@ -36,9 +36,11 @@ export interface CookieConsentProps {
enableDeclineButton?: boolean;
flipButtons?: boolean;
ButtonComponent?: React.ElementType;
overlay?: boolean,
overlayClasses?: string,
overlayStyle?: object,
overlay?: boolean;
overlayClasses?: string;
overlayStyle?: object;
ariaAcceptLabel?: string;
ariaDeclineLabel?: string;
}

export default class CookieConsent extends React.Component<CookieConsentProps, {}> {}
Expand Down
8 changes: 8 additions & 0 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -249,6 +249,8 @@ class CookieConsent extends Component {
overlay,
overlayClasses,
overlayStyle,
ariaAcceptLabel,
ariaDeclineLabel,
} = this.props;

let myStyle = {};
Expand Down Expand Up @@ -304,6 +306,7 @@ class CookieConsent extends Component {
style={myDeclineButtonStyle}
className={declineButtonClasses}
id={declineButtonId}
aria-label={ariaDeclineLabel}
onClick={() => {
this.decline();
}}
Expand All @@ -319,6 +322,7 @@ class CookieConsent extends Component {
style={myButtonStyle}
className={buttonClasses}
id={buttonId}
aria-label={ariaAcceptLabel}
onClick={() => {
this.accept({ acceptedByScrolling: false });
}}
Expand Down Expand Up @@ -394,6 +398,8 @@ CookieConsent.propTypes = {
overlay: PropTypes.bool,
overlayClasses: PropTypes.string,
overlayStyle: PropTypes.object,
ariaAcceptLabel: PropTypes.string,
ariaDeclineLabel: PropTypes.string,
};

CookieConsent.defaultProps = {
Expand Down Expand Up @@ -428,6 +434,8 @@ CookieConsent.defaultProps = {
ButtonComponent: ({ children, ...props }) => <button {...props}>{children}</button>,
overlay: false,
overlayClasses: "",
ariaAcceptLabel: "Accept cookies",
ariaDeclineLabel: "Decline cookies",
};

export default CookieConsent;
Expand Down

0 comments on commit 5e4e840

Please sign in to comment.