mizzkey/packages/frontend/src/components/MkMention.vue

159 lines
4.1 KiB
Vue
Raw Normal View History

<!--
2024-02-12 11:37:45 +09:00
SPDX-FileCopyrightText: syuilo and misskey-project
SPDX-License-Identifier: AGPL-3.0-only
-->
2018-12-12 13:06:05 +09:00
<template>
2023-10-24 21:13:30 +09:00
<MkA v-user-preview="canonical" :class="[$style.root, { [$style.isMe]: isMe && gamingType === '' , [$style.gamingDark]: gamingType === 'dark',[$style.gamingLight]: gamingType === 'light' }]" :to="url" :style="{ background: bgCss }">
<img :class="$style.icon" :src="avatarUrl" alt="">
2023-01-14 20:31:48 +09:00
<span>
<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>
</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';
2023-09-23 09:01:20 +09:00
import {computed, ref, watch} from 'vue';
2022-06-24 10:34:36 +09:00
import tinycolor from 'tinycolor2';
2023-09-19 16:37:43 +09:00
import { host as localHost } from '@/config.js';
import { $i } from '@/account.js';
import { defaultStore } from '@/store.js';
import { getStaticImageUrl } from '@/scripts/media-proxy.js';
2018-12-12 13:06:05 +09:00
2023-10-24 21:13:30 +09:00
const gamingType = computed(defaultStore.makeGetterSetter('gamingType'));
2023-09-23 09:01:20 +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 avatarUrl = computed(() => defaultStore.state.disableShowingAnimatedImages
? getStaticImageUrl(`/avatar/@${props.username}@${props.host}`)
: `/avatar/@${props.username}@${props.host}`,
);
2023-10-28 15:59:10 +09:00
const bgCss = (gamingType.value === '') ? bg.toRgbString() : "";
2023-09-23 09:01:20 +09:00
//const bgCss = `background:${bg.toRgbString()}; ${result}` ;
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;
color: var(--mention);
2020-06-04 22:19:08 +09:00
2023-09-23 09:01:20 +09:00
&.gamingLight{
color: white;
opacity: 0.9;
background: linear-gradient(270deg, #c06161, #c0a567, #b6ba69, #81bc72, #63c3be, #8bacd6, #9f8bd6, #d18bd6, #d883b4); background-size: 1800% 1800% !important;
2023-09-25 02:02:33 +09:00
-webkit-animation: AnimationLight var(--gamingspeed) cubic-bezier(0, 0.2, 0.90, 1) infinite !important;
-moz-animation: AnimationLight var(--gamingspeed) cubic-bezier(0, 0.2, 0.90, 1) infinite !important;
animation: AnimationLight var(--gamingspeed) cubic-bezier(0, 0.2, 0.90, 1) infinite !important;
2023-09-23 09:01:20 +09:00
}
&.gamingDark{
opacity: 0.9;
color: white;
background: linear-gradient(270deg, #e7a2a2, #e3cfa2, #ebefa1, #b3e7a6, #a6ebe7, #aec5e3, #cabded, #e0b9e3, #f4bddd); background-size: 1800% 1800%;
2023-09-25 02:02:33 +09:00
-webkit-animation:AnimationLight var(--gamingspeed) cubic-bezier(0, 0.2, 0.90, 1) infinite;
-moz-animation:AnimationLight var(--gamingspeed) cubic-bezier(0, 0.2, 0.90, 1) infinite;
animation:AnimationLight var(--gamingspeed) cubic-bezier(0, 0.2, 0.90, 1) infinite;
2023-09-23 09:01:20 +09:00
}
2020-06-04 22:19:08 +09:00
&.isMe {
color: var(--mentionMe);
2023-09-23 09:01:20 +09:00
2020-06-04 22:19:08 +09:00
}
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%;
}
2023-01-14 20:31:48 +09:00
.host {
opacity: 0.5;
}
2023-09-23 09:01:20 +09:00
@-webkit-keyframes AnimationLight {
0% {
background-position: 0% 50%
}
50% {
background-position: 100% 50%
}
100% {
background-position: 0% 50%
}
}
@-moz-keyframes AnimationLight {
0% {
background-position: 0% 50%
}
50% {
background-position: 100% 50%
}
100% {
background-position: 0% 50%
}
} @keyframes AnimationLight {
0% {
background-position: 0% 50%
}
50% {
background-position: 100% 50%
}
100% {
background-position: 0% 50%
}
}
@-webkit-keyframes AnimationDark {
0% {
background-position: 0% 50%
}
50% {
background-position: 100% 50%
}
100% {
background-position: 0% 50%
}
}
@-moz-keyframes AnimationDark {
0% {
background-position: 0% 50%
}
50% {
background-position: 100% 50%
}
100% {
background-position: 0% 50%
}
}
@keyframes AnimationDark {
0% {
background-position: 0% 50%
}
50% {
background-position: 100% 50%
}
100% {
background-position: 0% 50%
}
}
2018-12-12 13:06:05 +09:00
</style>