Rich welcome content (#7588)
* Add rich content (polls, media) to the welcome page notes * Add a simple scrolling animation to welcome page
This commit is contained in:
parent
38474c7316
commit
cb42f94d9c
2 changed files with 68 additions and 15 deletions
|
@ -10,7 +10,7 @@
|
||||||
</span>
|
</span>
|
||||||
</li>
|
</li>
|
||||||
</ul>
|
</ul>
|
||||||
<p>
|
<p v-if="!readOnly">
|
||||||
<span>{{ $t('_poll.totalVotes', { n: total }) }}</span>
|
<span>{{ $t('_poll.totalVotes', { n: total }) }}</span>
|
||||||
<span> · </span>
|
<span> · </span>
|
||||||
<a v-if="!closed && !isVoted" @click="toggleShowResult">{{ showResult ? $ts._poll.vote : $ts._poll.showResult }}</a>
|
<a v-if="!closed && !isVoted" @click="toggleShowResult">{{ showResult ? $ts._poll.vote : $ts._poll.showResult }}</a>
|
||||||
|
@ -31,6 +31,11 @@ export default defineComponent({
|
||||||
note: {
|
note: {
|
||||||
type: Object,
|
type: Object,
|
||||||
required: true
|
required: true
|
||||||
|
},
|
||||||
|
readOnly: {
|
||||||
|
type: Boolean,
|
||||||
|
required: false,
|
||||||
|
default: false,
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
data() {
|
data() {
|
||||||
|
@ -65,7 +70,7 @@ export default defineComponent({
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
created() {
|
created() {
|
||||||
this.showResult = this.isVoted;
|
this.showResult = this.readOnly || this.isVoted;
|
||||||
|
|
||||||
if (this.note.poll.expiresAt) {
|
if (this.note.poll.expiresAt) {
|
||||||
const update = () => {
|
const update = () => {
|
||||||
|
@ -83,7 +88,7 @@ export default defineComponent({
|
||||||
this.showResult = !this.showResult;
|
this.showResult = !this.showResult;
|
||||||
},
|
},
|
||||||
vote(id) {
|
vote(id) {
|
||||||
if (this.closed || !this.poll.multiple && this.poll.choices.some(c => c.isVoted)) return;
|
if (this.readOnly || this.closed || !this.poll.multiple && this.poll.choices.some(c => c.isVoted)) return;
|
||||||
os.api('notes/polls/vote', {
|
os.api('notes/polls/vote', {
|
||||||
noteId: this.note.id,
|
noteId: this.note.id,
|
||||||
choice: id
|
choice: id
|
||||||
|
|
|
@ -1,27 +1,44 @@
|
||||||
<template>
|
<template>
|
||||||
<div class="civpbkhh">
|
<div class="civpbkhh">
|
||||||
|
<div class="scrollbox" ref="scroll" v-bind:class="{ scroll: isScrolling }">
|
||||||
<div v-for="note in notes" class="note">
|
<div v-for="note in notes" class="note">
|
||||||
<div class="content _panel">
|
<div class="content _panel">
|
||||||
{{ note.text }}
|
<div class="body">
|
||||||
|
<MkA class="reply" v-if="note.replyId" :to="`/notes/${note.replyId}`"><i class="fas fa-reply"></i></MkA>
|
||||||
|
<Mfm v-if="note.text" :text="note.text" :author="note.user" :i="$i" :custom-emojis="note.emojis"/>
|
||||||
|
<MkA class="rp" v-if="note.renoteId" :to="`/notes/${note.renoteId}`">RN: ...</MkA>
|
||||||
|
</div>
|
||||||
|
<div v-if="note.files.length > 0" class="richcontent">
|
||||||
|
<XMediaList :media-list="note.files"/>
|
||||||
|
</div>
|
||||||
|
<div v-if="note.poll">
|
||||||
|
<XPoll :note="note" :readOnly="true" />
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<XReactionsViewer :note="note" ref="reactionsViewer"/>
|
<XReactionsViewer :note="note" ref="reactionsViewer"/>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import { defineComponent } from 'vue';
|
import { defineComponent } from 'vue';
|
||||||
import XReactionsViewer from '@client/components/reactions-viewer.vue';
|
import XReactionsViewer from '@client/components/reactions-viewer.vue';
|
||||||
|
import XMediaList from '@client/components/media-list.vue';
|
||||||
|
import XPoll from '@client/components/poll.vue';
|
||||||
import * as os from '@client/os';
|
import * as os from '@client/os';
|
||||||
|
|
||||||
export default defineComponent({
|
export default defineComponent({
|
||||||
components: {
|
components: {
|
||||||
XReactionsViewer
|
XReactionsViewer,
|
||||||
|
XMediaList,
|
||||||
|
XPoll
|
||||||
},
|
},
|
||||||
|
|
||||||
data() {
|
data() {
|
||||||
return {
|
return {
|
||||||
notes: [],
|
notes: [],
|
||||||
|
isScrolling: false,
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
@ -29,14 +46,40 @@ export default defineComponent({
|
||||||
os.api('notes/featured').then(notes => {
|
os.api('notes/featured').then(notes => {
|
||||||
this.notes = notes;
|
this.notes = notes;
|
||||||
});
|
});
|
||||||
|
},
|
||||||
|
|
||||||
|
updated() {
|
||||||
|
if (this.$refs.scroll.clientHeight > window.innerHeight) {
|
||||||
|
this.isScrolling = true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style lang="scss" scoped>
|
<style lang="scss" scoped>
|
||||||
|
@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);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
.civpbkhh {
|
.civpbkhh {
|
||||||
text-align: right;
|
text-align: right;
|
||||||
|
|
||||||
|
> .scrollbox {
|
||||||
|
&.scroll {
|
||||||
|
animation: scroll 45s linear infinite;
|
||||||
|
}
|
||||||
|
|
||||||
> .note {
|
> .note {
|
||||||
margin: 16px 0 16px auto;
|
margin: 16px 0 16px auto;
|
||||||
|
|
||||||
|
@ -45,6 +88,11 @@ export default defineComponent({
|
||||||
margin: 0 0 0 auto;
|
margin: 0 0 0 auto;
|
||||||
max-width: max-content;
|
max-width: max-content;
|
||||||
border-radius: 16px;
|
border-radius: 16px;
|
||||||
|
|
||||||
|
> .richcontent {
|
||||||
|
min-width: 250px;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue