-
Notifications
You must be signed in to change notification settings - Fork 226
/
Copy pathCustomButton.vue
146 lines (144 loc) · 3.34 KB
/
CustomButton.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
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
<template>
<button
class="custom-button flex align-center justify-content-center"
:class="{
'is-dark': dark,
'with-border': withBorder,
'is-hover': hover,
'is-selected': selected,
'round': round
}"
tabindex="-1"
type="button"
@click.prevent.stop="$emit('click')"
@focus="$emit('focus')"
@blur="$emit('blur')"
@mouseover="$emit('mouseover')"
@mouseleave="$emit('mouseleave')"
>
<span
:style="[bgStyle]"
class="custom-button-effect"
/>
<span
class="custom-button-content flex align-center justify-content-center flex-1"
:style="[colorStyle]"
>
<slot :style="[colorStyle]" />
</span>
</button>
</template>
<script>
export default {
name: 'CustomButton',
props: {
color: { type: String, default: 'dodgerblue' },
dark: { type: Boolean, default: false },
withBorder: { type: Boolean, default: false },
hover: { type: Boolean, default: false },
selected: { type: Boolean, default: false },
round: { type: Boolean, default: false }
},
computed: {
colorStyle () {
const color = this.dark ? 'white' : this.color
return {
color: color,
fill: color
}
},
bgStyle () {
return {
backgroundColor: this.color
}
}
}
}
</script>
<style lang="scss" scoped>
.custom-button {
padding: 0px 20px;
position: relative;
background-color: white;
border: 1px solid transparent;
border-radius: 4px;
height: 30px;
font-size: 13px;
outline: none;
cursor: pointer;
-webkit-transition: all 0.25s cubic-bezier(0.645, 0.045, 0.355, 1);
color: #FFF;
font-weight: 500;
&-content {
position: relative;
}
svg {
position: relative;
-webkit-transition: all 450ms cubic-bezier(0.23, 1, 0.32, 1) 0ms;
transition: all 450ms cubic-bezier(0.23, 1, 0.32, 1) 0ms;
fill: dodgerblue;
}
.custom-button-effect {
position: absolute;
background: dodgerblue;
top: 0;
left: 0;
bottom: 0;
right: 0;
height: 30px;
border-radius: 4px;
width: 100%;
-webkit-transition: all 450ms cubic-bezier(0.23, 1, 0.32, 1) 0ms;
transition: all 450ms cubic-bezier(0.23, 1, 0.32, 1) 0ms;
transform: scale(0);
}
&.with-border {
border: 1px solid #eaeaea;
}
&:hover, &.is-hover {
border: 1px solid transparent !important;
.custom-button-effect {
transform: scale(1);
opacity: (.6);
}
svg {
fill: white !important;
}
.custom-button-content {
color: #fff !important;
}
}
&.is-selected {
border: 1px solid transparent !important;
.custom-button-effect {
transform: scale(1);
opacity: (1);
}
svg {
fill: white !important;
}
.custom-button-content {
color: #fff !important;
}
}
&.is-dark {
background-color: #424242;
&.with-border {
border-color: lighten(#424242, 20%);
}
svg {
fill: white !important;
}
}
&.round {
padding: 0;
width: 24px;
height: 24px;
border-radius: 50%;
.custom-button-effect {
border-radius: 50%;
height: 24px;
}
}
}
</style>