Skip to content

Commit

Permalink
feat(Core): Add router-link support (#35)
Browse files Browse the repository at this point in the history
  • Loading branch information
on4r authored and apertureless committed Apr 19, 2018
1 parent 80f124e commit 9bc1256
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ You can also pass in the message into a named slot. This way you can for example
| prop | default | type | description
|---|---|---|---|
| buttonText | 'Got It!' | String | 🔘 Well, its the button text
| buttonLink | | String | Link to more infos
| buttonLink | | String\|Object | Link to more infos. Simple href or a [vue-router](https://github.com/vuejs/vue-router) Location object
| buttonLinkText | 'More info' | String | Label of link button
| buttonClass | 'Cookie__button' | String | Custom class name for buttons
| message | 'This website uses cookies to ensure you get the best experience on our website.' | String | Your message in the content area
Expand Down
12 changes: 10 additions & 2 deletions src/components/CookieLaw.vue
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@
<slot name="message">{{ message }}</slot>
</div>
<div class="Cookie__buttons">
<a :href="buttonLink" v-if="buttonLink" :class="buttonClass">{{ buttonLinkText }}</a>
<a :href="buttonLink" v-if="externalButtonLink" :class="buttonClass">{{ buttonLinkText }}</a>
<router-link :to="buttonLink" v-if="internalButtonLink" :class="buttonClass">{{ buttonLinkText }}</router-link>
<div :class="buttonClass" @click="accept">{{ buttonText }}</div>
</div>
</div>
Expand All @@ -21,7 +22,8 @@
default: 'Got it!'
},
buttonLink: {
type: String
type: [String, Object],
required: false
},
buttonLinkText: {
type: String,
Expand Down Expand Up @@ -72,6 +74,12 @@
},
cookieTheme () {
return `Cookie--${this.theme}`
},
externalButtonLink () {
return typeof this.buttonLink === 'string' && this.buttonLink.length
},
internalButtonLink () {
return typeof this.buttonLink === 'object' && this.buttonLink != null && Object.keys(this.buttonLink).length
}
},
created () {
Expand Down

0 comments on commit 9bc1256

Please sign in to comment.