Skip to content

Commit

Permalink
fix: Remove hardcoded cookie value with prop
Browse files Browse the repository at this point in the history
  • Loading branch information
apertureless committed Mar 31, 2020
1 parent 0d756a5 commit cae876a
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 10 deletions.
2 changes: 1 addition & 1 deletion README.md
Expand Up @@ -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
Expand Down
18 changes: 9 additions & 9 deletions src/components/CookieLaw.vue
Expand Up @@ -85,7 +85,7 @@
},
buttonDeclineClass: {
type: String,
default: 'Cookie__declineButton'
default: 'Cookie__button--decline'
},
storageName: {
type: String,
Expand Down Expand Up @@ -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 () {
Expand All @@ -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') {
Expand Down Expand Up @@ -318,7 +318,7 @@
background: darken($buttonBackgroundColor, 10%);
}
}
.Cookie__declineButton {
.Cookie__button--decline {
background: transparent;
padding: 0.625em 3.125em;
color: darken($backgroundColor, 50%);
Expand Down Expand Up @@ -361,7 +361,7 @@
.slideFromBottom-enter-active,
.slideFromBottom-leave-active,
.slideFromTop-enter-active,
.slideFromTop-leave-active, {
.slideFromTop-leave-active {
transition: transform .4s ease-in;
}
Expand Down

0 comments on commit cae876a

Please sign in to comment.