mirror of
https://github.com/misskey-dev/misskey.git
synced 2024-12-23 17:10:39 +01:00
enhance(client): プロフィールが長い場合は折りたたむ
This commit is contained in:
parent
a5b1fe5d16
commit
39349dcba5
2 changed files with 77 additions and 2 deletions
72
packages/frontend/src/components/MkOmit.vue
Normal file
72
packages/frontend/src/components/MkOmit.vue
Normal file
|
@ -0,0 +1,72 @@
|
||||||
|
<template>
|
||||||
|
<div ref="content" :class="[$style.content, { [$style.omitted]: omitted }]">
|
||||||
|
<slot></slot>
|
||||||
|
<button v-if="omitted" :class="$style.fade" class="_button" @click="() => { ignoreOmit = true; omitted = false; }">
|
||||||
|
<span :class="$style.fadeLabel">{{ $ts.showMore }}</span>
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script lang="ts" setup>
|
||||||
|
import { nextTick, onMounted } from 'vue';
|
||||||
|
|
||||||
|
const props = withDefaults(defineProps<{
|
||||||
|
maxHeight: number;
|
||||||
|
}>(), {
|
||||||
|
maxHeight: 200,
|
||||||
|
});
|
||||||
|
|
||||||
|
let content = $ref<HTMLElement>();
|
||||||
|
let omitted = $ref(false);
|
||||||
|
let ignoreOmit = $ref(false);
|
||||||
|
|
||||||
|
onMounted(() => {
|
||||||
|
const calcOmit = () => {
|
||||||
|
if (omitted || ignoreOmit) return;
|
||||||
|
omitted = content.offsetHeight > props.maxHeight;
|
||||||
|
};
|
||||||
|
|
||||||
|
calcOmit();
|
||||||
|
new ResizeObserver((entries, observer) => {
|
||||||
|
calcOmit();
|
||||||
|
}).observe(content);
|
||||||
|
});
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<style lang="scss" module>
|
||||||
|
.content {
|
||||||
|
--stickyTop: 0px;
|
||||||
|
|
||||||
|
&.omitted {
|
||||||
|
position: relative;
|
||||||
|
max-height: v-bind("props.maxHeight + 'px'");
|
||||||
|
overflow: hidden;
|
||||||
|
|
||||||
|
> .fade {
|
||||||
|
display: block;
|
||||||
|
position: absolute;
|
||||||
|
z-index: 10;
|
||||||
|
bottom: 0;
|
||||||
|
left: 0;
|
||||||
|
width: 100%;
|
||||||
|
height: 64px;
|
||||||
|
background: linear-gradient(0deg, var(--panel), var(--X15));
|
||||||
|
|
||||||
|
> .fadeLabel {
|
||||||
|
display: inline-block;
|
||||||
|
background: var(--panel);
|
||||||
|
padding: 6px 10px;
|
||||||
|
font-size: 0.8em;
|
||||||
|
border-radius: 999px;
|
||||||
|
box-shadow: 0 2px 6px rgb(0 0 0 / 20%);
|
||||||
|
}
|
||||||
|
|
||||||
|
&:hover {
|
||||||
|
> .fadeLabel {
|
||||||
|
background: var(--panelHighlight);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
</style>
|
|
@ -42,8 +42,10 @@
|
||||||
<span v-for="role in user.roles" :key="role.id" v-tooltip="role.description" class="role" :style="{ '--color': role.color }">{{ role.name }}</span>
|
<span v-for="role in user.roles" :key="role.id" v-tooltip="role.description" class="role" :style="{ '--color': role.color }">{{ role.name }}</span>
|
||||||
</div>
|
</div>
|
||||||
<div class="description">
|
<div class="description">
|
||||||
<Mfm v-if="user.description" :text="user.description" :is-note="false" :author="user" :i="$i"/>
|
<MkOmit>
|
||||||
<p v-else class="empty">{{ i18n.ts.noAccountDescription }}</p>
|
<Mfm v-if="user.description" :text="user.description" :is-note="false" :author="user" :i="$i"/>
|
||||||
|
<p v-else class="empty">{{ i18n.ts.noAccountDescription }}</p>
|
||||||
|
</MkOmit>
|
||||||
</div>
|
</div>
|
||||||
<div class="fields system">
|
<div class="fields system">
|
||||||
<dl v-if="user.location" class="field">
|
<dl v-if="user.location" class="field">
|
||||||
|
@ -119,6 +121,7 @@ import MkContainer from '@/components/MkContainer.vue';
|
||||||
import MkFoldableSection from '@/components/MkFoldableSection.vue';
|
import MkFoldableSection from '@/components/MkFoldableSection.vue';
|
||||||
import MkRemoteCaution from '@/components/MkRemoteCaution.vue';
|
import MkRemoteCaution from '@/components/MkRemoteCaution.vue';
|
||||||
import MkTab from '@/components/MkTab.vue';
|
import MkTab from '@/components/MkTab.vue';
|
||||||
|
import MkOmit from '@/components/MkOmit.vue';
|
||||||
import MkInfo from '@/components/MkInfo.vue';
|
import MkInfo from '@/components/MkInfo.vue';
|
||||||
import { getScrollPosition } from '@/scripts/scroll';
|
import { getScrollPosition } from '@/scripts/scroll';
|
||||||
import { getUserMenu } from '@/scripts/get-user-menu';
|
import { getUserMenu } from '@/scripts/get-user-menu';
|
||||||
|
|
Loading…
Reference in a new issue