Skip to content

Commit

Permalink
feat: Add method to show notification manually (#45)
Browse files Browse the repository at this point in the history
This method is very useful for SPA projects. Now we can call method open() in middleware after change route
  • Loading branch information
qWici authored and apertureless committed Feb 16, 2019
1 parent a4a4d53 commit db8426e
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ For a more complex layout use the scoped slot
|---|---|
| accept | Closes the cookie disclaimer and saves to localStorage |
| close | Only closes the cookie disclaimer. The disclaimer will reappear on the next page load. |
| open | Show disclaimer if user ignored him |

## Props
| prop | default | type | description
Expand Down
8 changes: 6 additions & 2 deletions src/components/CookieLaw.vue
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<template>
<transition appear :name="transitionName">
<div class="Cookie" :class="[containerPosition, cookieTheme]" v-if="isOpen">
<slot :accept="accept" :close="close">
<slot :accept="accept" :close="close" :open="open">
<div class="Cookie__content">
<slot name="message">{{ message }}</slot>
</div>
Expand Down Expand Up @@ -132,9 +132,13 @@
this.isOpen = false
this.$emit('accept')
},
close () {
this.isOpen = false
},
open () {
if (!this.getVisited() === true) {
this.isOpen = true
}
}
}
}
Expand Down

0 comments on commit db8426e

Please sign in to comment.