-
Notifications
You must be signed in to change notification settings - Fork 152
/
ButtonLink.vue
59 lines (53 loc) · 1.61 KB
/
ButtonLink.vue
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
<template>
<NuxtLink v-if="isInternal" :to="href" class="button-link" :class="[size, bold ? 'font-semibold' : 'font-medium']">
<Markdown unwrap="p ul li" />
</NuxtLink>
<a v-else :href="href" class="button-link" :class="[size, bold ? 'font-semibold' : 'font-medium']" v-bind="linkAttrs">
<Markdown unwrap="p ul li" />
<IconExternalLink v-if="blank" class="w-4 h-4 ml-2" />
</a>
</template>
<script>
import { computed, defineComponent } from '@nuxtjs/composition-api'
import { Markdown } from '~docus/utils'
export default defineComponent({
components: { Markdown },
props: {
href: {
type: String,
default: ''
},
blank: {
type: Boolean,
default: false
},
size: {
type: String,
default: 'medium'
},
bold: {
type: Boolean,
default: false
}
},
setup(props) {
const isInternal = computed(() => props.href.startsWith('/') && props.href.startsWith('//') === false)
const linkAttrs = computed(() => (props.blank ? { rel: 'noopener nofollow', target: '_blank' } : {}))
return {
isInternal,
linkAttrs
}
}
})
</script>
<style lang="postcss" scoped>
a.button-link {
@apply inline-flex items-center flex-none rounded-md px-3 py-1.5 text-sm leading-4 text-white transition-colors duration-200 border border-transparent bg-primary-500 hover:bg-primary-600 focus:ring-2 focus:ring-offset-2 focus:ring-offset-white dark:focus:ring-offset-gray-900 focus:ring-primary-600 focus:outline-none;
&.medium {
@apply px-4 py-2 text-base leading-4;
}
&.large {
@apply px-6 py-2.5 text-lg leading-6;
}
}
</style>