diff options
| author | tamaina <tamaina@hotmail.co.jp> | 2023-01-22 12:07:38 +0000 |
|---|---|---|
| committer | tamaina <tamaina@hotmail.co.jp> | 2023-01-22 12:07:38 +0000 |
| commit | a8b19f4aa8ca014ee4f86f15279c1b9b0b592c65 (patch) | |
| tree | 779967d21452e8fab4d9ec872a1277ac68f95956 /packages/frontend/src/components/MkReactedUsersDialog.vue | |
| parent | refactor (diff) | |
| parent | 13.1.7 (diff) | |
| download | misskey-a8b19f4aa8ca014ee4f86f15279c1b9b0b592c65.tar.gz misskey-a8b19f4aa8ca014ee4f86f15279c1b9b0b592c65.tar.bz2 misskey-a8b19f4aa8ca014ee4f86f15279c1b9b0b592c65.zip | |
Merge branch 'develop' into emoji-re
Diffstat (limited to 'packages/frontend/src/components/MkReactedUsersDialog.vue')
| -rw-r--r-- | packages/frontend/src/components/MkReactedUsersDialog.vue | 92 |
1 files changed, 92 insertions, 0 deletions
diff --git a/packages/frontend/src/components/MkReactedUsersDialog.vue b/packages/frontend/src/components/MkReactedUsersDialog.vue new file mode 100644 index 0000000000..2a8dffc014 --- /dev/null +++ b/packages/frontend/src/components/MkReactedUsersDialog.vue @@ -0,0 +1,92 @@ +<template> +<MkModalWindow + ref="dialog" + :width="400" + :height="450" + @close="dialog.close()" + @closed="emit('closed')" +> + <template #header>{{ i18n.ts.reactions }}</template> + + <MkSpacer :margin-min="20" :margin-max="28"> + <div v-if="note" class="_gaps"> + <div :class="$style.tabs"> + <button v-for="reaction in reactions" :key="reaction" :class="[$style.tab, { [$style.tabActive]: tab === reaction }]" class="_button" @click="tab = reaction"> + <MkReactionIcon :reaction="reaction"/> + <span style="margin-left: 4px;">{{ note.reactions[reaction] }}</span> + </button> + </div> + <MkA v-for="user in users" :key="user.id" :to="userPage(user)"> + <MkUserCardMini :user="user" :with-chart="false"/> + </MkA> + </div> + <div v-else> + <MkLoading/> + </div> + </MkSpacer> +</MkModalWindow> +</template> + +<script lang="ts" setup> +import { onMounted, watch } from 'vue'; +import * as misskey from 'misskey-js'; +import MkModalWindow from '@/components/MkModalWindow.vue'; +import MkReactionIcon from '@/components/MkReactionIcon.vue'; +import MkUserCardMini from '@/components/MkUserCardMini.vue'; +import { userPage } from '@/filters/user'; +import { i18n } from '@/i18n'; +import * as os from '@/os'; + +const emit = defineEmits<{ + (ev: 'closed'): void, +}>(); + +const props = defineProps<{ + noteId: misskey.entities.Note['id']; +}>(); + +const dialog = $shallowRef<InstanceType<typeof MkModalWindow>>(); + +let note = $ref<misskey.entities.Note>(); +let tab = $ref<string>(); +let reactions = $ref<string[]>(); +let users = $ref(); + +watch($$(tab), async () => { + const res = await os.api('notes/reactions', { + noteId: props.noteId, + type: tab, + limit: 30, + }); + + users = res.map(x => x.user); +}); + +onMounted(() => { + os.api('notes/show', { + noteId: props.noteId, + }).then((res) => { + reactions = Object.keys(res.reactions); + tab = reactions[0]; + note = res; + }); +}); +</script> + +<style lang="scss" module> +.tabs { + display: flex; + gap: 8px; + flex-wrap: wrap; +} + +.tab { + padding: 4px 6px; + border: solid 1px var(--divider); + border-radius: 6px; +} + +.tabActive { + border-color: var(--accent); +} +</style> |