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

97 lines
2.4 KiB
Vue
Raw Normal View History

<!--
SPDX-FileCopyrightText: syuilo and other misskey contributors
SPDX-License-Identifier: AGPL-3.0-only
-->
2020-12-30 17:22:20 +02: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>
<MkA v-if="note.replyId" class="reply" :to="`/notes/${note.replyId}`"><i class="ph-arrow-u-up-left ph-bold ph-lg"></i></MkA>
<Mfm v-if="note.text" :text="note.text" :author="note.user"/>
2021-11-19 12:36:12 +02: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-05-19 10:20:53 +03:00
<MkMediaList :mediaList="note.files"/>
</div>
<div v-if="note.poll">
2023-05-19 10:20:53 +03:00
<MkPoll :note="note" :readOnly="true"/>
</div>
</div>
2023-04-01 07:52:07 +03:00
<MkReactionsViewer ref="reactionsViewer" :note="note"/>
2020-12-30 17:22:20 +02:00
</div>
</div>
</div>
</template>
<script lang="ts" setup>
import * as Misskey from 'misskey-js';
import { onUpdated, ref, shallowRef } from 'vue';
2022-12-30 06:56:22 +02:00
import MkReactionsViewer from '@/components/MkReactionsViewer.vue';
import MkMediaList from '@/components/MkMediaList.vue';
import MkPoll from '@/components/MkPoll.vue';
import { misskeyApiGet } from '@/scripts/misskey-api.js';
2023-09-19 10:37:43 +03:00
import { getScrollContainer } from '@/scripts/scroll.js';
2020-12-30 17:22:20 +02:00
const notes = ref<Misskey.entities.Note[]>([]);
const isScrolling = ref(false);
const scrollEl = shallowRef<HTMLElement>();
2020-12-30 17:22:20 +02:00
misskeyApiGet('notes/featured').then(_notes => {
notes.value = _notes;
});
onUpdated(() => {
if (!scrollEl.value) return;
const container = getScrollContainer(scrollEl.value);
const containerHeight = container ? container.clientHeight : window.innerHeight;
if (scrollEl.value.offsetHeight > containerHeight) {
isScrolling.value = true;
}
2020-12-30 17:22:20 +02: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 17:22:20 +02:00
text-align: right;
}
2020-12-30 17:22:20 +02: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: var(--radius-md);
}
2020-12-30 17:22:20 +02:00
.richcontent {
min-width: 250px;
2020-12-30 17:22:20 +02:00
}
</style>