2018-12-11 21:06:05 -07:00
|
|
|
<template>
|
2022-07-09 22:16:11 -06:00
|
|
|
<MkA v-if="url.startsWith('/')" v-user-preview="canonical" class="akbvjaqn" :class="{ isMe }" :to="url" :style="{ background: bgCss }">
|
|
|
|
<img class="icon" :src="`/avatar/@${username}@${host}`" alt="">
|
2018-12-11 21:06:05 -07:00
|
|
|
<span class="main">
|
|
|
|
<span class="username">@{{ username }}</span>
|
2022-07-09 22:16:11 -06:00
|
|
|
<span v-if="(host != localHost) || $store.state.showFullAcct" class="host">@{{ toUnicode(host) }}</span>
|
2018-12-11 21:06:05 -07:00
|
|
|
</span>
|
2020-10-24 10:21:41 -06:00
|
|
|
</MkA>
|
2022-07-09 22:16:11 -06:00
|
|
|
<a v-else class="akbvjaqn" :href="url" target="_blank" rel="noopener" :style="{ background: bgCss }">
|
2019-07-18 12:13:47 -06:00
|
|
|
<span class="main">
|
|
|
|
<span class="username">@{{ username }}</span>
|
2022-07-09 22:16:11 -06:00
|
|
|
<span class="host">@{{ toUnicode(host) }}</span>
|
2019-07-18 12:13:47 -06:00
|
|
|
</span>
|
|
|
|
</a>
|
2018-12-11 21:06:05 -07:00
|
|
|
</template>
|
|
|
|
|
2022-06-23 19:34:36 -06:00
|
|
|
<script lang="ts" setup>
|
2021-10-31 05:19:49 -06:00
|
|
|
import { toUnicode } from 'punycode';
|
2022-06-23 19:34:36 -06:00
|
|
|
import { useCssModule } from 'vue';
|
|
|
|
import tinycolor from 'tinycolor2';
|
2021-11-11 10:02:25 -07:00
|
|
|
import { host as localHost } from '@/config';
|
|
|
|
import { $i } from '@/account';
|
2018-12-11 21:06:05 -07:00
|
|
|
|
2022-06-23 19:34:36 -06:00
|
|
|
const props = defineProps<{
|
|
|
|
username: string;
|
|
|
|
host: string;
|
|
|
|
}>();
|
2021-10-31 05:19:49 -06:00
|
|
|
|
2022-06-23 19:34:36 -06:00
|
|
|
const canonical = props.host === localHost ? `@${props.username}` : `@${props.username}@${toUnicode(props.host)}`;
|
2021-10-31 05:19:49 -06:00
|
|
|
|
2022-06-23 19:34:36 -06:00
|
|
|
const url = `/${canonical}`;
|
2021-10-31 05:19:49 -06:00
|
|
|
|
2022-06-23 19:34:36 -06:00
|
|
|
const isMe = $i && (
|
|
|
|
`@${props.username}@${toUnicode(props.host)}` === `@${$i.username}@${toUnicode(localHost)}`.toLowerCase()
|
|
|
|
);
|
2021-10-31 05:19:49 -06:00
|
|
|
|
2022-06-23 19:34:36 -06:00
|
|
|
const bg = tinycolor(getComputedStyle(document.documentElement).getPropertyValue(isMe ? '--mentionMe' : '--mention'));
|
|
|
|
bg.setAlpha(0.1);
|
|
|
|
const bgCss = bg.toRgbString();
|
2022-05-05 05:46:46 -06:00
|
|
|
|
2022-06-23 19:34:36 -06:00
|
|
|
useCssModule();
|
2018-12-11 21:06:05 -07:00
|
|
|
</script>
|
|
|
|
|
2022-07-09 22:16:11 -06:00
|
|
|
<style lang="scss" scoped>
|
|
|
|
.akbvjaqn {
|
2021-10-31 05:19:49 -06:00
|
|
|
display: inline-block;
|
|
|
|
padding: 4px 8px 4px 4px;
|
|
|
|
border-radius: 999px;
|
2020-01-29 12:37:25 -07:00
|
|
|
color: var(--mention);
|
2020-06-04 07:19:08 -06:00
|
|
|
|
|
|
|
&.isMe {
|
|
|
|
color: var(--mentionMe);
|
|
|
|
}
|
2018-12-11 21:06:05 -07:00
|
|
|
|
2022-07-09 22:16:11 -06: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 06:02:50 -06:00
|
|
|
|
2022-07-09 22:16:11 -06:00
|
|
|
> .host {
|
|
|
|
opacity: 0.5;
|
|
|
|
}
|
2020-01-29 12:37:25 -07:00
|
|
|
}
|
2022-07-09 22:16:11 -06:00
|
|
|
|
2018-12-11 21:06:05 -07:00
|
|
|
</style>
|