-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Rens Alkemade
authored and
Rens Alkemade
committed
May 24, 2023
1 parent
3a6668b
commit 00bf090
Showing
5 changed files
with
218 additions
and
60 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,33 +1,68 @@ | ||
# FHCookieGuard | ||
|
||
A set of hooks to use to save a user's cookie preferences in a cookie(🥲). | ||
|
||
The cookie settings are stored as follows: | ||
|
||
`'["functional","analytics","marketing"]'` | ||
|
||
## Usage | ||
|
||
```js | ||
import { CookiePopup } from '@freshheads/cookie-guard' | ||
You can use the build in cookieguard to get up and running quickly or use the provided hooks to make your own. | ||
|
||
const App = () => { | ||
return ( | ||
<div> | ||
<CookiePopup /> | ||
</div> | ||
); | ||
}; | ||
``` | ||
The cookiebanner makes use of Context to share the cookie state throughout the app. | ||
|
||
We provide some basic styles but you can also use your own. | ||
Import them as global css. | ||
```css | ||
@import '@freshheads/cookie-guard/dist/style.css'; | ||
``` | ||
- Wrap your app with the Provider: | ||
|
||
```jsx | ||
import { CookieGuardContextProvider } from '@freshheads/cookie-guard'; | ||
|
||
<CookieGuardContextProvider> | ||
<App /> | ||
</CookieGuardContextProvider>; | ||
``` | ||
|
||
- The provider optionally accepts: | ||
|
||
- onCookiesChange | ||
- onCookiesSet | ||
- onCookiesCleared | ||
|
||
TODO: Documentation below needs to be changed | ||
## Documentation | ||
e.g. If you want to change the Google consent options based on the cookie settings | ||
|
||
- [Installation](doc/installation.md) | ||
- [Usage](doc/usage.md) | ||
- [Configuration](doc/configuration.md) | ||
- Add the premade Cookie Banner to your app | ||
|
||
## Browser support | ||
```jsx | ||
import { | ||
CookieGuard, | ||
CookieGuardContextProvider, | ||
CookieGuardProps | ||
} from '@freshheads/cookie-guard'; | ||
import '@freshheads/cookie-guard/dist/style.css'; | ||
This library supports the latest 2 versions of all modern browsers. But support can be extended by converting code to ES5 and using some polyfills. | ||
const CookieGuardProps = { | ||
title: 'Onze site maakt gebruik van cookies.', | ||
description: | ||
'Wij gebruiken cookies voor de werking van de website, analyse en verbetering en marketingdoeleinden.', | ||
acceptAllLabel: 'Alle cookies accepteren', | ||
saveLabel: 'Opslaan', | ||
functionalLabel: 'Noodzakelijke cookies', | ||
analyticsLabel: 'Analytische cookies', | ||
marketingLabel: 'Marketing cookies', | ||
} | ||
<CookieGuardContextProvider> | ||
<App/> | ||
<CookieGuard {...CookieGuardProps}> | ||
</CookieGuardContextProvider> | ||
``` | ||
|
||
- To style look at the source code `/src/popupstyles.css` and import your own css. | ||
|
||
- You can also use the hooks to make your own custom cookiebanner | ||
|
||
TODO: explain hooks with chakraui example | ||
|
||
```jsx | ||
``` |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
module.exports = { | ||
plugins: { | ||
'postcss-nesting': { | ||
/* plugin options */ | ||
}, | ||
}, | ||
}; |
Oops, something went wrong.