From cae876a55a4a853ae0f057c5c8d5e95ae112e708 Mon Sep 17 00:00:00 2001 From: Jakub Juszczak Date: Tue, 31 Mar 2020 09:35:26 +0200 Subject: [PATCH] fix: Remove hardcoded cookie value with prop --- README.md | 2 +- src/components/CookieLaw.vue | 18 +++++++++--------- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/README.md b/README.md index ebee347..3b6e5c9 100644 --- a/README.md +++ b/README.md @@ -84,7 +84,7 @@ For a more complex layout use the **scoped slot** | cookieOptions | {} | Object | (Optional) The cookieOptions parameter is an object. And its property can be a valid cookie option, such as `path`, `domain`, `expires` / `max-age`, `samesite` or `secure`. See [tiny-cookie docs](https://github.com/Alex1990/tiny-cookie#setkey-value-options) for details. | buttonDecline | false | Boolean | Display decline button | buttonDeclineText | 'Decline' | String | 🔘Decline button text -| buttonDeclineClass | 'Cookie__declineButton' | String | Custom class name for decline button +| buttonDeclineClass | 'Cookie__button--decline' | String | Custom class name for decline button ## Events diff --git a/src/components/CookieLaw.vue b/src/components/CookieLaw.vue index 47b96b5..03b0348 100644 --- a/src/components/CookieLaw.vue +++ b/src/components/CookieLaw.vue @@ -85,7 +85,7 @@ }, buttonDeclineClass: { type: String, - default: 'Cookie__declineButton' + default: 'Cookie__button--decline' }, storageName: { type: String, @@ -160,16 +160,16 @@ }, setAccepted () { if (this.canUseLocalStorage) { - localStorage.setItem('cookie:all', true) + localStorage.setItem(this.storageName, true) } else { - Cookie.set('cookie:all', true, { ...this.cookieOptions, expires: '1Y' }) + Cookie.set(this.storageName, true, { ...this.cookieOptions, expires: '1Y' }) } }, setDeclined () { if (this.canUseLocalStorage) { - localStorage.setItem('cookie:all', false) + localStorage.setItem(this.storageName, false) } else { - Cookie.set('cookie:all', false, { ...this.cookieOptions, expires: '1Y' }) + Cookie.set(this.storageName, false, { ...this.cookieOptions, expires: '1Y' }) } }, getVisited () { @@ -189,9 +189,9 @@ isAccepted () { let accepted = false if (this.canUseLocalStorage) { - accepted = localStorage.getItem('cookie:all') + accepted = localStorage.getItem(this.storageName) } else { - accepted = Cookie.get('cookie:all') + accepted = Cookie.get(this.storageName) } if (typeof accepted === 'string') { @@ -318,7 +318,7 @@ background: darken($buttonBackgroundColor, 10%); } } - .Cookie__declineButton { + .Cookie__button--decline { background: transparent; padding: 0.625em 3.125em; color: darken($backgroundColor, 50%); @@ -361,7 +361,7 @@ .slideFromBottom-enter-active, .slideFromBottom-leave-active, .slideFromTop-enter-active, - .slideFromTop-leave-active, { + .slideFromTop-leave-active { transition: transform .4s ease-in; }