Collapse inline replied-to post to make it more compact

This commit is contained in:
Michcio 2022-09-06 11:45:45 +02:00
parent b541ecb099
commit 1258a588c7
6 changed files with 29 additions and 12 deletions

View file

@ -1,16 +1,16 @@
<template> <template>
<div v-size="{ max: [450] }" class="wrpstxzv" :class="{ children: depth > 1 }"> <div v-size="{ max: [450] }" class="wrpstxzv" :class="{ children: depth > 1, supercompact }">
<div class="main"> <div class="main">
<MkAvatar class="avatar" :user="note.user"/> <MkAvatar class="avatar" :user="note.user"/>
<div class="body"> <div class="body">
<XNoteHeader class="header" :note="note" :mini="true"/> <XNoteHeader :supercompact="supercompact" class="header" :note="note" :mini="true"/>
<div class="body"> <div class="body">
<p v-if="note.cw != null" class="cw"> <p v-if="note.cw != null" class="cw">
<Mfm v-if="note.cw != ''" class="text" :text="note.cw" :author="note.user" :i="$i" :custom-emojis="note.emojis"/> <Mfm v-if="note.cw != ''" class="text" :text="note.cw" :author="note.user" :i="$i" :custom-emojis="note.emojis"/>
<XCwButton v-model="showContent" :note="note"/> <XCwButton v-model="showContent" :note="note"/>
</p> </p>
<div v-show="note.cw == null || showContent" class="content"> <div v-show="note.cw == null || showContent" class="content">
<MkNoteSubNoteContent class="text" :note="note"/> <MkNoteSubNoteContent class="text" :note="note" :supercompact="supercompact"/>
</div> </div>
</div> </div>
</div> </div>
@ -38,11 +38,13 @@ const props = withDefaults(defineProps<{
note: foundkey.entities.Note; note: foundkey.entities.Note;
conversation?: foundkey.entities.Note[] | null; conversation?: foundkey.entities.Note[] | null;
supercompact?: boolean;
// how many notes are in between this one and the note being viewed in detail // how many notes are in between this one and the note being viewed in detail
depth?: number; depth?: number;
}>(), { }>(), {
conversation: null, conversation: null,
depth: 1, depth: 1,
supercompact: false,
}); });
let showContent = $ref(false); let showContent = $ref(false);
@ -67,6 +69,13 @@ const replies: foundkey.entities.Note[] = props.conversation?.filter(item => ite
} }
} }
&.supercompact {
> .main > .avatar {
width: 30px;
height: 30px;
}
}
> .main { > .main {
display: flex; display: flex;
@ -76,7 +85,7 @@ const replies: foundkey.entities.Note[] = props.conversation?.filter(item => ite
margin: 0 8px 0 0; margin: 0 8px 0 0;
width: 38px; width: 38px;
height: 38px; height: 38px;
border-radius: 8px; border-radius: calc(8% / 38);
} }
> .body { > .body {

View file

@ -1,10 +1,11 @@
<template> <template>
<header class="kkwtjztg"> <header class="kkwtjztg">
<MkA v-user-preview="note.user.id" class="name" :to="userPage(note.user)"> <MkA v-user-preview="note.user.id" class="name" :to="userPage(note.user)">
<MkUserName :user="note.user"/> <MkUserName v-if="!supercompact" :user="note.user"/>
<div v-if="supercompact" class="username"><MkAcct :user="note.user"/></div>
</MkA> </MkA>
<div v-if="note.user.isBot" class="is-bot">bot</div> <div v-if="note.user.isBot" class="is-bot">bot</div>
<div class="username"><MkAcct :user="note.user"/></div> <div v-if="!supercompact" class="username"><MkAcct :user="note.user"/></div>
<div class="info"> <div class="info">
<MkA class="created-at" :to="notePage(note)"> <MkA class="created-at" :to="notePage(note)">
<MkTime :time="note.createdAt"/> <MkTime :time="note.createdAt"/>
@ -23,6 +24,7 @@ import { userPage } from '@/filters/user';
defineProps<{ defineProps<{
note: foundkey.entities.Note; note: foundkey.entities.Note;
pinned?: boolean; pinned?: boolean;
supercompact?: boolean;
}>(); }>();
</script> </script>

View file

@ -9,7 +9,7 @@
:tabindex="!isDeleted ? '-1' : null" :tabindex="!isDeleted ? '-1' : null"
:class="{ renote: isRenote }" :class="{ renote: isRenote }"
> >
<MkNoteSub v-if="appearNote.reply" :note="appearNote.reply" class="reply-to"/> <MkNoteSub v-if="appearNote.reply" :note="appearNote.reply" :supercompact="compactParent" class="reply-to"/>
<div v-if="pinned" class="info"><i class="fas fa-thumbtack"></i> {{ i18n.ts.pinnedNote }}</div> <div v-if="pinned" class="info"><i class="fas fa-thumbtack"></i> {{ i18n.ts.pinnedNote }}</div>
<div v-if="appearNote._featuredId_" class="info"><i class="fas fa-bolt"></i> {{ i18n.ts.featured }}</div> <div v-if="appearNote._featuredId_" class="info"><i class="fas fa-bolt"></i> {{ i18n.ts.featured }}</div>
<div v-if="isRenote" class="renote"> <div v-if="isRenote" class="renote">
@ -131,6 +131,7 @@ import { useNoteCapture } from '@/scripts/use-note-capture';
const props = defineProps<{ const props = defineProps<{
note: foundkey.entities.Note; note: foundkey.entities.Note;
pinned?: boolean; pinned?: boolean;
compactParent?: boolean;
}>(); }>();
const inChannel = inject('inChannel', null); const inChannel = inject('inChannel', null);

View file

@ -10,7 +10,7 @@
<template #default="{ items: notes }"> <template #default="{ items: notes }">
<div class="giivymft" :class="{ noGap }"> <div class="giivymft" :class="{ noGap }">
<XList ref="notes" v-slot="{ item: note }" :items="notes" :direction="pagination.reversed ? 'up' : 'down'" :reversed="pagination.reversed" :no-gap="noGap" class="notes"> <XList ref="notes" v-slot="{ item: note }" :items="notes" :direction="pagination.reversed ? 'up' : 'down'" :reversed="pagination.reversed" :no-gap="noGap" class="notes">
<XNote :key="note._featuredId_ || note.id" class="qtqtichx" :note="note"/> <XNote :key="note._featuredId_ || note.id" class="qtqtichx" :note="note" :compact-parent="true"/>
</XList> </XList>
</div> </div>
</template> </template>

View file

@ -9,7 +9,7 @@
<template #default="{ items: notifications }"> <template #default="{ items: notifications }">
<XList v-slot="{ item: notification }" class="elsfgstc" :items="notifications" :no-gap="true"> <XList v-slot="{ item: notification }" class="elsfgstc" :items="notifications" :no-gap="true">
<XNote v-if="['reply', 'quote', 'mention'].includes(notification.type)" :key="notification.id" :note="notification.note"/> <XNote v-if="['reply', 'quote', 'mention'].includes(notification.type)" :key="notification.id" :note="notification.note" :compact-parent="true"/>
<XNotification v-else :key="notification.id" :notification="notification" :with-time="true" :full="true" class="_panel notification"/> <XNotification v-else :key="notification.id" :notification="notification" :with-time="true" :full="true" class="_panel notification"/>
</XList> </XList>
</template> </template>

View file

@ -1,5 +1,5 @@
<template> <template>
<div class="wrmlmaau" :class="{ collapsed, isLong }"> <div class="wrmlmaau" :class="{ collapsed, isLong, supercompact }">
<div class="body"> <div class="body">
<span v-if="note.deletedAt" style="opacity: 0.5">({{ i18n.ts.deleted }})</span> <span v-if="note.deletedAt" style="opacity: 0.5">({{ i18n.ts.deleted }})</span>
<MkA v-if="note.replyId" class="reply" :to="`/notes/${note.replyId}`"><i class="fas fa-reply"></i></MkA> <MkA v-if="note.replyId" class="reply" :to="`/notes/${note.replyId}`"><i class="fas fa-reply"></i></MkA>
@ -15,7 +15,7 @@
<XPoll :note="note"/> <XPoll :note="note"/>
</details> </details>
<button v-if="isLong && collapsed" class="fade _button" @click="collapsed = false"> <button v-if="isLong && collapsed" class="fade _button" @click="collapsed = false">
<span>{{ i18n.ts.showMore }}</span> <span v-if="!supercompact">{{ i18n.ts.showMore }}</span>
</button> </button>
<button v-if="isLong && !collapsed" class="showLess _button" @click="collapsed = true"> <button v-if="isLong && !collapsed" class="showLess _button" @click="collapsed = true">
<span>{{ i18n.ts.showLess }}</span> <span>{{ i18n.ts.showLess }}</span>
@ -31,6 +31,7 @@ import { i18n } from '@/i18n';
const props = defineProps<{ const props = defineProps<{
note: foundkey.entities.Note; note: foundkey.entities.Note;
supercompact?: boolean;
}>(); }>();
const isLong = ( const isLong = (
@ -39,7 +40,7 @@ const isLong = (
(props.note.text.length > 500) (props.note.text.length > 500)
) )
); );
const collapsed = $ref(props.note.cw == null && isLong); const collapsed = $ref(props.supercompact || (props.note.cw == null && isLong));
</script> </script>
<style lang="scss" scoped> <style lang="scss" scoped>
@ -64,6 +65,10 @@ const collapsed = $ref(props.note.cw == null && isLong);
max-height: 9em; max-height: 9em;
overflow: hidden; overflow: hidden;
&.supercompact {
max-height: 4.5em;
}
> .fade { > .fade {
display: block; display: block;
position: absolute; position: absolute;