mirror of
https://github.com/Mastermindzh/react-cookie-consent.git
synced 2025-08-23 09:35:04 +02:00
Compare commits
4 Commits
Author | SHA1 | Date | |
---|---|---|---|
c9a6e1f0ce | |||
|
fefe28e288 | ||
|
d63cb81fb7 | ||
e96b4fe4c0 |
@@ -5,6 +5,15 @@ 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/),
|
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).
|
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
||||||
|
|
||||||
|
## [[7.4.0]](https://github.com/Mastermindzh/react-cookie-consent/releases/tag/7.4.0)
|
||||||
|
|
||||||
|
- Added support for React 18
|
||||||
|
- Updated example and codebase to use React 18
|
||||||
|
|
||||||
|
## [[7.3.1]](https://github.com/Mastermindzh/react-cookie-consent/releases/tag/7.3.1)
|
||||||
|
|
||||||
|
- Added type annotations on public functions
|
||||||
|
|
||||||
## [[7.3.0]](https://github.com/Mastermindzh/react-cookie-consent/releases/tag/7.3.0)
|
## [[7.3.0]](https://github.com/Mastermindzh/react-cookie-consent/releases/tag/7.3.0)
|
||||||
|
|
||||||
- added `customButtonProps` that allows to use custom props with the button component. Specifically useful for library buttons components, for e.g. MUI Button.
|
- added `customButtonProps` that allows to use custom props with the button component. Specifically useful for library buttons components, for e.g. MUI Button.
|
||||||
|
4
build/index.d.ts
vendored
4
build/index.d.ts
vendored
@@ -65,12 +65,12 @@ export function getCookieConsentValue(name?: string): string;
|
|||||||
* Remove the cookie on browser in order to allow user to change their consent
|
* Remove the cookie on browser in order to allow user to change their consent
|
||||||
* @param {*} name optional name of the cookie
|
* @param {*} name optional name of the cookie
|
||||||
*/
|
*/
|
||||||
export function resetCookieConsentValue(name?: string);
|
export function resetCookieConsentValue(name?: string): void;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the legacy cookie name by the regular cookie name
|
* Get the legacy cookie name by the regular cookie name
|
||||||
* @param {string} name of cookie to get
|
* @param {string} name of cookie to get
|
||||||
*/
|
*/
|
||||||
export function getLegacyCookieName(name: string);
|
export function getLegacyCookieName(name: string): string;
|
||||||
|
|
||||||
export { Cookies };
|
export { Cookies };
|
||||||
|
File diff suppressed because one or more lines are too long
5764
package-lock.json
generated
5764
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
26
package.json
26
package.json
@@ -4,7 +4,7 @@
|
|||||||
"name": "Rick van Lieshout",
|
"name": "Rick van Lieshout",
|
||||||
"email": "info@rickvanlieshout.com"
|
"email": "info@rickvanlieshout.com"
|
||||||
},
|
},
|
||||||
"version": "7.3.0",
|
"version": "7.4.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",
|
||||||
"types": "build/index.d.ts",
|
"types": "build/index.d.ts",
|
||||||
@@ -13,7 +13,7 @@
|
|||||||
"prop-types": "^15.7.2"
|
"prop-types": "^15.7.2"
|
||||||
},
|
},
|
||||||
"peerDependencies": {
|
"peerDependencies": {
|
||||||
"react": "^16.13.1 || ^17.0.0"
|
"react": "^16.13.1 || ^17.0.0 | ^18.0.0"
|
||||||
},
|
},
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"build": "webpack",
|
"build": "webpack",
|
||||||
@@ -43,22 +43,22 @@
|
|||||||
},
|
},
|
||||||
"homepage": "https://github.com/Mastermindzh/react-cookie-consent#readme",
|
"homepage": "https://github.com/Mastermindzh/react-cookie-consent#readme",
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@babel/cli": "^7.12.1",
|
"@babel/cli": "^7.17.6",
|
||||||
"@babel/core": "^7.12.3",
|
"@babel/core": "^7.17.8",
|
||||||
"@babel/plugin-proposal-object-rest-spread": "^7.12.1",
|
"@babel/plugin-proposal-object-rest-spread": "^7.17.3",
|
||||||
"@babel/plugin-transform-object-assign": "^7.12.1",
|
"@babel/plugin-transform-object-assign": "^7.16.7",
|
||||||
"@babel/plugin-transform-react-jsx": "^7.12.1",
|
"@babel/plugin-transform-react-jsx": "^7.17.3",
|
||||||
"@babel/preset-env": "^7.12.1",
|
"@babel/preset-env": "^7.16.11",
|
||||||
"@mastermindzh/prettier-config": "^1.0.0",
|
"@mastermindzh/prettier-config": "^1.0.0",
|
||||||
"@types/js-cookie": "^2.2.6",
|
"@types/js-cookie": "^2.2.6",
|
||||||
"babel-loader": "^8.1.0",
|
"babel-loader": "^8.2.4",
|
||||||
"copy-webpack-plugin": "^6.2.1",
|
"copy-webpack-plugin": "^6.2.1",
|
||||||
"husky": "^4.3.0",
|
"husky": "^4.3.0",
|
||||||
"lint-staged": "^10.5.1",
|
"lint-staged": "^10.5.1",
|
||||||
"prettier": "^2.1.2",
|
"prettier": "^2.6.2",
|
||||||
"react": "^16.13.1",
|
"react": "^18.0.0",
|
||||||
"webpack": "^5.3.2",
|
"webpack": "^5.71.0",
|
||||||
"webpack-cli": "^4.1.0"
|
"webpack-cli": "^4.9.2"
|
||||||
},
|
},
|
||||||
"prettier": "@mastermindzh/prettier-config",
|
"prettier": "@mastermindzh/prettier-config",
|
||||||
"husky": {
|
"husky": {
|
||||||
|
10
src/index.js
10
src/index.js
@@ -27,11 +27,11 @@ export const VISIBLE_OPTIONS = {
|
|||||||
* @param {*} name optional name of the cookie
|
* @param {*} name optional name of the cookie
|
||||||
*/
|
*/
|
||||||
export const getCookieConsentValue = (name = defaultCookieConsentName) => {
|
export const getCookieConsentValue = (name = defaultCookieConsentName) => {
|
||||||
let cookieValue = Cookies.get(name);
|
const cookieValue = Cookies.get(name);
|
||||||
|
|
||||||
// if the cookieValue is undefined check for the legacy cookie
|
// if the cookieValue is undefined check for the legacy cookie
|
||||||
if (cookieValue === undefined) {
|
if (cookieValue === undefined) {
|
||||||
cookieValue = Cookies.get(getLegacyCookieName(name));
|
return Cookies.get(getLegacyCookieName(name));
|
||||||
}
|
}
|
||||||
return cookieValue;
|
return cookieValue;
|
||||||
};
|
};
|
||||||
@@ -201,7 +201,7 @@ class CookieConsent extends Component {
|
|||||||
cookieSecurity = location ? location.protocol === "https:" : true;
|
cookieSecurity = location ? location.protocol === "https:" : true;
|
||||||
}
|
}
|
||||||
|
|
||||||
let cookieOptions = { expires, ...extraCookieOptions, sameSite, secure: cookieSecurity };
|
const cookieOptions = { expires, ...extraCookieOptions, sameSite, secure: cookieSecurity };
|
||||||
|
|
||||||
// Fallback for older browsers where can not set SameSite=None, SEE: https://web.dev/samesite-cookie-recipes/#handling-incompatible-clients
|
// Fallback for older browsers where can not set SameSite=None, SEE: https://web.dev/samesite-cookie-recipes/#handling-incompatible-clients
|
||||||
if (sameSite === SAME_SITE_OPTIONS.NONE) {
|
if (sameSite === SAME_SITE_OPTIONS.NONE) {
|
||||||
@@ -229,12 +229,12 @@ class CookieConsent extends Component {
|
|||||||
const { acceptOnScrollPercentage } = this.props;
|
const { acceptOnScrollPercentage } = this.props;
|
||||||
|
|
||||||
// (top / height) - height * 100
|
// (top / height) - height * 100
|
||||||
let rootNode = document.documentElement,
|
const rootNode = document.documentElement,
|
||||||
body = document.body,
|
body = document.body,
|
||||||
top = "scrollTop",
|
top = "scrollTop",
|
||||||
height = "scrollHeight";
|
height = "scrollHeight";
|
||||||
|
|
||||||
let percentage =
|
const percentage =
|
||||||
((rootNode[top] || body[top]) /
|
((rootNode[top] || body[top]) /
|
||||||
((rootNode[height] || body[height]) - rootNode.clientHeight)) *
|
((rootNode[height] || body[height]) - rootNode.clientHeight)) *
|
||||||
100;
|
100;
|
||||||
|
Reference in New Issue
Block a user