Skip to content

Commit 5e4e840

Browse files
committed
added aria label capabilities for both buttons
1 parent b1913d2 commit 5e4e840

6 files changed

Lines changed: 32 additions & 6 deletions

File tree

CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,12 @@ All notable changes to this project will be documented in this file.
55
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
66
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
77

8+
## [[5.2.0](https://github.com/Mastermindzh/react-cookie-consent/releases/tag/5.2.0)]
9+
10+
### added
11+
12+
Added aria labels for both the decline and accept button
13+
814
## [[5.1.4](https://github.com/Mastermindzh/react-cookie-consent/releases/tag/5.1.4)]
915

1016
### changed

build/index.d.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,8 @@ export interface CookieConsentProps {
3939
overlay?: boolean;
4040
overlayClasses?: string;
4141
overlayStyle?: object;
42+
ariaAcceptLabel?: string;
43+
ariaDeclineLabel?: string;
4244
}
4345

4446
export default class CookieConsent extends React.Component<CookieConsentProps, {}> {}

build/index.js

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -913,7 +913,9 @@ module.exports = /******/ (function (modules) {
913913
ButtonComponent = _props4.ButtonComponent,
914914
overlay = _props4.overlay,
915915
overlayClasses = _props4.overlayClasses,
916-
overlayStyle = _props4.overlayStyle;
916+
overlayStyle = _props4.overlayStyle,
917+
ariaAcceptLabel = _props4.ariaAcceptLabel,
918+
ariaDeclineLabel = _props4.ariaDeclineLabel;
917919

918920
var myStyle = {};
919921
var myButtonStyle = {};
@@ -970,6 +972,7 @@ module.exports = /******/ (function (modules) {
970972
style: myDeclineButtonStyle,
971973
className: declineButtonClasses,
972974
id: declineButtonId,
975+
"aria-label": ariaDeclineLabel,
973976
onClick: function onClick() {
974977
_this2.decline();
975978
},
@@ -987,6 +990,7 @@ module.exports = /******/ (function (modules) {
987990
style: myButtonStyle,
988991
className: buttonClasses,
989992
id: buttonId,
993+
"aria-label": ariaAcceptLabel,
990994
onClick: function onClick() {
991995
_this2.accept({ acceptedByScrolling: false });
992996
},
@@ -1098,6 +1102,8 @@ module.exports = /******/ (function (modules) {
10981102
overlay: _propTypes2.default.bool,
10991103
overlayClasses: _propTypes2.default.string,
11001104
overlayStyle: _propTypes2.default.object,
1105+
ariaAcceptLabel: _propTypes2.default.string,
1106+
ariaDeclineLabel: _propTypes2.default.string,
11011107
};
11021108

11031109
CookieConsent.defaultProps = {
@@ -1137,6 +1143,8 @@ module.exports = /******/ (function (modules) {
11371143
},
11381144
overlay: false,
11391145
overlayClasses: "",
1146+
ariaAcceptLabel: "Accept cookies",
1147+
ariaDeclineLabel: "Decline cookies",
11401148
};
11411149

11421150
exports.default = CookieConsent;

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
"name": "Rick van Lieshout",
55
"email": "info@rickvanlieshout.com"
66
},
7-
"version": "5.1.4",
7+
"version": "5.2.0",
88
"description": "A small, simple and customizable cookie consent bar for use in React applications.",
99
"main": "build/index.js",
1010
"types": "build/index.d.ts",

src/index.d.ts

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ export interface CookieConsentProps {
2424
expires?: number;
2525
containerClasses?: string;
2626
contentClasses?: string;
27-
buttonWrapperClasses?: string,
27+
buttonWrapperClasses?: string;
2828
buttonClasses?: string;
2929
declineButtonClasses?: string;
3030
buttonId?: string;
@@ -36,9 +36,11 @@ export interface CookieConsentProps {
3636
enableDeclineButton?: boolean;
3737
flipButtons?: boolean;
3838
ButtonComponent?: React.ElementType;
39-
overlay?: boolean,
40-
overlayClasses?: string,
41-
overlayStyle?: object,
39+
overlay?: boolean;
40+
overlayClasses?: string;
41+
overlayStyle?: object;
42+
ariaAcceptLabel?: string;
43+
ariaDeclineLabel?: string;
4244
}
4345

4446
export default class CookieConsent extends React.Component<CookieConsentProps, {}> {}

src/index.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -249,6 +249,8 @@ class CookieConsent extends Component {
249249
overlay,
250250
overlayClasses,
251251
overlayStyle,
252+
ariaAcceptLabel,
253+
ariaDeclineLabel,
252254
} = this.props;
253255

254256
let myStyle = {};
@@ -304,6 +306,7 @@ class CookieConsent extends Component {
304306
style={myDeclineButtonStyle}
305307
className={declineButtonClasses}
306308
id={declineButtonId}
309+
aria-label={ariaDeclineLabel}
307310
onClick={() => {
308311
this.decline();
309312
}}
@@ -319,6 +322,7 @@ class CookieConsent extends Component {
319322
style={myButtonStyle}
320323
className={buttonClasses}
321324
id={buttonId}
325+
aria-label={ariaAcceptLabel}
322326
onClick={() => {
323327
this.accept({ acceptedByScrolling: false });
324328
}}
@@ -394,6 +398,8 @@ CookieConsent.propTypes = {
394398
overlay: PropTypes.bool,
395399
overlayClasses: PropTypes.string,
396400
overlayStyle: PropTypes.object,
401+
ariaAcceptLabel: PropTypes.string,
402+
ariaDeclineLabel: PropTypes.string,
397403
};
398404

399405
CookieConsent.defaultProps = {
@@ -428,6 +434,8 @@ CookieConsent.defaultProps = {
428434
ButtonComponent: ({ children, ...props }) => <button {...props}>{children}</button>,
429435
overlay: false,
430436
overlayClasses: "",
437+
ariaAcceptLabel: "Accept cookies",
438+
ariaDeclineLabel: "Decline cookies",
431439
};
432440

433441
export default CookieConsent;

0 commit comments

Comments
 (0)