2021-02-27 11:53:20 +01:00
|
|
|
<template>
|
2023-04-08 02:01:42 +02:00
|
|
|
<section>
|
|
|
|
<header class="_acrylic" @click="shown = !shown">
|
|
|
|
<i
|
|
|
|
class="toggle ph-fw ph-lg"
|
|
|
|
:class="
|
|
|
|
shown
|
2023-06-24 01:51:13 +02:00
|
|
|
? 'ph-caret-down ph-bold ph-lg'
|
2023-04-08 02:01:42 +02:00
|
|
|
: 'ph-caret-up ph-bold ph-lg'
|
|
|
|
"
|
|
|
|
></i>
|
|
|
|
<slot></slot> ({{ emojis.length }})
|
2023-06-24 01:51:13 +02:00
|
|
|
<span v-if="props.skinToneSelector">
|
|
|
|
<button
|
|
|
|
v-for="skinTone in skinTones"
|
|
|
|
class="_button"
|
|
|
|
@click="applySkinTone(skinTones.indexOf(skinTone))"
|
|
|
|
>
|
|
|
|
<i
|
|
|
|
class="ph-circle ph-fill ph-fw ph-lg"
|
|
|
|
:style="{ color: skinTone + '!important' }"
|
|
|
|
></i>
|
|
|
|
</button>
|
|
|
|
</span>
|
2023-04-08 02:01:42 +02:00
|
|
|
</header>
|
|
|
|
<div v-if="shown" class="body">
|
|
|
|
<button
|
2023-06-24 01:51:13 +02:00
|
|
|
v-for="emoji in localEmojis"
|
2023-04-08 02:01:42 +02:00
|
|
|
:key="emoji"
|
|
|
|
class="_button item"
|
|
|
|
@click="emit('chosen', emoji, $event)"
|
|
|
|
>
|
|
|
|
<MkEmoji class="emoji" :emoji="emoji" :normal="true" />
|
|
|
|
</button>
|
|
|
|
</div>
|
|
|
|
</section>
|
2021-02-27 11:53:20 +01:00
|
|
|
</template>
|
|
|
|
|
2022-01-18 15:06:16 +01:00
|
|
|
<script lang="ts" setup>
|
2023-06-24 01:51:13 +02:00
|
|
|
import { ref, watch, onMounted } from "vue";
|
|
|
|
import { addSkinTone } from "@/scripts/emojilist";
|
2021-02-27 11:53:20 +01:00
|
|
|
|
2022-01-18 15:06:16 +01:00
|
|
|
const props = defineProps<{
|
|
|
|
emojis: string[];
|
|
|
|
initialShown?: boolean;
|
2023-06-24 01:51:13 +02:00
|
|
|
skinToneSelector?: boolean;
|
2022-01-18 15:06:16 +01:00
|
|
|
}>();
|
2021-02-27 11:53:20 +01:00
|
|
|
|
2023-06-24 01:51:13 +02:00
|
|
|
const skinTones = [
|
|
|
|
"#FFDC5E",
|
|
|
|
"#F7DFCF",
|
|
|
|
"#F3D3A3",
|
|
|
|
"#D6AE89",
|
|
|
|
"#B17F56",
|
|
|
|
"#7D523C",
|
|
|
|
];
|
|
|
|
|
|
|
|
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);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-01-18 15:06:16 +01:00
|
|
|
const emit = defineEmits<{
|
2023-04-08 02:01:42 +02:00
|
|
|
(ev: "chosen", v: string, event: MouseEvent): void;
|
2022-01-18 15:06:16 +01:00
|
|
|
}>();
|
2021-02-27 11:53:20 +01:00
|
|
|
|
2022-01-18 15:06:16 +01:00
|
|
|
const shown = ref(!!props.initialShown);
|
2023-06-24 01:51:13 +02:00
|
|
|
|
|
|
|
onMounted(() => {
|
|
|
|
if (props.skinToneSelector) {
|
|
|
|
applySkinTone();
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
watch(
|
|
|
|
() => props.emojis,
|
|
|
|
(newVal) => {
|
|
|
|
localEmojis.value = [...newVal];
|
|
|
|
}
|
|
|
|
);
|
2021-02-27 11:53:20 +01:00
|
|
|
</script>
|
|
|
|
|
2023-04-08 02:01:42 +02:00
|
|
|
<style lang="scss" scoped></style>
|