7640f4d3f8
Could possibly be for future custom emoji sets that support custom skin tones? (i.e. Mutant Standard)
78 lines
1.7 KiB
Vue
78 lines
1.7 KiB
Vue
<template>
|
|
<section>
|
|
<header class="_acrylic" @click="shown = !shown">
|
|
<i
|
|
class="toggle ph-fw ph-lg"
|
|
:class="
|
|
shown
|
|
? 'ph-caret-down ph-bold ph-lg'
|
|
: 'ph-caret-up ph-bold ph-lg'
|
|
"
|
|
></i>
|
|
<slot></slot> ({{ emojis.length }})
|
|
<span v-if="props.skinToneSelector && props.skinTones">
|
|
<button
|
|
v-for="skinTone in props.skinTones"
|
|
class="_button"
|
|
@click="applySkinTone(props.skinTones.indexOf(skinTone) + 1)"
|
|
>
|
|
<i
|
|
class="ph-circle ph-fill ph-fw ph-lg"
|
|
:style="{ color: skinTone + '!important' }"
|
|
></i>
|
|
</button>
|
|
</span>
|
|
</header>
|
|
<div v-if="shown" class="body">
|
|
<button
|
|
v-for="emoji in localEmojis"
|
|
:key="emoji"
|
|
class="_button item"
|
|
@click="emit('chosen', emoji, $event)"
|
|
>
|
|
<MkEmoji class="emoji" :emoji="emoji" :normal="true" />
|
|
</button>
|
|
</div>
|
|
</section>
|
|
</template>
|
|
|
|
<script lang="ts" setup>
|
|
import { ref, watch, onMounted } from "vue";
|
|
import { addSkinTone } from "@/scripts/emojilist";
|
|
|
|
const props = defineProps<{
|
|
emojis: string[];
|
|
initialShown?: boolean;
|
|
skinToneSelector?: boolean;
|
|
skinTones?: string[];
|
|
}>();
|
|
|
|
const localEmojis = ref([...props.emojis]);
|
|
|
|
function applySkinTone(custom?: number) {
|
|
for (let i = 0; i < localEmojis.value.length; i++) {
|
|
localEmojis.value[i] = addSkinTone(localEmojis.value[i], custom);
|
|
}
|
|
}
|
|
|
|
const emit = defineEmits<{
|
|
(ev: "chosen", v: string, event: MouseEvent): void;
|
|
}>();
|
|
|
|
const shown = ref(!!props.initialShown);
|
|
|
|
onMounted(() => {
|
|
if (props.skinToneSelector) {
|
|
applySkinTone();
|
|
}
|
|
});
|
|
|
|
watch(
|
|
() => props.emojis,
|
|
(newVal) => {
|
|
localEmojis.value = [...newVal];
|
|
}
|
|
);
|
|
</script>
|
|
|
|
<style lang="scss" scoped></style>
|