絵文字ピッカーのすべての絵文字でマウスホバー時にtitle表示されるように (#9765)
* 絵文字ピッカーの絵文字アイコン選択のコンポーネント化とすべてでtitle表示 * コンポーネント化を取り消し、イベントとデータ属性で行う * fix typo --------- Co-authored-by: tamaina <tamaina@hotmail.co.jp>
This commit is contained in:
parent
c0bad443ff
commit
b7c26dc29d
2 changed files with 23 additions and 1 deletions
|
@ -8,7 +8,9 @@
|
||||||
<button
|
<button
|
||||||
v-for="emoji in emojis"
|
v-for="emoji in emojis"
|
||||||
:key="emoji"
|
:key="emoji"
|
||||||
|
:data-emoji="emoji"
|
||||||
class="_button item"
|
class="_button item"
|
||||||
|
@pointerenter="computeButtonTitle"
|
||||||
@click="emit('chosen', emoji, $event)"
|
@click="emit('chosen', emoji, $event)"
|
||||||
>
|
>
|
||||||
<MkCustomEmoji v-if="emoji[0] === ':'" class="emoji" :name="emoji" :normal="true"/>
|
<MkCustomEmoji v-if="emoji[0] === ':'" class="emoji" :name="emoji" :normal="true"/>
|
||||||
|
@ -20,6 +22,7 @@
|
||||||
|
|
||||||
<script lang="ts" setup>
|
<script lang="ts" setup>
|
||||||
import { ref, computed, Ref } from 'vue';
|
import { ref, computed, Ref } from 'vue';
|
||||||
|
import { getEmojiName } from '@/scripts/emojilist';
|
||||||
|
|
||||||
const props = defineProps<{
|
const props = defineProps<{
|
||||||
emojis: string[] | Ref<string[]>;
|
emojis: string[] | Ref<string[]>;
|
||||||
|
@ -33,4 +36,12 @@ const emit = defineEmits<{
|
||||||
const emojis = computed(() => Array.isArray(props.emojis) ? props.emojis : props.emojis.value);
|
const emojis = computed(() => Array.isArray(props.emojis) ? props.emojis : props.emojis.value);
|
||||||
|
|
||||||
const shown = ref(!!props.initialShown);
|
const shown = ref(!!props.initialShown);
|
||||||
|
|
||||||
|
/** @see MkEmojiPicker.vue */
|
||||||
|
function computeButtonTitle(ev: MouseEvent): void {
|
||||||
|
const elm = ev.target as HTMLElement;
|
||||||
|
const emoji = elm.dataset.emoji as string;
|
||||||
|
elm.title = getEmojiName(emoji) ?? emoji;
|
||||||
|
}
|
||||||
|
|
||||||
</script>
|
</script>
|
||||||
|
|
|
@ -35,8 +35,10 @@
|
||||||
<button
|
<button
|
||||||
v-for="emoji in pinned"
|
v-for="emoji in pinned"
|
||||||
:key="emoji"
|
:key="emoji"
|
||||||
|
:data-emoji="emoji"
|
||||||
class="_button item"
|
class="_button item"
|
||||||
tabindex="0"
|
tabindex="0"
|
||||||
|
@pointerenter="computeButtonTitle"
|
||||||
@click="chosen(emoji, $event)"
|
@click="chosen(emoji, $event)"
|
||||||
>
|
>
|
||||||
<MkCustomEmoji v-if="emoji[0] === ':'" class="emoji" :name="emoji" :normal="true"/>
|
<MkCustomEmoji v-if="emoji[0] === ':'" class="emoji" :name="emoji" :normal="true"/>
|
||||||
|
@ -52,6 +54,8 @@
|
||||||
v-for="emoji in recentlyUsedEmojis"
|
v-for="emoji in recentlyUsedEmojis"
|
||||||
:key="emoji"
|
:key="emoji"
|
||||||
class="_button item"
|
class="_button item"
|
||||||
|
:data-emoji="emoji"
|
||||||
|
@pointerenter="computeButtonTitle"
|
||||||
@click="chosen(emoji, $event)"
|
@click="chosen(emoji, $event)"
|
||||||
>
|
>
|
||||||
<MkCustomEmoji v-if="emoji[0] === ':'" class="emoji" :name="emoji" :normal="true"/>
|
<MkCustomEmoji v-if="emoji[0] === ':'" class="emoji" :name="emoji" :normal="true"/>
|
||||||
|
@ -90,7 +94,7 @@
|
||||||
import { ref, shallowRef, computed, watch, onMounted } from 'vue';
|
import { ref, shallowRef, computed, watch, onMounted } from 'vue';
|
||||||
import * as Misskey from 'misskey-js';
|
import * as Misskey from 'misskey-js';
|
||||||
import XSection from '@/components/MkEmojiPicker.section.vue';
|
import XSection from '@/components/MkEmojiPicker.section.vue';
|
||||||
import { emojilist, emojiCharByCategory, UnicodeEmojiDef, unicodeEmojiCategories as categories } from '@/scripts/emojilist';
|
import { emojilist, emojiCharByCategory, UnicodeEmojiDef, unicodeEmojiCategories as categories, getEmojiName } from '@/scripts/emojilist';
|
||||||
import MkRippleEffect from '@/components/MkRippleEffect.vue';
|
import MkRippleEffect from '@/components/MkRippleEffect.vue';
|
||||||
import * as os from '@/os';
|
import * as os from '@/os';
|
||||||
import { isTouchUsing } from '@/scripts/touch';
|
import { isTouchUsing } from '@/scripts/touch';
|
||||||
|
@ -291,6 +295,13 @@ function getKey(emoji: string | Misskey.entities.CustomEmoji | UnicodeEmojiDef):
|
||||||
return typeof emoji === 'string' ? emoji : 'char' in emoji ? emoji.char : `:${emoji.name}:`;
|
return typeof emoji === 'string' ? emoji : 'char' in emoji ? emoji.char : `:${emoji.name}:`;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** @see MkEmojiPicker.section.vue */
|
||||||
|
function computeButtonTitle(ev: MouseEvent): void {
|
||||||
|
const elm = ev.target as HTMLElement;
|
||||||
|
const emoji = elm.dataset.emoji as string;
|
||||||
|
elm.title = getEmojiName(emoji) ?? emoji;
|
||||||
|
}
|
||||||
|
|
||||||
function chosen(emoji: any, ev?: MouseEvent) {
|
function chosen(emoji: any, ev?: MouseEvent) {
|
||||||
const el = ev && (ev.currentTarget ?? ev.target) as HTMLElement | null | undefined;
|
const el = ev && (ev.currentTarget ?? ev.target) as HTMLElement | null | undefined;
|
||||||
if (el) {
|
if (el) {
|
||||||
|
|
Loading…
Reference in a new issue