-
Notifications
You must be signed in to change notification settings - Fork 0
/
favorite.vue
85 lines (83 loc) · 2.02 KB
/
favorite.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
<template>
<div class="favoriting">
<label
class="favorite__heart"
v-bind:class="{'favorite__heart__selected': value, 'is-disabled': disabled}"
v-on:click="favorite">
<input
class="favorite__checkbox"
type="checkbox"
v-bind:name="name"
v-bind:value="value"
v-bind:required="required"
v-bind:disabled="disabled"
v-model="value">
❤
</label>
</div>
</template>
<style>
.favoriting{
display: inline-block
}
.favorite__heart {
display: inline-block;
padding: 3px;
vertical-align: middle;
line-height: 1;
font-size: 16px;
color: #ABABAB;
cursor: pointer;
-webkit-transition: color .2s ease-out;
transition: color .2s ease-out;
}
.favorite__heart.is-disabled:hover {
cursor: default;
}
.favorite__checkbox {
position: absolute;
overflow: hidden;
clip: rect(0 0 0 0);
height: 1px;
width: 1px;
margin: -1px;
padding: 0;
border: 0;
}
.favorite__heart__selected{
color: #df470b;
}
</style>
<script>
Vue.component('favorite', {
template: '#template-favorite',
data: function() {
return { };
},
props: {
'name': {
type: String,
default: 'favorite'
},
'value': {
type: Boolean,
default: false
},
'disabled': {
type: Boolean,
default: false
}
},
methods: {
favorite: function() {
if (this.disabled==true) {
return;
}
this.value = !this.value;
}
}
});
var app = new Vue({
el: 'body'
});
</script>