-
-
Notifications
You must be signed in to change notification settings - Fork 30
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Emoji picker inserts emojis and can be closed
- Loading branch information
Showing
3 changed files
with
90 additions
and
21 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
<template> | ||
<div class="emoji-picker"> | ||
<div class="emoji-picker" v-on-clickaway="blur"> | ||
<div class="card card-body"> | ||
<div style="display:flex; flex-direction:column;"> | ||
<div class="emoji-grid"> | ||
|
@@ -15,7 +15,8 @@ | |
:src="url(emojis.emoticons[code])" | ||
:title="emojis.emoticons[code].name" | ||
:alt="emojis.emoticons[code].native" | ||
@mouseover="mouseOver(emojis.emoticons[code])"/> | ||
@mouseover="mouseOver(emojis.emoticons[code])" | ||
@click="select(code)"/> | ||
</template> | ||
</div> | ||
</div> | ||
|
@@ -37,7 +38,7 @@ | |
|
||
<div class="search-box"> | ||
<input class="form-control" v-model="searchPhrase" placeholder="Wyszukaj emoji..."/> | ||
<button class="btn btn-primary" type="button"> | ||
<button class="btn btn-primary" type="button" ref="close-button" @click="close"> | ||
<i class="fas fa-times"/> | ||
Zamknij | ||
</button> | ||
|
@@ -48,7 +49,10 @@ | |
</template> | ||
|
||
<script> | ||
import {mixin as clickAway} from 'vue-clickaway'; | ||
export default { | ||
mixins: [clickAway], | ||
props: { | ||
emojis: {require: true}, | ||
}, | ||
|
@@ -59,6 +63,17 @@ export default { | |
}; | ||
}, | ||
methods: { | ||
select(emoji) { | ||
this.$emit('input', emoji); | ||
}, | ||
blur(blurEvent) { | ||
if (this.isDesktop()) { | ||
this.$emit('blur', blurEvent); | ||
} | ||
}, | ||
close(closeEvent) { | ||
this.$emit('close', closeEvent); | ||
}, | ||
url(emoji) { | ||
return 'https://cdn.jsdelivr.net/gh/twitter/[email protected]/assets/svg/' + emoji.unified + '.svg'; | ||
}, | ||
|
@@ -76,6 +91,9 @@ export default { | |
} | ||
return false; | ||
}, | ||
clearSearchPhrase() { | ||
this.searchPhrase = ''; | ||
}, | ||
keywords(emoji) { | ||
if (emoji) { | ||
return emoji.keywords.map(keyword => '"' + keyword + '"').join(", "); | ||
|
@@ -87,6 +105,10 @@ export default { | |
}, | ||
mouseLeave() { | ||
this.emoji = null; | ||
}, | ||
isDesktop() { | ||
const style = window.getComputedStyle(this.$refs["close-button"]); | ||
return style.display === 'none'; | ||
} | ||
}, | ||
computed: { | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters