misskey/packages/client/src/components/user-card-mini.vue

98 lines
2.4 KiB
Vue
Raw Normal View History

2022-06-21 17:55:38 +09:00
<template>
2022-06-22 23:40:53 +09:00
<div :class="[$style.root, { yellow: user.isSilenced, red: user.isSuspended, gray: false }]">
<MkAvatar class="avatar" :user="user" :disable-link="true" :show-indicator="true"/>
2022-06-21 17:55:38 +09:00
<div class="body">
2022-06-22 23:40:53 +09:00
<span class="name"><MkUserName class="name" :user="user"/></span>
<span class="sub"><span class="acct _monospace">@{{ acct(user) }}</span></span>
2022-06-21 17:55:38 +09:00
</div>
2022-06-22 23:40:53 +09:00
<MkMiniChart v-if="chart" class="chart" :src="chart.inc"/>
2022-06-21 17:55:38 +09:00
</div>
</template>
<script lang="ts" setup>
import * as misskey from 'misskey-js';
import MkMiniChart from '@/components/mini-chart.vue';
import * as os from '@/os';
2022-06-22 23:40:53 +09:00
import { acct } from '@/filters/user';
2022-06-21 17:55:38 +09:00
const props = defineProps<{
2022-06-22 23:40:53 +09:00
user: misskey.entities.User;
2022-06-21 17:55:38 +09:00
}>();
const chart = $ref(null);
2022-06-22 23:40:53 +09:00
os.api('charts/user/notes', { userId: props.user.id, limit: 16, span: 'day' }).then(res => {
2022-06-21 17:55:38 +09:00
chart = res;
});
</script>
<style lang="scss" module>
.root {
$bodyTitleHieght: 18px;
$bodyInfoHieght: 16px;
display: flex;
align-items: center;
padding: 16px;
background: var(--panel);
border-radius: 8px;
2022-06-22 23:40:53 +09:00
> :global(.avatar) {
2022-06-21 17:55:38 +09:00
display: block;
width: ($bodyTitleHieght + $bodyInfoHieght);
height: ($bodyTitleHieght + $bodyInfoHieght);
2022-06-22 23:40:53 +09:00
margin-right: 12px;
2022-06-21 17:55:38 +09:00
}
> :global(.body) {
flex: 1;
overflow: hidden;
font-size: 0.9em;
color: var(--fg);
padding-right: 8px;
2022-06-22 23:40:53 +09:00
> :global(.name) {
2022-06-21 17:55:38 +09:00
display: block;
width: 100%;
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
line-height: $bodyTitleHieght;
}
> :global(.sub) {
2022-06-23 13:39:28 +09:00
display: block;
width: 100%;
font-size: 95%;
2022-06-21 17:55:38 +09:00
opacity: 0.7;
line-height: $bodyInfoHieght;
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
}
}
> :global(.chart) {
height: 30px;
}
&:global(.yellow) {
--c: rgb(255 196 0 / 15%);
background-image: linear-gradient(45deg, var(--c) 16.67%, transparent 16.67%, transparent 50%, var(--c) 50%, var(--c) 66.67%, transparent 66.67%, transparent 100%);
background-size: 16px 16px;
}
&:global(.red) {
--c: rgb(255 0 0 / 15%);
background-image: linear-gradient(45deg, var(--c) 16.67%, transparent 16.67%, transparent 50%, var(--c) 50%, var(--c) 66.67%, transparent 66.67%, transparent 100%);
background-size: 16px 16px;
}
&:global(.gray) {
--c: var(--bg);
background-image: linear-gradient(45deg, var(--c) 16.67%, transparent 16.67%, transparent 50%, var(--c) 50%, var(--c) 66.67%, transparent 66.67%, transparent 100%);
background-size: 16px 16px;
}
}
</style>