2018-12-12 13:06:05 +09:00
|
|
|
<template>
|
2023-01-14 20:31:48 +09:00
|
|
|
<MkA v-user-preview="canonical" :class="[$style.root, { [$style.isMe]: isMe }]" :to="url" :style="{ background: bgCss }">
|
|
|
|
<img :class="$style.icon" :src="`/avatar/@${username}@${host}`" alt="">
|
|
|
|
<span>
|
2023-06-01 17:19:46 +09:00
|
|
|
<span>@{{ username }}</span>
|
2023-04-01 13:42:40 +09:00
|
|
|
<span v-if="(host != localHost) || defaultStore.state.showFullAcct" :class="$style.host">@{{ toUnicode(host) }}</span>
|
2018-12-12 13:06:05 +09:00
|
|
|
</span>
|
2020-10-25 01:21:41 +09:00
|
|
|
</MkA>
|
2018-12-12 13:06:05 +09:00
|
|
|
</template>
|
|
|
|
|
2022-06-24 10:34:36 +09:00
|
|
|
<script lang="ts" setup>
|
2021-10-31 20:19:49 +09:00
|
|
|
import { toUnicode } from 'punycode';
|
2022-07-14 23:32:00 +09:00
|
|
|
import { } from 'vue';
|
2022-06-24 10:34:36 +09:00
|
|
|
import tinycolor from 'tinycolor2';
|
2021-11-12 02:02:25 +09:00
|
|
|
import { host as localHost } from '@/config';
|
|
|
|
import { $i } from '@/account';
|
2023-04-01 13:42:40 +09:00
|
|
|
import { defaultStore } from '@/store';
|
2018-12-12 13:06:05 +09:00
|
|
|
|
2022-06-24 10:34:36 +09:00
|
|
|
const props = defineProps<{
|
|
|
|
username: string;
|
|
|
|
host: string;
|
|
|
|
}>();
|
2021-10-31 20:19:49 +09:00
|
|
|
|
2022-06-24 10:34:36 +09:00
|
|
|
const canonical = props.host === localHost ? `@${props.username}` : `@${props.username}@${toUnicode(props.host)}`;
|
2021-10-31 20:19:49 +09:00
|
|
|
|
2022-06-24 10:34:36 +09:00
|
|
|
const url = `/${canonical}`;
|
2021-10-31 20:19:49 +09:00
|
|
|
|
2022-06-24 10:34:36 +09:00
|
|
|
const isMe = $i && (
|
|
|
|
`@${props.username}@${toUnicode(props.host)}` === `@${$i.username}@${toUnicode(localHost)}`.toLowerCase()
|
|
|
|
);
|
2021-10-31 20:19:49 +09:00
|
|
|
|
2022-06-24 10:34:36 +09:00
|
|
|
const bg = tinycolor(getComputedStyle(document.documentElement).getPropertyValue(isMe ? '--mentionMe' : '--mention'));
|
|
|
|
bg.setAlpha(0.1);
|
|
|
|
const bgCss = bg.toRgbString();
|
2018-12-12 13:06:05 +09:00
|
|
|
</script>
|
|
|
|
|
2023-01-14 20:31:48 +09:00
|
|
|
<style lang="scss" module>
|
|
|
|
.root {
|
2021-10-31 20:19:49 +09:00
|
|
|
display: inline-block;
|
|
|
|
padding: 4px 8px 4px 4px;
|
|
|
|
border-radius: 999px;
|
2020-01-30 04:37:25 +09:00
|
|
|
color: var(--mention);
|
2020-06-04 22:19:08 +09:00
|
|
|
|
|
|
|
&.isMe {
|
|
|
|
color: var(--mentionMe);
|
|
|
|
}
|
2023-01-14 20:31:48 +09:00
|
|
|
}
|
2018-12-12 13:06:05 +09:00
|
|
|
|
2023-01-14 20:31:48 +09:00
|
|
|
.icon {
|
|
|
|
width: 1.5em;
|
|
|
|
height: 1.5em;
|
|
|
|
object-fit: cover;
|
|
|
|
margin: 0 0.2em 0 0;
|
|
|
|
vertical-align: bottom;
|
|
|
|
border-radius: 100%;
|
|
|
|
}
|
2021-10-24 21:02:50 +09:00
|
|
|
|
2023-01-14 20:31:48 +09:00
|
|
|
.host {
|
|
|
|
opacity: 0.5;
|
2020-01-30 04:37:25 +09:00
|
|
|
}
|
2018-12-12 13:06:05 +09:00
|
|
|
</style>
|