2018-12-12 05:06:05 +01:00
|
|
|
<template>
|
2021-10-31 12:19:49 +01:00
|
|
|
<MkA v-if="url.startsWith('/')" class="ldlomzub" :class="{ isMe }" :to="url" v-user-preview="canonical" :style="{ background: bg }">
|
2021-10-24 14:02:50 +02:00
|
|
|
<img class="icon" :src="`/avatar/@${username}@${host}`" alt="">
|
2018-12-12 05:06:05 +01:00
|
|
|
<span class="main">
|
|
|
|
<span class="username">@{{ username }}</span>
|
2020-12-19 02:55:52 +01:00
|
|
|
<span class="host" v-if="(host != localHost) || $store.state.showFullAcct">@{{ toUnicode(host) }}</span>
|
2018-12-12 05:06:05 +01:00
|
|
|
</span>
|
2020-10-24 18:21:41 +02:00
|
|
|
</MkA>
|
2021-10-31 12:19:49 +01:00
|
|
|
<a v-else class="ldlomzub" :href="url" target="_blank" rel="noopener" :style="{ background: bg }">
|
2019-07-18 20:13:47 +02:00
|
|
|
<span class="main">
|
|
|
|
<span class="username">@{{ username }}</span>
|
2020-01-29 20:37:25 +01:00
|
|
|
<span class="host">@{{ toUnicode(host) }}</span>
|
2019-07-18 20:13:47 +02:00
|
|
|
</span>
|
|
|
|
</a>
|
2018-12-12 05:06:05 +01:00
|
|
|
</template>
|
|
|
|
|
|
|
|
<script lang="ts">
|
2020-10-17 13:12:00 +02:00
|
|
|
import { defineComponent } from 'vue';
|
2021-10-31 12:19:49 +01:00
|
|
|
import * as tinycolor from 'tinycolor2';
|
|
|
|
import { toUnicode } from 'punycode';
|
2021-03-23 09:30:14 +01:00
|
|
|
import { host as localHost } from '@client/config';
|
2020-08-07 04:27:37 +02:00
|
|
|
import { wellKnownServices } from '../../well-known-services';
|
2021-10-31 12:19:49 +01:00
|
|
|
import { $i } from '@client/account';
|
2018-12-12 05:06:05 +01:00
|
|
|
|
2020-10-17 13:12:00 +02:00
|
|
|
export default defineComponent({
|
2018-12-12 05:06:05 +01:00
|
|
|
props: {
|
|
|
|
username: {
|
|
|
|
type: String,
|
|
|
|
required: true
|
|
|
|
},
|
|
|
|
host: {
|
|
|
|
type: String,
|
|
|
|
required: true
|
|
|
|
}
|
|
|
|
},
|
2021-10-31 12:19:49 +01:00
|
|
|
|
|
|
|
setup(props) {
|
|
|
|
const canonical = props.host === localHost ? `@${props.username}` : `@${props.username}@${toUnicode(props.host)}`;
|
|
|
|
|
|
|
|
const wellKnown = wellKnownServices.find(x => x[0] === props.host);
|
|
|
|
const url = wellKnown ? wellKnown[1](props.username) : `/${canonical}`;
|
|
|
|
|
|
|
|
const isMe = $i && (
|
|
|
|
`@${props.username}@${toUnicode(props.host)}` === `@${$i.username}@${toUnicode(localHost)}`.toLowerCase()
|
|
|
|
);
|
|
|
|
|
|
|
|
const bg = tinycolor(getComputedStyle(document.documentElement).getPropertyValue(isMe ? '--mentionMe' : '--mention'));
|
2021-11-05 08:18:59 +01:00
|
|
|
bg.setAlpha(0.1);
|
2021-10-31 12:19:49 +01:00
|
|
|
|
2018-12-12 05:06:05 +01:00
|
|
|
return {
|
2021-10-31 12:19:49 +01:00
|
|
|
localHost,
|
|
|
|
isMe,
|
|
|
|
url,
|
|
|
|
canonical,
|
|
|
|
toUnicode,
|
|
|
|
bg: bg.toRgbString(),
|
2018-12-12 05:06:05 +01:00
|
|
|
};
|
|
|
|
},
|
|
|
|
});
|
|
|
|
</script>
|
|
|
|
|
2020-01-29 20:37:25 +01:00
|
|
|
<style lang="scss" scoped>
|
|
|
|
.ldlomzub {
|
2021-10-31 12:19:49 +01:00
|
|
|
display: inline-block;
|
|
|
|
padding: 4px 8px 4px 4px;
|
|
|
|
border-radius: 999px;
|
2020-01-29 20:37:25 +01:00
|
|
|
color: var(--mention);
|
2020-06-04 15:19:08 +02:00
|
|
|
|
|
|
|
&.isMe {
|
|
|
|
color: var(--mentionMe);
|
|
|
|
}
|
2018-12-12 05:06:05 +01:00
|
|
|
|
2021-10-24 14:02:50 +02:00
|
|
|
> .icon {
|
|
|
|
width: 1.5em;
|
2021-10-31 12:19:49 +01:00
|
|
|
margin: 0 0.2em 0 0;
|
2021-10-24 14:02:50 +02:00
|
|
|
vertical-align: bottom;
|
|
|
|
border-radius: 100%;
|
|
|
|
}
|
|
|
|
|
2020-01-29 20:37:25 +01:00
|
|
|
> .main {
|
|
|
|
> .host {
|
|
|
|
opacity: 0.5;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2018-12-12 05:06:05 +01:00
|
|
|
</style>
|