hippofish/packages/frontend/src/components/MkEmojiPickerDialog.vue

92 lines
2 KiB
Vue
Raw Normal View History

<!--
SPDX-FileCopyrightText: syuilo and misskey-project
SPDX-License-Identifier: AGPL-3.0-only
-->
<template>
<MkModal
ref="modal"
v-slot="{ type, maxHeight }"
2023-05-19 06:58:09 +02:00
:zPriority="'middle'"
:preferType="defaultStore.state.emojiPickerUseDrawerForMobile === false ? 'popup' : 'auto'"
2023-05-19 06:58:09 +02:00
:transparentBg="true"
:manualShowing="manualShowing"
:src="src"
@click="modal?.close()"
@opening="opening"
@close="emit('close')"
@closed="emit('closed')"
>
<MkEmojiPicker
ref="picker"
2023-05-27 04:35:26 +02:00
class="_popup _shadow"
:class="{ [$style.drawer]: type === 'drawer' }"
2023-05-19 06:58:09 +02:00
:showPinned="showPinned"
:pinnedEmojis="pinnedEmojis"
2023-05-19 06:58:09 +02:00
:asReactionPicker="asReactionPicker"
2024-02-06 21:23:37 +01:00
:targetNote="targetNote"
2023-05-19 06:58:09 +02:00
:asDrawer="type === 'drawer'"
:max-height="maxHeight"
@chosen="chosen"
/>
</MkModal>
</template>
<script lang="ts" setup>
2024-02-06 21:23:37 +01:00
import * as Misskey from 'misskey-js';
import { shallowRef } from 'vue';
import MkModal from '@/components/MkModal.vue';
import MkEmojiPicker from '@/components/MkEmojiPicker.vue';
2023-09-19 09:37:43 +02:00
import { defaultStore } from '@/store.js';
const props = withDefaults(defineProps<{
manualShowing?: boolean | null;
src?: HTMLElement;
showPinned?: boolean;
pinnedEmojis?: string[],
asReactionPicker?: boolean;
2024-02-06 21:23:37 +01:00
targetNote?: Misskey.entities.Note;
choseAndClose?: boolean;
}>(), {
manualShowing: null,
showPinned: true,
pinnedEmojis: undefined,
asReactionPicker: false,
choseAndClose: true,
});
const emit = defineEmits<{
2024-03-02 17:36:49 +01:00
(ev: 'done', v: string): void;
2022-01-28 04:20:42 +01:00
(ev: 'close'): void;
(ev: 'closed'): void;
}>();
const modal = shallowRef<InstanceType<typeof MkModal>>();
const picker = shallowRef<InstanceType<typeof MkEmojiPicker>>();
2024-03-02 17:36:49 +01:00
function chosen(emoji: string) {
emit('done', emoji);
if (props.choseAndClose) {
modal.value?.close();
}
}
function opening() {
picker.value?.reset();
picker.value?.focus();
// 何故かちょっと待たないとフォーカスされない
setTimeout(() => {
picker.value?.focus();
}, 10);
}
</script>
2023-05-27 04:35:26 +02:00
<style lang="scss" module>
.drawer {
border-radius: var(--radius-lg);
2023-05-27 04:35:26 +02:00
border-bottom-right-radius: 0;
border-bottom-left-radius: 0;
}
</style>