2023-07-27 08:31:52 +03:00
|
|
|
<!--
|
|
|
|
SPDX-FileCopyrightText: syuilo and other misskey contributors
|
|
|
|
SPDX-License-Identifier: AGPL-3.0-only
|
|
|
|
-->
|
|
|
|
|
2023-03-03 05:29:34 +02:00
|
|
|
<template>
|
|
|
|
<Transition
|
2023-05-19 07:58:09 +03:00
|
|
|
:enterActiveClass="defaultStore.state.animation ? $style.transition_popup_enterActive : ''"
|
|
|
|
:leaveActiveClass="defaultStore.state.animation ? $style.transition_popup_leaveActive : ''"
|
|
|
|
:enterFromClass="defaultStore.state.animation ? $style.transition_popup_enterFrom : ''"
|
|
|
|
:leaveToClass="defaultStore.state.animation ? $style.transition_popup_leaveTo : ''"
|
|
|
|
appear @afterLeave="emit('closed')"
|
2023-03-03 05:29:34 +02:00
|
|
|
>
|
|
|
|
<div v-if="showing" :class="$style.root" class="_popup _shadow" :style="{ zIndex, top: top + 'px', left: left + 'px' }" @mouseover="() => { emit('mouseover'); }" @mouseleave="() => { emit('mouseleave'); }">
|
|
|
|
<div v-if="user != null">
|
|
|
|
<div :class="$style.banner" :style="user.bannerUrl ? `background-image: url(${user.bannerUrl})` : ''">
|
2023-04-01 08:01:57 +03:00
|
|
|
<span v-if="$i && $i.id != user.id && user.isFollowed" :class="$style.followed">{{ i18n.ts.followsYou }}</span>
|
2023-03-03 05:29:34 +02:00
|
|
|
</div>
|
|
|
|
<svg viewBox="0 0 128 128" :class="$style.avatarBack">
|
|
|
|
<g transform="matrix(1.6,0,0,1.6,-38.4,-51.2)">
|
|
|
|
<path d="M64,32C81.661,32 96,46.339 96,64C95.891,72.184 104,72 104,72C104,72 74.096,80 64,80C52.755,80 24,72 24,72C24,72 31.854,72.018 32,64C32,46.339 46.339,32 64,32Z" style="fill: var(--popup);"/>
|
|
|
|
</g>
|
|
|
|
</svg>
|
|
|
|
<MkAvatar :class="$style.avatar" :user="user" indicator/>
|
|
|
|
<div :class="$style.title">
|
|
|
|
<MkA :class="$style.name" :to="userPage(user)"><MkUserName :user="user" :nowrap="false"/></MkA>
|
|
|
|
<div :class="$style.username"><MkAcct :user="user"/></div>
|
|
|
|
</div>
|
|
|
|
<div :class="$style.description">
|
2023-11-04 11:27:22 +02:00
|
|
|
<Mfm v-if="user.description" :class="$style.mfm" :text="user.description" :author="user"/>
|
2023-03-03 05:29:34 +02:00
|
|
|
<div v-else style="opacity: 0.7;">{{ i18n.ts.noAccountDescription }}</div>
|
|
|
|
</div>
|
|
|
|
<div :class="$style.status">
|
|
|
|
<div :class="$style.statusItem">
|
2023-04-01 08:01:57 +03:00
|
|
|
<div :class="$style.statusItemLabel">{{ i18n.ts.notes }}</div>
|
2023-03-03 05:29:34 +02:00
|
|
|
<div>{{ number(user.notesCount) }}</div>
|
|
|
|
</div>
|
2023-12-18 13:59:20 +02:00
|
|
|
<div v-if="isFollowingVisibleForMe(user)" :class="$style.statusItem">
|
2023-04-01 08:01:57 +03:00
|
|
|
<div :class="$style.statusItemLabel">{{ i18n.ts.following }}</div>
|
2023-03-03 05:29:34 +02:00
|
|
|
<div>{{ number(user.followingCount) }}</div>
|
|
|
|
</div>
|
2023-12-18 13:59:20 +02:00
|
|
|
<div v-if="isFollowersVisibleForMe(user)" :class="$style.statusItem">
|
2023-04-01 08:01:57 +03:00
|
|
|
<div :class="$style.statusItemLabel">{{ i18n.ts.followers }}</div>
|
2023-03-03 05:29:34 +02:00
|
|
|
<div>{{ number(user.followersCount) }}</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
<button class="_button" :class="$style.menu" @click="showMenu"><i class="ti ti-dots"></i></button>
|
2023-10-17 14:56:17 +03:00
|
|
|
<MkFollowButton v-if="$i && user.id != $i.id" v-model:user="user" :class="$style.follow" mini/>
|
2023-03-03 05:29:34 +02:00
|
|
|
</div>
|
|
|
|
<div v-else>
|
|
|
|
<MkLoading/>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</Transition>
|
|
|
|
</template>
|
|
|
|
|
|
|
|
<script lang="ts" setup>
|
2023-12-07 07:42:09 +02:00
|
|
|
import { onMounted, ref } from 'vue';
|
2023-09-04 07:33:38 +03:00
|
|
|
import * as Misskey from 'misskey-js';
|
2023-03-03 05:29:34 +02:00
|
|
|
import MkFollowButton from '@/components/MkFollowButton.vue';
|
2023-09-19 10:37:43 +03:00
|
|
|
import { userPage } from '@/filters/user.js';
|
|
|
|
import * as os from '@/os.js';
|
2024-01-04 11:32:46 +02:00
|
|
|
import { misskeyApi } from '@/scripts/misskey-api.js';
|
2023-09-19 10:37:43 +03:00
|
|
|
import { getUserMenu } from '@/scripts/get-user-menu.js';
|
|
|
|
import number from '@/filters/number.js';
|
|
|
|
import { i18n } from '@/i18n.js';
|
|
|
|
import { defaultStore } from '@/store.js';
|
|
|
|
import { $i } from '@/account.js';
|
2023-12-18 13:59:20 +02:00
|
|
|
import { isFollowingVisibleForMe, isFollowersVisibleForMe } from '@/scripts/isFfVisibleForMe.js';
|
2023-03-03 05:29:34 +02:00
|
|
|
|
|
|
|
const props = defineProps<{
|
|
|
|
showing: boolean;
|
|
|
|
q: string;
|
|
|
|
source: HTMLElement;
|
|
|
|
}>();
|
|
|
|
|
|
|
|
const emit = defineEmits<{
|
|
|
|
(ev: 'closed'): void;
|
|
|
|
(ev: 'mouseover'): void;
|
|
|
|
(ev: 'mouseleave'): void;
|
|
|
|
}>();
|
|
|
|
|
|
|
|
const zIndex = os.claimZIndex('middle');
|
2023-12-07 07:42:09 +02:00
|
|
|
const user = ref<Misskey.entities.UserDetailed | null>(null);
|
|
|
|
const top = ref(0);
|
|
|
|
const left = ref(0);
|
2023-03-03 05:29:34 +02:00
|
|
|
|
|
|
|
function showMenu(ev: MouseEvent) {
|
2023-12-07 07:42:09 +02:00
|
|
|
const { menu, cleanup } = getUserMenu(user.value);
|
2023-08-01 09:32:03 +03:00
|
|
|
os.popupMenu(menu, ev.currentTarget ?? ev.target).finally(cleanup);
|
2023-03-03 05:29:34 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
onMounted(() => {
|
|
|
|
if (typeof props.q === 'object') {
|
2023-12-07 07:42:09 +02:00
|
|
|
user.value = props.q;
|
2023-03-03 05:29:34 +02:00
|
|
|
} else {
|
|
|
|
const query = props.q.startsWith('@') ?
|
2023-09-04 07:33:38 +03:00
|
|
|
Misskey.acct.parse(props.q.substring(1)) :
|
2023-03-03 05:29:34 +02:00
|
|
|
{ userId: props.q };
|
|
|
|
|
2024-01-04 11:32:46 +02:00
|
|
|
misskeyApi('users/show', query).then(res => {
|
2023-03-03 05:29:34 +02:00
|
|
|
if (!props.showing) return;
|
2023-12-07 07:42:09 +02:00
|
|
|
user.value = res;
|
2023-03-03 05:29:34 +02:00
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
const rect = props.source.getBoundingClientRect();
|
|
|
|
const x = ((rect.left + (props.source.offsetWidth / 2)) - (300 / 2)) + window.pageXOffset;
|
|
|
|
const y = rect.top + props.source.offsetHeight + window.pageYOffset;
|
|
|
|
|
2023-12-07 07:42:09 +02:00
|
|
|
top.value = y;
|
|
|
|
left.value = x;
|
2023-03-03 05:29:34 +02:00
|
|
|
});
|
|
|
|
</script>
|
|
|
|
|
|
|
|
<style lang="scss" module>
|
|
|
|
.transition_popup_enterActive,
|
|
|
|
.transition_popup_leaveActive {
|
|
|
|
transition: opacity 0.15s, transform 0.15s !important;
|
|
|
|
}
|
|
|
|
.transition_popup_enterFrom,
|
|
|
|
.transition_popup_leaveTo {
|
|
|
|
opacity: 0;
|
|
|
|
transform: scale(0.9);
|
|
|
|
}
|
|
|
|
|
|
|
|
.root {
|
|
|
|
position: absolute;
|
|
|
|
width: 300px;
|
|
|
|
overflow: clip;
|
|
|
|
transform-origin: center top;
|
|
|
|
}
|
|
|
|
|
|
|
|
.banner {
|
|
|
|
height: 78px;
|
|
|
|
background-color: rgba(0, 0, 0, 0.1);
|
|
|
|
background-size: cover;
|
|
|
|
background-position: center;
|
|
|
|
}
|
|
|
|
|
|
|
|
.followed {
|
|
|
|
position: absolute;
|
|
|
|
top: 12px;
|
|
|
|
left: 12px;
|
|
|
|
padding: 4px 8px;
|
|
|
|
color: #fff;
|
|
|
|
background: rgba(0, 0, 0, 0.7);
|
|
|
|
font-size: 0.7em;
|
|
|
|
border-radius: 6px;
|
|
|
|
}
|
|
|
|
|
|
|
|
.avatarBack {
|
|
|
|
width: 100px;
|
|
|
|
position: absolute;
|
|
|
|
top: 28px;
|
|
|
|
left: 0;
|
|
|
|
right: 0;
|
|
|
|
margin: 0 auto;
|
|
|
|
}
|
|
|
|
|
|
|
|
.avatar {
|
|
|
|
display: block;
|
|
|
|
position: absolute;
|
|
|
|
top: 38px;
|
|
|
|
left: 0;
|
|
|
|
right: 0;
|
|
|
|
margin: 0 auto;
|
|
|
|
z-index: 2;
|
|
|
|
width: 58px;
|
|
|
|
height: 58px;
|
|
|
|
}
|
|
|
|
|
|
|
|
.title {
|
|
|
|
position: relative;
|
|
|
|
z-index: 3;
|
|
|
|
display: block;
|
|
|
|
padding: 8px 26px 16px 26px;
|
|
|
|
margin-top: 16px;
|
|
|
|
text-align: center;
|
|
|
|
}
|
|
|
|
|
|
|
|
.name {
|
|
|
|
display: inline-block;
|
|
|
|
font-weight: bold;
|
|
|
|
word-break: break-all;
|
|
|
|
}
|
|
|
|
|
|
|
|
.username {
|
|
|
|
display: block;
|
|
|
|
font-size: 0.8em;
|
|
|
|
opacity: 0.7;
|
|
|
|
}
|
|
|
|
|
|
|
|
.description {
|
|
|
|
padding: 16px 26px;
|
|
|
|
font-size: 0.8em;
|
|
|
|
text-align: center;
|
|
|
|
border-top: solid 1px var(--divider);
|
|
|
|
border-bottom: solid 1px var(--divider);
|
|
|
|
}
|
|
|
|
|
2023-06-05 11:58:00 +03:00
|
|
|
.mfm {
|
|
|
|
display: -webkit-box;
|
|
|
|
-webkit-line-clamp: 5;
|
2023-07-08 01:08:16 +03:00
|
|
|
-webkit-box-orient: vertical;
|
2023-06-05 11:58:00 +03:00
|
|
|
overflow: hidden;
|
|
|
|
}
|
|
|
|
|
2023-03-03 05:29:34 +02:00
|
|
|
.status {
|
|
|
|
padding: 16px 26px 16px 26px;
|
|
|
|
}
|
|
|
|
|
|
|
|
.statusItem {
|
|
|
|
display: inline-block;
|
|
|
|
width: 33%;
|
|
|
|
text-align: center;
|
|
|
|
}
|
|
|
|
|
|
|
|
.statusItemLabel {
|
|
|
|
font-size: 0.7em;
|
|
|
|
color: var(--fgTransparentWeak);
|
|
|
|
}
|
|
|
|
|
|
|
|
.menu {
|
|
|
|
position: absolute;
|
|
|
|
top: 8px;
|
|
|
|
right: 44px;
|
|
|
|
padding: 6px;
|
|
|
|
background: var(--panel);
|
|
|
|
border-radius: 999px;
|
|
|
|
}
|
|
|
|
|
|
|
|
.follow {
|
2023-03-03 07:55:56 +02:00
|
|
|
position: absolute !important;
|
2023-03-03 05:29:34 +02:00
|
|
|
top: 8px;
|
|
|
|
right: 8px;
|
|
|
|
}
|
|
|
|
</style>
|