Skip to content
This repository was archived by the owner on Mar 1, 2024. It is now read-only.
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion src/CookieBanner.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ export type CookieBannerRequiredProps = {
},
/** used to set the cookie path */
cookiePath?: string,
/** used to set the cookie domain */
cookieDomain?: string,
/** whether the cookie banner should be dismissed on scroll or not */
dismissOnScroll?: boolean,
/** amount of pixel the user need to scroll to dismiss the cookie banner */
Expand Down Expand Up @@ -73,6 +75,7 @@ export default class CookieBanner extends React.Component<CookieBanner.Props, St
})
]),
cookiePath: PropTypes.string,
cookieDomain: PropTypes.string,
dismissOnScroll: PropTypes.bool,
dismissOnScrollThreshold: PropTypes.number
}
Expand Down Expand Up @@ -147,10 +150,11 @@ export default class CookieBanner extends React.Component<CookieBanner.Props, St
}

onAccept = () => {
const { cookies, cookie, cookieExpiration, cookiePath: path, onAccept } = this.props as CookieBannerDefaultedProps;
const { cookies, cookie, cookieExpiration, cookiePath: path, cookieDomain: domain, onAccept } = this.props as CookieBannerDefaultedProps;

cookies.set(cookie, true, {
path,
domain,
expires: new Date(Date.now() + (this.getSecondsSinceExpiration(cookieExpiration) * 1000))
});

Expand Down
1 change: 1 addition & 0 deletions src/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ React Cookie banner dismissable with just a scroll!
| **cookie** | <code>String</code> | <code>"accepts-cookies"</code> | *optional*. Cookie-key used to save user's decision about you cookie-policy |
| **cookieExpiration** | <code>union(Integer &#124; {years: ?Number, days: ?Number, hours: ?Number})</code> | <code>{ "years": 1 }</code> | *optional*. Used to set the cookie expiration |
| **cookiePath** | <code>String</code> | | *optional*. Used to set the cookie path |
| **cookieDomain** | <code>String</code> | | *optional*. Used to set the cookie domain |
| **dismissOnScroll** | <code>Boolean</code> | <code>true</code> | *optional*. Whether the cookie banner should be dismissed on scroll or not |
| **dismissOnScrollThreshold** | <code>Number</code> | <code>0</code> | *optional*. amount of pixel the user need to scroll to dismiss the cookie banner |
| **closeIcon** | <code>String</code> | | *optional*. ClassName passed to close-icon |
Expand Down