added extra cookie options as requested in #23

This commit is contained in:
2018-07-29 22:02:34 +02:00
parent 27833943f0
commit df6bd5464f
3 changed files with 42 additions and 9 deletions

View File

@@ -88,6 +88,7 @@ One of the props (onAccept) is a function, this function will be called after th
| onAccept | function | `() => {}` | Function to be called after the accept button has been clicked. |
| debug | boolean | undefined | Bar will be drawn regardless of cookie for debugging purposes. |
| expires | number | 365 | Number of days before the cookie expires. |
| 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 |
| contentClasses| string | "" | CSS classes to apply to the content |
@@ -162,6 +163,31 @@ Which results in:
![bootstrap styling](https://github.com/Mastermindzh/react-cookie-consent/blob/master/images/css_classes.png?raw=true)
#### Accept on scroll
You can make the cookiebar disappear after scrolling a certain percentage using acceptOnScroll and acceptOnScrollPercentage.
```js
<CookieConsent
acceptOnScroll={true}
acceptOnScrollPercentage={50}
onAccept={() => {alert("consent given")}}
>
Hello scroller :)
</CookieConsent>
```
#### Extra cookie options
You can add more cookie options using the extraCookieOptions parameter like so:
```js
<CookieConsent
extraCookieOptions={{domain: 'myexample.com'}}
>
cookie bar
</CookieConsent>
```
#### rainbows!
![rainbows!](https://github.com/Mastermindzh/react-cookie-consent/blob/master/images/rainbow.png?raw=true)