initial attempts at making emoji-picker somewhat extensible

This commit is contained in:
Henry Jameson 2019-08-12 14:20:08 +03:00
parent 036882d27c
commit 579b5c9e77
3 changed files with 144 additions and 146 deletions

View file

@ -6,7 +6,8 @@ const EmojiPicker = {
data () { data () {
return { return {
keyword: '', keyword: '',
activeGroup: 'standard' activeGroup: 'standard',
showingAdditional: false
} }
}, },
methods: { methods: {
@ -28,6 +29,9 @@ const EmojiPicker = {
this.activeGroup = key this.activeGroup = key
} }
}) })
},
toggleAdditional (value) {
this.showingAdditional = value
} }
}, },
computed: { computed: {

View file

@ -0,0 +1,83 @@
@import '../../_variables.scss';
.emoji-picker {
position: absolute;
z-index: 1;
right: 0;
width: 300px;
height: 300px;
display: flex;
flex-direction: column;
margin: 0 !important;
.emoji {
&-tabs {
&-item {
padding: 0 5px;
&.active {
border-bottom: 4px solid;
i {
color: $fallback--lightText;
color: var(--lightText, $fallback--lightText);
}
}
}
}
&-content {
display: flex;
flex-direction: column;
}
&-search {
padding: 5px;
flex: 0 0 1px;
input {
width: 100%;
}
}
&-groups {
flex: 1 1 1px;
position: relative;
overflow: auto;
}
&-group {
display: flex;
align-items: center;
flex-wrap: wrap;
padding: 5px;
justify-content: space-between;
&-title {
font-size: 12px;
width: 100%;
margin: 0;
}
}
&-item {
width: 32px;
height: 32px;
box-sizing: border-box;
display: flex;
font-size: 32px;
align-items: center;
justify-content: center;
margin: 2px;
cursor: pointer;
img {
max-width: 100%;
max-height: 100%;
}
}
}
}

View file

@ -1,161 +1,72 @@
<template> <template>
<div class="emoji-dropdown-menu panel panel-default"> <div class="emoji-picker panel panel-default">
<div class="panel-heading emoji-tabs"> <div class="panel-heading">
<span <span class="emoji-tabs">
v-for="(value, key) in emojis" <span
:key="key" v-for="(value, key) in emojis"
class="emoji-tabs-item" :key="key"
:class="{'active': activeGroup === key}" class="emoji-tabs-item"
:title="value.text" :class="{'active': activeGroup === key}"
@click.prevent="highlight(key)" :title="value.text"
> @click.prevent="highlight(key)"
<i :class="value.icon" /> >
<i :class="value.icon" />
</span>
</span>
<span class="additional-tabs">
<slot name="tabs" />
</span> </span>
</div> </div>
<div class="panel-body emoji-dropdown-menu-content"> <div class="panel-body emoji-dropdown-menu-content">
<div class="emoji-search">
<input
v-model="keyword"
type="text"
class="form-control"
>
</div>
<div <div
ref="emoji-groups" v-if="!showingAdditional"
class="emoji-groups" class="emoji-content"
@scroll="scrolledGroup"
> >
<div class="emoji-search">
<input
v-model="keyword"
type="text"
class="form-control"
>
</div>
<div <div
v-for="(value, key) in emojis" ref="emoji-groups"
:key="key" class="emoji-groups"
class="emoji-group" @scroll="scrolledGroup"
> >
<h6 <div
:ref="'group-' + key" v-for="(value, key) in emojis"
class="emoji-group-title" :key="key"
class="emoji-group"
> >
{{ value.text }} <h6
</h6> :ref="'group-' + key"
<span class="emoji-group-title"
v-for="emoji in value.emojis"
:key="key + emoji.displayText"
:title="emoji.displayText"
class="emoji-item"
@click="onEmoji(emoji)"
>
<span v-if="!emoji.imageUrl">{{ emoji.replacement }}</span>
<img
v-else
:src="emoji.imageUrl"
> >
</span> {{ value.text }}
</h6>
<span
v-for="emoji in value.emojis"
:key="key + emoji.displayText"
:title="emoji.displayText"
class="emoji-item"
@click="onEmoji(emoji)"
>
<span v-if="!emoji.imageUrl">{{ emoji.replacement }}</span>
<img
v-else
:src="emoji.imageUrl"
>
</span>
</div>
</div> </div>
</div> </div>
<div v-if="showingAdditional" class="additional-tabs-content">
<slot name="tab-content" />
</div>
</div> </div>
</div> </div>
</template> </template>
<script src="./emoji_picker.js"></script> <script src="./emoji_picker.js"></script>
<style lang="scss" src="./emoji_picker.scss"></style>
<style lang="scss">
@import '../../_variables.scss';
.emoji {
&-dropdown {
position: absolute;
right: 0;
top: 28px;
z-index: 1;
&-toggle {
cursor: pointer;
position: absolute;
top: -23px;
right: 2px;
line-height: 1;
i {
font-size: 18px;
}
}
&-menu {
position: absolute;
z-index: 1;
right: 0;
width: 300px;
height: 300px;
display: flex;
flex-direction: column;
margin: 0 !important;
&-content {
flex: 1 1 1px;
display: flex;
flex-direction: column;
}
}
}
&-tabs {
&-item {
padding: 0 5px;
&.active {
border-bottom: 4px solid;
i {
color: $fallback--lightText;
color: var(--lightText, $fallback--lightText);
}
}
}
}
&-search {
padding: 5px;
input {
width: 100%;
}
}
&-groups {
flex: 1 1 1px;
overflow: auto;
position: relative;
}
&-group {
display: flex;
align-items: center;
flex-wrap: wrap;
width: 100%;
&-title {
font-size: 12px;
width: 100%;
margin: 0;
padding: 5px;
}
}
&-item {
width: 32px;
height: 32px;
box-sizing: border-box;
display: flex;
font-size: 32px;
align-items: center;
justify-content: center;
margin: 2px;
cursor: pointer;
img {
max-width: 100%;
max-height: 100%;
}
}
}
</style>