generated from mitevpi/vue-template
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathCustomVModel.vue
67 lines (64 loc) · 1.36 KB
/
CustomVModel.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
<template>
<div>
<p
:class="{ selectedStyle: selected, noselect: true }"
@click="toggleSelect"
>
{{ name }}
</p>
</div>
</template>
<script>
export default {
name: "CustomVModel",
props: {
name: String
},
data: () => ({
selected: false
}),
watch: {
// The emitted event has to be named "input" in order for the parent component
// to be able to consume this data through the v-model API
selected(val) {
this.$emit("input", { id: this.name, status: val });
}
},
methods: {
toggleSelect() {
this.selected = !this.selected;
}
}
};
</script>
<style scoped lang="scss">
p {
-webkit-font-smoothing: antialiased;
-moz-osx-font-smoothing: grayscale;
color: rgb(0, 192, 222);
background-color: white;
display: inline-block;
padding: 5px;
margin-left: 3px;
margin-right: 3px;
box-sizing: border-box;
border-radius: 25px;
border: 2px solid rgb(0, 192, 222);
transition: border 0.1s ease-in, background-color 0.3s ease-in-out,
color 0.3s ease-in-out;
}
p:hover {
background-color: rgb(0, 192, 222);
color: white;
}
.selectedStyle {
background-color: rgb(0, 192, 222);
color: white;
}
.noselect {
-webkit-user-select: none; /* Safari */
-moz-user-select: none; /* Firefox */
-ms-user-select: none; /* IE10+/Edge */
user-select: none; /* Standard */
}
</style>