2020-01-29 20:37:25 +01:00
|
|
|
<template>
|
2023-04-08 02:01:42 +02: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-07-14 01:27:00 +02:00
|
|
|
<MkUserInfo v-if="user != null" :user="user" :detailed="true" />
|
2023-04-08 02:01:42 +02:00
|
|
|
<div v-else>
|
|
|
|
<MkLoading />
|
2020-01-29 20:37:25 +01:00
|
|
|
</div>
|
|
|
|
</div>
|
2023-04-08 02:01:42 +02:00
|
|
|
</transition>
|
2020-01-29 20:37:25 +01:00
|
|
|
</template>
|
|
|
|
|
2022-09-05 11:24:46 +02:00
|
|
|
<script lang="ts" setup>
|
2023-04-08 02:01:42 +02:00
|
|
|
import { onMounted } from "vue";
|
2023-07-14 01:27:00 +02:00
|
|
|
import MkUserInfo from "@/components/MkUserInfo.vue";
|
2023-07-15 23:21:17 +02:00
|
|
|
import * as Acct from "firefish-js/built/acct";
|
|
|
|
import type * as misskey from "firefish-js";
|
2023-04-08 02:01:42 +02:00
|
|
|
import * as os from "@/os";
|
2020-01-29 20:37:25 +01:00
|
|
|
|
2022-09-05 11:24:46 +02:00
|
|
|
const props = defineProps<{
|
|
|
|
showing: boolean;
|
|
|
|
q: string;
|
|
|
|
source: HTMLElement;
|
|
|
|
}>();
|
2020-01-29 20:37:25 +01:00
|
|
|
|
2022-09-05 11:24:46 +02:00
|
|
|
const emit = defineEmits<{
|
2023-04-08 02:01:42 +02:00
|
|
|
(ev: "closed"): void;
|
|
|
|
(ev: "mouseover"): void;
|
|
|
|
(ev: "mouseleave"): void;
|
2022-09-05 11:24:46 +02:00
|
|
|
}>();
|
2020-01-29 20:37:25 +01:00
|
|
|
|
2023-04-08 02:01:42 +02:00
|
|
|
const zIndex = os.claimZIndex("middle");
|
2022-09-05 11:24:46 +02:00
|
|
|
let user = $ref<misskey.entities.UserDetailed | null>(null);
|
|
|
|
let top = $ref(0);
|
|
|
|
let left = $ref(0);
|
2020-10-17 13:12:00 +02:00
|
|
|
|
2022-09-05 11:24:46 +02:00
|
|
|
onMounted(() => {
|
2023-04-08 02:01:42 +02:00
|
|
|
if (typeof props.q === "object") {
|
2022-09-05 11:24:46 +02:00
|
|
|
user = props.q;
|
|
|
|
} else {
|
2023-04-08 02:01:42 +02:00
|
|
|
const query = props.q.startsWith("@")
|
2023-07-13 08:56:22 +02:00
|
|
|
? Acct.parse(props.q.slice(1))
|
2023-04-08 02:01:42 +02:00
|
|
|
: { userId: props.q };
|
2020-01-29 20:37:25 +01:00
|
|
|
|
2023-04-08 02:01:42 +02:00
|
|
|
os.api("users/show", query).then((res) => {
|
2022-09-05 11:24:46 +02:00
|
|
|
if (!props.showing) return;
|
|
|
|
user = res;
|
|
|
|
});
|
|
|
|
}
|
2020-10-17 13:12:00 +02:00
|
|
|
|
2022-09-05 11:24:46 +02:00
|
|
|
const rect = props.source.getBoundingClientRect();
|
2023-04-08 02:01:42 +02:00
|
|
|
const x =
|
|
|
|
rect.left + props.source.offsetWidth / 2 - 300 / 2 + window.pageXOffset;
|
2022-09-05 11:24:46 +02:00
|
|
|
const y = rect.top + props.source.offsetHeight + window.pageYOffset;
|
2020-01-29 20:37:25 +01:00
|
|
|
|
2022-09-05 11:24:46 +02:00
|
|
|
top = y;
|
|
|
|
left = x;
|
2020-01-29 20:37:25 +01:00
|
|
|
});
|
|
|
|
</script>
|
|
|
|
|
|
|
|
<style lang="scss" scoped>
|
2023-04-08 02:01:42 +02:00
|
|
|
.popup-enter-active,
|
|
|
|
.popup-leave-active {
|
2023-07-06 03:28:27 +02:00
|
|
|
transition:
|
|
|
|
opacity 0.3s,
|
|
|
|
transform 0.3s !important;
|
2020-01-29 20:37:25 +01:00
|
|
|
}
|
2023-04-08 02:01:42 +02:00
|
|
|
.popup-enter-from,
|
|
|
|
.popup-leave-to {
|
2020-01-29 20:37:25 +01:00
|
|
|
opacity: 0;
|
|
|
|
transform: scale(0.9);
|
|
|
|
}
|
|
|
|
|
|
|
|
.fxxzrfni {
|
|
|
|
position: absolute;
|
|
|
|
width: 300px;
|
2021-03-02 14:57:16 +01:00
|
|
|
overflow: hidden;
|
2020-10-17 13:12:00 +02:00
|
|
|
transform-origin: center top;
|
2020-01-29 20:37:25 +01:00
|
|
|
}
|
|
|
|
</style>
|