-
Notifications
You must be signed in to change notification settings - Fork 48
/
exampleSelectable.vue
97 lines (92 loc) · 2.12 KB
/
exampleSelectable.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
<template>
<div class="example">
<h2>Selectable Example</h2>
<div class="row">
The picker allows to "select" the emoji displayed above it and remove the
selection when the emoji is slected.
</div>
<div class="row row-selected">
<emoji
v-if="selectedEmoji"
:data="index"
:emoji="selectedEmoji"
:size="32"
/>
<emoji v-else :data="index" emoji=":dotted_line_face:" :size="32" />
<button @click="toggleSelectable">Show / hide the picker</button>
</div>
<div class="row">
<picker
v-if="selectableVisible"
:data="index"
@select="selectableSelectEmoji"
>
<template v-slot:customCategory v-if="selectedEmoji">
<div class="emoji-mart-category-label">
<h3 class="emoji-mart-category-label">Selected</h3>
</div>
<emoji
class="emoji-selected"
:data="index"
:emoji="selectedEmoji"
:size="32"
@click="selectableUnselectEmoji"
/>
<emoji
class="emoji-delete"
:data="index"
emoji=":x:"
:size="10"
@click="selectableUnselectEmoji"
/>
</template>
</picker>
</div>
</div>
</template>
<script>
import data from '../data/all.json'
import { Picker, Emoji, EmojiIndex } from '../src'
const emojiIndex = new EmojiIndex(data)
export default {
props: {
index: {
type: Object,
},
},
data() {
return {
selectedEmoji: emojiIndex.findEmoji(':smile:'),
selectableVisible: true,
}
},
methods: {
selectableSelectEmoji(emoji) {
this.selectedEmoji = emoji
},
selectableUnselectEmoji(emoji) {
this.selectedEmoji = undefined
},
toggleSelectable() {
this.selectableVisible = !this.selectableVisible
},
},
components: {
Picker,
Emoji,
},
}
</script>
<style scoped>
.row-selected span {
vertical-align: middle;
}
.row-selected button {
vertical-align: middle;
}
.emoji-delete {
vertical-align: top;
margin-left: -21px;
margin-top: -3px;
}
</style>