Move src to dashboard (#152)

This commit is contained in:
Pranav Raj S
2019-10-16 14:36:17 +05:30
committed by GitHub
parent 012a2743f2
commit 2783fb6006
187 changed files with 29 additions and 29 deletions

View File

@@ -0,0 +1,103 @@
<template>
<div role="dialog" class="emoji-dialog">
<header class="emoji-dialog-header" role="menu">
<ul>
<li
v-bind:class="{ 'active': selectedKey === category.key }"
v-for="category in categoryList"
@click="changeCategory(category)"
>
<div
@click="changeCategory(category)"
role="menuitem"
class="emojione"
v-html="getEmojiUnicode(`:${category.emoji}:`)"
>
</div>
</li>
</ul>
</header>
<div class="emoji-row">
<h5 class="emoji-category-title">{{selectedKey}}</h5>
<div
v-for="(emoji, key) in selectedEmojis"
role="menuitem"
:class="`emojione`"
v-html="getEmojiUnicode(emoji[emoji.length - 1].shortname)"
v-if="filterEmoji(emoji[emoji.length - 1].shortname)"
track-by="$index"
@click="onClick(emoji[emoji.length - 1])"
/>
</div>
</div>
</div>
</template>
<script>
import strategy from 'emojione/emoji.json';
import categoryList from './categories';
import { getEmojiUnicode } from './utils';
export default {
props: ['onClick'],
data() {
return {
selectedKey: 'people',
categoryList,
selectedEmojis: [],
};
},
computed: {
emojis() {
const emojiArr = {};
// categorise and nest emoji
// sort ensures that modifiers appear unmodified keys
const keys = Object.keys(strategy);
for (const key of keys) {
const value = strategy[key];
// skip unknown categoryList
if (value.category !== 'modifier') {
if (!emojiArr[value.category]) emojiArr[value.category] = {};
const match = key.match(/(.*?)_tone(.*?)$/);
if (match) {
// this check is to stop the plugin from failing in the case that the
// emoji strategy miscategorizes tones - which was the case here:
const unmodifiedEmojiExists = !!emojiArr[value.category][match[1]];
if (unmodifiedEmojiExists) {
emojiArr[value.category][match[1]][match[2]] = value;
}
} else {
emojiArr[value.category][key] = [value];
}
}
}
return emojiArr;
},
},
// On mount render initial emoji
mounted() {
this.getInitialEmoji();
},
methods: {
// Change category and associated emojis
changeCategory(category) {
this.selectedKey = category.key;
this.selectedEmojis = this.emojis[this.selectedKey];
},
// Filter non-existant or irregular unicode characters
filterEmoji(shortName) {
return shortName !== ':relaxed:' && shortName !== ':frowning2:';
},
// Get inital emojis
getInitialEmoji() {
this.selectedEmojis = this.emojis.people;
},
getEmojiUnicode,
},
};
</script>

View File

@@ -0,0 +1,42 @@
export default [ // eslint-disable-line
{
key: 'people',
title: 'People',
emoji: 'smile',
},
{
key: 'nature',
title: 'Nature',
emoji: 'hamster',
},
{
key: 'food',
title: 'Food & Drink',
emoji: 'pizza',
},
{
key: 'activity',
title: 'Activity',
emoji: 'soccer',
},
{
key: 'travel',
title: 'Travel & Places',
emoji: 'earth_americas',
},
{
key: 'objects',
title: 'Objects',
emoji: 'bulb',
},
{
key: 'symbols',
title: 'Symbols',
emoji: 'clock9',
},
{
key: 'flags',
title: 'Flags',
emoji: 'flag_gb',
},
];

View File

@@ -0,0 +1,9 @@
import emojione from 'emojione';
/* eslint-disable */
export default function (value, method = 'shortnameToImage') {
return emojione[method](value);
}
export function getEmojiUnicode(value) {
return emojione.shortnameToUnicode(value);
}