hippofish/packages/frontend/src/components/MkSubNoteContent.vue

142 lines
3.8 KiB
Vue
Raw Normal View History

<!--
SPDX-FileCopyrightText: syuilo and other misskey contributors
SPDX-License-Identifier: AGPL-3.0-only
-->
<template>
2023-01-14 07:05:23 +01:00
<div :class="[$style.root, { [$style.collapsed]: collapsed }]">
<div :class="{ [$style.clickToOpen]: defaultStore.state.clickToOpen }" @click="defaultStore.state.clickToOpen ? noteclick(note.id) : undefined">
2022-07-20 15:24:26 +02:00
<span v-if="note.isHidden" style="opacity: 0.5">({{ i18n.ts.private }})</span>
<span v-if="note.deletedAt" style="opacity: 0.5">({{ i18n.ts.deleted }})</span>
2023-10-01 00:46:42 +02:00
<MkA v-if="note.replyId" :class="$style.reply" :to="`/notes/${note.replyId}`" v-on:click.stop><i class="ph-arrow-bend-left-up ph-bold pg-lg"></i></MkA>
2023-05-19 06:58:09 +02:00
<Mfm v-if="note.text" :text="note.text" :author="note.user" :i="$i" :emojiUrls="note.emojis"/>
<div v-if="note.text && translating || note.text && translation" :class="$style.translation">
<MkLoading v-if="translating" mini/>
<div v-else>
<b>{{ i18n.t('translatedFrom', { x: translation.sourceLang }) }}: </b>
<Mfm :text="translation.text" :author="note.user" :i="$i" :emojiUrls="note.emojis"/>
</div>
</div>
2023-09-23 01:26:57 +02:00
<MkA v-if="note.renoteId" :class="$style.rp" :to="`/notes/${note.renoteId}`" v-on:click.stop>RN: ...</MkA>
</div>
<details v-if="note.files.length > 0" :open="!defaultStore.state.collapseFiles && !hideFiles">
2023-04-01 07:01:57 +02:00
<summary>({{ i18n.t('withNFiles', { n: note.files.length }) }})</summary>
2023-05-19 06:58:09 +02:00
<MkMediaList :mediaList="note.files"/>
</details>
<details v-if="note.poll">
2022-07-20 15:24:26 +02:00
<summary>{{ i18n.ts.poll }}</summary>
2022-12-30 05:56:22 +01:00
<MkPoll :note="note"/>
</details>
<button v-if="isLong && collapsed" :class="$style.fade" class="_button" @click="collapsed = false">
2023-01-14 07:05:23 +01:00
<span :class="$style.fadeLabel">{{ i18n.ts.showMore }}</span>
</button>
<button v-else-if="isLong && !collapsed" :class="$style.showLess" class="_button" @click="collapsed = true">
<span :class="$style.showLessLabel">{{ i18n.ts.showLess }}</span>
</button>
</div>
</template>
<script lang="ts" setup>
import { } from 'vue';
import * as Misskey from 'misskey-js';
2022-12-30 05:56:22 +01:00
import MkMediaList from '@/components/MkMediaList.vue';
import MkPoll from '@/components/MkPoll.vue';
2023-09-19 09:37:43 +02:00
import { i18n } from '@/i18n.js';
import { $i } from '@/account.js';
import { shouldCollapsed } from '@/scripts/collapsed.js';
2023-09-28 11:46:24 +02:00
import { defaultStore } from '@/store.js';
2023-09-23 01:26:57 +02:00
import { useRouter } from '@/router.js';
const props = defineProps<{
note: Misskey.entities.Note;
translating?: boolean;
translation?: any;
hideFiles?: boolean;
}>();
2023-09-23 01:26:57 +02:00
const router = useRouter();
function noteclick(id: string) {
router.push(`/notes/${id}`);
}
const isLong = shouldCollapsed(props.note, []);
const collapsed = $ref(isLong);
</script>
2023-01-14 07:05:23 +01:00
<style lang="scss" module>
.root {
overflow-wrap: break-word;
&.collapsed {
position: relative;
max-height: 9em;
overflow: clip;
> .fade {
display: block;
position: absolute;
bottom: 0;
left: 0;
width: 100%;
height: 64px;
2023-10-16 02:05:34 +02:00
//background: linear-gradient(0deg, var(--panel), var(--X15));
2023-01-14 07:05:23 +01:00
> .fadeLabel {
display: inline-block;
background: var(--panel);
padding: 6px 10px;
font-size: 0.8em;
border-radius: var(--radius-ellipse);
box-shadow: 0 2px 6px rgb(0 0 0 / 20%);
}
&:hover {
2023-01-14 07:05:23 +01:00
> .fadeLabel {
background: var(--panelHighlight);
}
}
}
}
}
2023-01-14 07:05:23 +01:00
.reply {
margin-right: 6px;
color: var(--accent);
}
.rp {
margin-left: 4px;
font-style: oblique;
color: var(--renote);
}
.translation {
border: solid 0.5px var(--divider);
border-radius: var(--radius);
padding: 12px;
margin-top: 8px;
}
.showLess {
width: 100%;
margin-top: 14px;
position: sticky;
bottom: calc(var(--stickyBottom, 0px) + 14px);
}
.showLessLabel {
display: inline-block;
background: var(--popup);
padding: 6px 10px;
font-size: 0.8em;
border-radius: var(--radius-ellipse);
box-shadow: 0 2px 6px rgb(0 0 0 / 20%);
}
.clickToOpen {
cursor: pointer;
}
</style>