2023-07-07 19:22:30 +00:00
|
|
|
<template>
|
2023-07-23 13:31:28 +00:00
|
|
|
<transition
|
|
|
|
:name="$store.state.animation ? 'popup' : ''"
|
|
|
|
appear
|
|
|
|
@after-leave="emit('closed')"
|
|
|
|
>
|
|
|
|
<div
|
|
|
|
v-if="showing"
|
|
|
|
class="fxxzrfni _popup _shadow"
|
|
|
|
:style="{ zIndex, top: top + 'px', left: left + 'px' }"
|
|
|
|
@mouseover="
|
|
|
|
() => {
|
|
|
|
emit('mouseover');
|
|
|
|
}
|
|
|
|
"
|
|
|
|
@mouseleave="
|
|
|
|
() => {
|
|
|
|
emit('mouseleave');
|
|
|
|
}
|
|
|
|
"
|
|
|
|
>
|
2023-11-09 20:35:55 +00:00
|
|
|
<div v-if="user" class="info">
|
2023-07-23 13:31:28 +00:00
|
|
|
<div
|
|
|
|
class="banner"
|
|
|
|
:style="
|
2023-11-09 20:35:55 +00:00
|
|
|
user.banner_url
|
|
|
|
? `background-image: url(${user.banner_url})`
|
2023-07-23 13:31:28 +00:00
|
|
|
: ''
|
|
|
|
"
|
|
|
|
>
|
|
|
|
<span
|
2023-11-09 20:35:55 +00:00
|
|
|
v-if="$i && $i.id != user.id && user.follows_you"
|
2023-07-23 13:31:28 +00:00
|
|
|
class="followed"
|
|
|
|
>{{ i18n.ts.followsYou }}</span
|
|
|
|
>
|
2023-09-08 01:33:49 +00:00
|
|
|
<span
|
|
|
|
v-if="
|
2023-11-09 20:35:55 +00:00
|
|
|
$i && $i.id != user.id && user.they_request_follow
|
2023-09-08 01:33:49 +00:00
|
|
|
"
|
|
|
|
class="followed"
|
|
|
|
>
|
|
|
|
{{ i18n.ts.followRequestYou }}
|
|
|
|
</span>
|
2023-07-23 13:31:28 +00:00
|
|
|
</div>
|
|
|
|
<MkAvatar
|
|
|
|
class="avatar"
|
|
|
|
:user="user"
|
|
|
|
:disable-preview="true"
|
|
|
|
:show-indicator="true"
|
|
|
|
/>
|
|
|
|
<div class="title">
|
|
|
|
<MkA class="name" :to="userPage(user)"
|
|
|
|
><MkUserName :user="user" :nowrap="true"
|
|
|
|
/></MkA>
|
|
|
|
<p class="username"><MkAcct :user="user" /></p>
|
|
|
|
</div>
|
|
|
|
<div
|
|
|
|
class="description"
|
|
|
|
:class="{ collapsed: isLong && collapsed }"
|
|
|
|
>
|
|
|
|
<Mfm
|
|
|
|
v-if="user.description"
|
2023-12-24 22:46:36 +00:00
|
|
|
:mm="user.description_mm"
|
2023-07-23 13:31:28 +00:00
|
|
|
:text="user.description"
|
|
|
|
:author="user"
|
|
|
|
:i="$i"
|
|
|
|
:custom-emojis="user.emojis"
|
|
|
|
/>
|
|
|
|
</div>
|
|
|
|
<XShowMoreButton
|
|
|
|
v-if="isLong"
|
|
|
|
v-model="collapsed"
|
|
|
|
></XShowMoreButton>
|
|
|
|
<div v-if="user.fields.length > 0" class="fields">
|
|
|
|
<dl
|
|
|
|
v-for="(field, i) in user.fields"
|
|
|
|
:key="i"
|
|
|
|
class="field"
|
|
|
|
>
|
|
|
|
<dt class="name">
|
|
|
|
<Mfm
|
|
|
|
:text="field.name"
|
|
|
|
:plain="true"
|
|
|
|
:custom-emojis="user.emojis"
|
|
|
|
:colored="false"
|
|
|
|
/>
|
|
|
|
</dt>
|
|
|
|
<dd class="value">
|
|
|
|
<Mfm
|
2023-12-24 22:46:36 +00:00
|
|
|
:mm="field.value_mm"
|
2023-07-23 13:31:28 +00:00
|
|
|
:text="field.value"
|
|
|
|
:author="user"
|
|
|
|
:i="$i"
|
|
|
|
:custom-emojis="user.emojis"
|
|
|
|
:colored="false"
|
|
|
|
/>
|
|
|
|
</dd>
|
|
|
|
</dl>
|
|
|
|
</div>
|
|
|
|
<div class="status">
|
|
|
|
<div>
|
|
|
|
<p>{{ i18n.ts.notes }}</p>
|
2023-11-09 20:35:55 +00:00
|
|
|
<span>{{ user.note_count }}</span>
|
2023-07-23 13:31:28 +00:00
|
|
|
</div>
|
|
|
|
<div>
|
|
|
|
<p>{{ i18n.ts.following }}</p>
|
2023-11-09 20:35:55 +00:00
|
|
|
<span>{{ user.following_count }}</span>
|
2023-07-23 13:31:28 +00:00
|
|
|
</div>
|
|
|
|
<div>
|
|
|
|
<p>{{ i18n.ts.followers }}</p>
|
2023-11-09 20:35:55 +00:00
|
|
|
<span>{{ user.follower_count }}</span>
|
2023-07-23 13:31:28 +00:00
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
<div class="follow-button-container">
|
|
|
|
<MkFollowButton
|
|
|
|
v-if="$i && user.id != $i.id"
|
|
|
|
:user="user"
|
|
|
|
mini
|
|
|
|
/>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
<div v-else>
|
|
|
|
<MkLoading />
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</transition>
|
2023-07-07 19:22:30 +00:00
|
|
|
</template>
|
|
|
|
|
|
|
|
<script lang="ts" setup>
|
2023-11-09 20:35:55 +00:00
|
|
|
import { computed, onMounted } from "vue";
|
2023-07-07 19:22:30 +00:00
|
|
|
import MkFollowButton from "@/components/MkFollowButton.vue";
|
|
|
|
import { userPage } from "@/filters/user";
|
|
|
|
import XShowMoreButton from "@/components/MkShowMoreButton.vue";
|
|
|
|
import * as os from "@/os";
|
|
|
|
import { $i } from "@/account";
|
|
|
|
import { i18n } from "@/i18n";
|
2023-11-19 14:13:34 +00:00
|
|
|
import { endpoints, packed } from "magnetar-common";
|
2023-11-09 20:35:55 +00:00
|
|
|
import { host as localHost } from "@/config";
|
|
|
|
import { toUnicode } from "punycode";
|
2023-07-07 19:22:30 +00:00
|
|
|
|
|
|
|
const props = defineProps<{
|
2023-07-23 13:31:28 +00:00
|
|
|
showing: boolean;
|
2023-11-09 20:35:55 +00:00
|
|
|
userTag: string | { username: string; host?: string };
|
2023-07-23 13:31:28 +00:00
|
|
|
source: HTMLElement;
|
2023-07-07 19:22:30 +00:00
|
|
|
}>();
|
|
|
|
|
|
|
|
const emit = defineEmits<{
|
2023-07-23 13:31:28 +00:00
|
|
|
(ev: "closed"): void;
|
|
|
|
(ev: "mouseover"): void;
|
|
|
|
(ev: "mouseleave"): void;
|
2023-07-07 19:22:30 +00:00
|
|
|
}>();
|
|
|
|
|
|
|
|
const zIndex = os.claimZIndex("middle");
|
2023-11-09 20:35:55 +00:00
|
|
|
let user = $ref<packed.PackUserMaybeAll | null>(null);
|
2023-07-07 19:22:30 +00:00
|
|
|
let top = $ref(0);
|
|
|
|
let left = $ref(0);
|
|
|
|
|
2023-11-09 20:35:55 +00:00
|
|
|
let isLong = computed(() => {
|
|
|
|
if (!user?.description) return;
|
|
|
|
|
|
|
|
return (
|
|
|
|
user.description.split("\n").length > 9 || user.description.length > 400
|
|
|
|
);
|
|
|
|
});
|
2023-07-07 19:22:30 +00:00
|
|
|
let collapsed = $ref(!isLong);
|
|
|
|
|
|
|
|
onMounted(() => {
|
2023-11-09 20:35:55 +00:00
|
|
|
const options = { detail: true, profile: true, relation: true };
|
|
|
|
|
|
|
|
if (typeof props.userTag === "object") {
|
|
|
|
const canonical =
|
|
|
|
!props.userTag.host || props.userTag.host === localHost
|
|
|
|
? `${props.userTag.username}`
|
|
|
|
: `${props.userTag.username}@${toUnicode(props.userTag.host)}`;
|
2023-07-07 19:22:30 +00:00
|
|
|
|
2023-11-09 20:35:55 +00:00
|
|
|
os.magApi(endpoints.GetUserByAcct, options, {
|
|
|
|
user_acct: canonical,
|
|
|
|
}).then((u) => {
|
|
|
|
user = u;
|
2023-07-23 13:31:28 +00:00
|
|
|
});
|
2023-11-09 20:35:55 +00:00
|
|
|
} else {
|
|
|
|
const acctQuery = props.userTag.startsWith("@");
|
|
|
|
|
|
|
|
const apiCall = acctQuery
|
|
|
|
? os.magApi(endpoints.GetUserByAcct, options, {
|
|
|
|
user_acct: props.userTag,
|
|
|
|
})
|
|
|
|
: os.magApi(endpoints.GetUserById, options, {
|
|
|
|
user_id: props.userTag,
|
|
|
|
});
|
|
|
|
|
|
|
|
apiCall.then((u) => (user = u));
|
2023-07-23 13:31:28 +00:00
|
|
|
}
|
2023-07-07 19:22:30 +00:00
|
|
|
|
2023-07-23 13:31:28 +00:00
|
|
|
const rect = props.source.getBoundingClientRect();
|
2023-11-09 20:35:55 +00:00
|
|
|
left = rect.left + props.source.offsetWidth / 2 - 300 / 2 + window.scrollX;
|
|
|
|
top = rect.top + props.source.offsetHeight + window.scrollY;
|
2023-07-07 19:22:30 +00:00
|
|
|
});
|
|
|
|
</script>
|
|
|
|
|
|
|
|
<style lang="scss" scoped>
|
|
|
|
.popup-enter-active,
|
|
|
|
.popup-leave-active {
|
2023-07-23 13:31:28 +00:00
|
|
|
transition: opacity 0.3s, transform 0.3s !important;
|
2023-07-07 19:22:30 +00:00
|
|
|
}
|
|
|
|
.popup-enter-from,
|
|
|
|
.popup-leave-to {
|
2023-07-23 13:31:28 +00:00
|
|
|
opacity: 0;
|
|
|
|
transform: scale(0.9);
|
2023-07-07 19:22:30 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
.fxxzrfni {
|
2023-07-23 13:31:28 +00:00
|
|
|
position: absolute;
|
|
|
|
width: 300px;
|
|
|
|
overflow: hidden;
|
|
|
|
transform-origin: center top;
|
2023-07-07 19:22:30 +00:00
|
|
|
|
2023-07-23 13:31:28 +00:00
|
|
|
> .info {
|
|
|
|
> .banner {
|
|
|
|
height: 84px;
|
|
|
|
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;
|
|
|
|
}
|
2023-07-07 19:22:30 +00:00
|
|
|
|
2023-07-23 13:31:28 +00:00
|
|
|
&::before {
|
|
|
|
content: "";
|
|
|
|
position: absolute;
|
|
|
|
inset: 0;
|
|
|
|
z-index: 2;
|
|
|
|
height: 84px;
|
|
|
|
background: linear-gradient(
|
|
|
|
-125deg,
|
|
|
|
rgba(0, 0, 0, 0.7),
|
|
|
|
transparent,
|
|
|
|
transparent
|
|
|
|
);
|
|
|
|
}
|
2023-07-07 19:22:30 +00:00
|
|
|
|
2023-07-23 13:31:28 +00:00
|
|
|
&::after {
|
|
|
|
content: "";
|
|
|
|
background-image: var(--blur, inherit);
|
|
|
|
position: fixed;
|
|
|
|
inset: 0;
|
|
|
|
background-size: cover;
|
|
|
|
background-position: center;
|
|
|
|
pointer-events: none;
|
|
|
|
opacity: 0.1;
|
|
|
|
filter: var(--blur, blur(10px));
|
|
|
|
}
|
|
|
|
}
|
2023-07-07 19:22:30 +00:00
|
|
|
|
2023-07-23 13:31:28 +00:00
|
|
|
> .avatar {
|
|
|
|
display: block;
|
|
|
|
position: absolute;
|
|
|
|
top: 70px;
|
|
|
|
left: 13px;
|
|
|
|
z-index: 2;
|
|
|
|
width: 58px;
|
|
|
|
height: 58px;
|
|
|
|
border: solid 3px var(--face);
|
|
|
|
border-radius: 8px;
|
|
|
|
}
|
2023-07-07 19:22:30 +00:00
|
|
|
|
2023-07-23 13:31:28 +00:00
|
|
|
> .title {
|
|
|
|
display: block;
|
|
|
|
padding: 8px 0 8px 82px;
|
2023-07-07 19:22:30 +00:00
|
|
|
|
2023-07-23 13:31:28 +00:00
|
|
|
> .name {
|
|
|
|
display: inline-block;
|
|
|
|
margin: 0;
|
|
|
|
font-weight: bold;
|
|
|
|
line-height: 16px;
|
|
|
|
word-break: break-all;
|
|
|
|
}
|
2023-07-07 19:22:30 +00:00
|
|
|
|
2023-07-23 13:31:28 +00:00
|
|
|
> .username {
|
|
|
|
display: block;
|
|
|
|
margin: 0;
|
|
|
|
line-height: 16px;
|
|
|
|
font-size: 0.8em;
|
|
|
|
color: var(--fg);
|
|
|
|
opacity: 0.7;
|
|
|
|
}
|
|
|
|
}
|
2023-07-07 19:22:30 +00:00
|
|
|
|
2023-07-23 13:31:28 +00:00
|
|
|
> .description {
|
|
|
|
padding: 0 16px;
|
|
|
|
font-size: 0.8em;
|
|
|
|
color: var(--fg);
|
|
|
|
&.collapsed {
|
|
|
|
position: relative;
|
|
|
|
max-height: calc(9em + 50px);
|
|
|
|
mask: linear-gradient(black calc(100% - 64px), transparent);
|
|
|
|
-webkit-mask: linear-gradient(
|
|
|
|
black calc(100% - 64px),
|
|
|
|
transparent
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
:deep(.fade) {
|
|
|
|
position: relative;
|
|
|
|
display: block;
|
|
|
|
width: 100%;
|
|
|
|
margin-top: -2.5em;
|
|
|
|
z-index: 2;
|
|
|
|
> span {
|
|
|
|
display: inline-block;
|
|
|
|
background: var(--panel);
|
|
|
|
padding: 0.4em 1em;
|
|
|
|
font-size: 0.8em;
|
|
|
|
border-radius: 999px;
|
|
|
|
box-shadow: 0 2px 6px rgb(0 0 0 / 20%);
|
|
|
|
}
|
|
|
|
&:hover {
|
|
|
|
> span {
|
|
|
|
background: var(--panelHighlight);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
:deep(.showLess) {
|
|
|
|
width: 100%;
|
|
|
|
margin-top: 1em;
|
|
|
|
position: sticky;
|
|
|
|
bottom: var(--stickyBottom);
|
2023-07-07 19:22:30 +00:00
|
|
|
|
2023-07-23 13:31:28 +00:00
|
|
|
> span {
|
|
|
|
display: inline-block;
|
|
|
|
background: var(--panel);
|
|
|
|
padding: 6px 10px;
|
|
|
|
font-size: 0.8em;
|
|
|
|
border-radius: 999px;
|
|
|
|
box-shadow: 0 0 7px 7px var(--bg);
|
|
|
|
}
|
|
|
|
}
|
2023-07-07 19:22:30 +00:00
|
|
|
|
2023-07-23 13:31:28 +00:00
|
|
|
> .fields {
|
|
|
|
padding: 0 16px;
|
|
|
|
font-size: 0.8em;
|
|
|
|
margin-top: 1em;
|
2023-07-07 19:22:30 +00:00
|
|
|
|
2023-07-23 13:31:28 +00:00
|
|
|
> .field {
|
|
|
|
display: flex;
|
|
|
|
padding: 0;
|
|
|
|
margin: 0;
|
|
|
|
align-items: center;
|
2023-07-07 19:22:30 +00:00
|
|
|
|
2023-07-23 13:31:28 +00:00
|
|
|
&:not(:last-child) {
|
|
|
|
margin-bottom: 8px;
|
|
|
|
}
|
2023-07-07 19:22:30 +00:00
|
|
|
|
2023-07-23 13:31:28 +00:00
|
|
|
:deep(span) {
|
|
|
|
white-space: nowrap !important;
|
|
|
|
}
|
2023-07-07 19:22:30 +00:00
|
|
|
|
2023-07-23 13:31:28 +00:00
|
|
|
> .name {
|
|
|
|
width: 30%;
|
|
|
|
overflow: hidden;
|
|
|
|
white-space: nowrap;
|
|
|
|
text-overflow: ellipsis;
|
|
|
|
font-weight: bold;
|
|
|
|
text-align: center;
|
|
|
|
}
|
2023-07-07 19:22:30 +00:00
|
|
|
|
2023-07-23 13:31:28 +00:00
|
|
|
> .value {
|
|
|
|
width: 70%;
|
|
|
|
overflow: hidden;
|
|
|
|
white-space: nowrap;
|
|
|
|
text-overflow: ellipsis;
|
|
|
|
margin: 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2023-07-07 19:22:30 +00:00
|
|
|
|
2023-07-23 13:31:28 +00:00
|
|
|
> .status {
|
|
|
|
padding: 8px 16px;
|
2023-07-07 19:22:30 +00:00
|
|
|
|
2023-07-23 13:31:28 +00:00
|
|
|
> div {
|
|
|
|
display: inline-block;
|
|
|
|
width: 33%;
|
2023-07-07 19:22:30 +00:00
|
|
|
|
2023-07-23 13:31:28 +00:00
|
|
|
> p {
|
|
|
|
margin: 0;
|
|
|
|
font-size: 0.7em;
|
|
|
|
color: var(--fg);
|
|
|
|
}
|
2023-07-07 19:22:30 +00:00
|
|
|
|
2023-07-23 13:31:28 +00:00
|
|
|
> span {
|
|
|
|
font-size: 1em;
|
|
|
|
color: var(--accent);
|
|
|
|
:deep(span) {
|
|
|
|
white-space: nowrap;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2023-07-07 19:22:30 +00:00
|
|
|
|
2023-07-23 13:31:28 +00:00
|
|
|
> .follow-button-container {
|
|
|
|
position: absolute;
|
|
|
|
top: 8px;
|
|
|
|
right: 8px;
|
|
|
|
z-index: 3;
|
|
|
|
color: white;
|
|
|
|
}
|
|
|
|
}
|
2023-07-07 19:22:30 +00:00
|
|
|
}
|
|
|
|
</style>
|