hippofish/packages/frontend/src/pages/welcome.timeline.vue

93 lines
2.2 KiB
Vue
Raw Normal View History

2020-12-30 16:22:20 +01:00
<template>
<div :class="$style.root">
<div ref="scrollEl" :class="[$style.scrollbox, { [$style.scroll]: isScrolling }]">
<div v-for="note in notes" :key="note.id" :class="$style.note">
<div class="_panel" :class="$style.content">
<div :class="$style.body">
<MkA v-if="note.replyId" class="reply" :to="`/notes/${note.replyId}`"><i class="ti ti-arrow-back-up"></i></MkA>
2023-04-01 06:52:07 +02:00
<Mfm v-if="note.text" :text="note.text" :author="note.user" :i="$i"/>
2021-11-19 11:36:12 +01:00
<MkA v-if="note.renoteId" class="rp" :to="`/notes/${note.renoteId}`">RN: ...</MkA>
</div>
<div v-if="note.files.length > 0" :class="$style.richcontent">
2023-04-01 06:52:07 +02:00
<MkMediaList :media-list="note.files"/>
</div>
<div v-if="note.poll">
2023-04-01 06:52:07 +02:00
<MkPoll :note="note" :read-only="true"/>
</div>
</div>
2023-04-01 06:52:07 +02:00
<MkReactionsViewer ref="reactionsViewer" :note="note"/>
2020-12-30 16:22:20 +01:00
</div>
</div>
</div>
</template>
<script lang="ts" setup>
2023-04-01 06:52:07 +02:00
import { Note } from 'misskey-js/built/entities';
import { onUpdated } from 'vue';
2022-12-30 05:56:22 +01:00
import MkReactionsViewer from '@/components/MkReactionsViewer.vue';
import MkMediaList from '@/components/MkMediaList.vue';
import MkPoll from '@/components/MkPoll.vue';
2021-11-11 18:02:25 +01:00
import * as os from '@/os';
import { getScrollContainer } from '@/scripts/scroll';
2023-04-01 06:52:07 +02:00
import { $i } from '@/account';
2020-12-30 16:22:20 +01:00
let notes = $ref<Note[]>([]);
let isScrolling = $ref(false);
let scrollEl = $ref<HTMLElement>();
2020-12-30 16:22:20 +01:00
os.apiGet('notes/featured').then(_notes => {
notes = _notes;
});
onUpdated(() => {
if (!scrollEl) return;
const container = getScrollContainer(scrollEl);
const containerHeight = container ? container.clientHeight : window.innerHeight;
if (scrollEl.offsetHeight > containerHeight) {
isScrolling = true;
}
2020-12-30 16:22:20 +01:00
});
</script>
<style lang="scss" module>
@keyframes scroll {
0% {
transform: translate3d(0, 0, 0);
}
5% {
transform: translate3d(0, 0, 0);
}
75% {
transform: translate3d(0, calc(-100% + 90vh), 0);
}
90% {
transform: translate3d(0, calc(-100% + 90vh), 0);
}
}
.root {
2020-12-30 16:22:20 +01:00
text-align: right;
}
2020-12-30 16:22:20 +01:00
.scrollbox {
&.scroll {
animation: scroll 45s linear infinite;
}
}
.note {
margin: 16px 0 16px auto;
}
.content {
padding: 16px;
margin: 0 0 0 auto;
max-width: max-content;
border-radius: 16px;
}
2020-12-30 16:22:20 +01:00
.richcontent {
min-width: 250px;
2020-12-30 16:22:20 +01:00
}
</style>