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 02:19:26 +02:00
|
|
|
<span v-if="props.skinToneSelector && props.skinTones">
|
2023-06-24 01:51:13 +02:00
|
|
|
<button
|
2023-06-24 02:19:26 +02:00
|
|
|
v-for="skinTone in props.skinTones"
|
2023-06-24 01:51:13 +02:00
|
|
|
class="_button"
|
2023-06-25 04:38:55 +02:00
|
|
|
@click.stop="
|
2023-06-24 02:47:07 +02:00
|
|
|
applyUnicodeSkinTone(
|
2023-07-06 03:28:27 +02:00
|
|
|
props.skinTones.indexOf(skinTone) + 1,
|
2023-06-24 02:47:07 +02:00
|
|
|
)
|
|
|
|
"
|
2023-06-24 01:51:13 +02:00
|
|
|
>
|
|
|
|
<i
|
|
|
|
class="ph-circle ph-fill ph-fw ph-lg"
|
2023-06-26 23:49:55 +02:00
|
|
|
:style="{ color: skinTone + ' !important' }"
|
|
|
|
:aria-label="
|
|
|
|
props.skinToneLabels
|
|
|
|
? props.skinToneLabels[
|
|
|
|
props.skinTones.indexOf(skinTone)
|
|
|
|
]
|
|
|
|
: ''
|
|
|
|
"
|
2023-06-24 01:51:13 +02:00
|
|
|
></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;
|
2023-06-24 02:19:26 +02:00
|
|
|
skinTones?: string[];
|
2023-06-26 23:49:55 +02:00
|
|
|
skinToneLabels?: string[];
|
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 localEmojis = ref([...props.emojis]);
|
|
|
|
|
2023-06-24 02:47:07 +02:00
|
|
|
function applyUnicodeSkinTone(custom?: number) {
|
2023-06-24 01:51:13 +02:00
|
|
|
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) {
|
2023-06-24 02:47:07 +02:00
|
|
|
applyUnicodeSkinTone();
|
2023-06-24 01:51:13 +02:00
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
watch(
|
|
|
|
() => props.emojis,
|
|
|
|
(newVal) => {
|
|
|
|
localEmojis.value = [...newVal];
|
2023-07-06 03:28:27 +02:00
|
|
|
},
|
2023-06-24 01:51:13 +02:00
|
|
|
);
|
2021-02-27 11:53:20 +01:00
|
|
|
</script>
|
|
|
|
|
2023-04-08 02:01:42 +02:00
|
|
|
<style lang="scss" scoped></style>
|