forked from EnergySage/es-ds
-
Notifications
You must be signed in to change notification settings - Fork 0
/
EsButton.vue
83 lines (80 loc) · 1.91 KB
/
EsButton.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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
<template>
<b-button
:class="{ 'inline': inline }"
:variant="computedVariant"
:size="size"
v-bind="$attrs"
v-on="$listeners">
<!--
@slot Button Content
@binding {string} text or html of the button content
-->
<slot />
</b-button>
</template>
<script lang="js">
import { BButton } from 'bootstrap-vue';
export default {
name: 'EsButton',
components: {
BButton,
},
props: {
/**
* Button Variant
*
*/
variant: {
type: String,
default: 'primary',
required: false,
},
/**
* Outline only button
*/
outline: {
type: Boolean,
default: false,
},
/**
* Size of button
*/
size: {
type: String,
validator: (val) => ['lg', 'md', 'sm'].includes(val),
default: 'md',
},
/**
* Only works for 'link' variant buttons.
* Removes the fixed height and padding so the button can fit nicely within a block of text.
*/
inline: {
type: Boolean,
default: false,
},
},
computed: {
/**
* Compute the Variant
* used for when you want to `outline` something but don't know the
* theme's default variant
*
* @returns { string } computed variant based on outline prop
*/
computedVariant() {
return `${this.outline && this.variant !== 'link' ? 'outline-' : ''}${this.variant}`;
},
},
};
</script>
<style lang="scss" scoped>
.btn-link.inline {
/* use normal CSS here so users can override with utility classes as necessary */
border: 0;
height: auto;
line-height: inherit;
margin: 0;
padding: 0;
vertical-align: baseline;
}
</style>