1
0
Fork 0
pixelfed/resources/assets/js/components/StoryTimelineComponent.vue

133 lines
2.7 KiB
Vue
Raw Normal View History

2020-01-10 20:00:42 +00:00
<template>
<div>
2020-11-19 09:15:07 +00:00
<div v-if="show" class="card card-body p-0 border mt-md-4 mb-md-3 shadow-none">
2021-08-31 07:30:21 +00:00
<div v-if="loading" class="w-100 h-100 d-flex align-items-center justify-content-center">
<div class="spinner-border spinner-border-sm text-lighter" role="status">
<span class="sr-only">Loading...</span>
</div>
</div>
<div v-else class="d-flex align-items-center justify-content-start scrolly">
<div
v-for="(story, index) in stories"
class="px-3 pt-3 text-center cursor-pointer"
:class="{ seen: story.seen }"
@click="showStory(index)">
<span
:class="[
story.seen ? 'not-seen' : '',
story.local ? '' : 'remote'
]"
class="mb-1 ring">
<img :src="story.avatar" width="60" height="60" class="rounded-circle border" onerror="this.onerror=null;this.src='/storage/avatars/default.png?v=2'">
</span>
<p
class="small font-weight-bold text-truncate"
:class="{ 'text-lighter': story.seen }"
style="max-width: 69px"
:title="story.username"
>
{{story.username}}
</p>
</div>
</div>
2020-01-10 20:00:42 +00:00
</div>
</div>
</template>
<script type="text/javascript">
export default {
2021-08-31 07:30:21 +00:00
props: ['list', 'scope'],
2020-01-10 20:00:42 +00:00
data() {
return {
2021-08-31 07:30:21 +00:00
loading: true,
show: true,
2020-01-10 20:00:42 +00:00
stories: {},
}
},
mounted() {
this.fetchStories();
},
methods: {
fetchStories() {
2021-08-31 07:30:21 +00:00
axios.get('/api/web/stories/v1/recent')
2020-01-10 20:00:42 +00:00
.then(res => {
let data = res.data;
2020-05-30 05:53:50 +00:00
if(!res.data.length) {
this.show = false;
return;
}
2021-08-31 07:30:21 +00:00
this.stories = res.data;
this.loading = false;
}).catch(err => {
this.loading = false;
this.$bvToast.toast('Cannot load stories. Please try again later.', {
title: 'Error',
variant: 'danger',
autoHideDelay: 5000
});
this.show = false;
});
},
2020-01-10 20:00:42 +00:00
2021-08-31 07:30:21 +00:00
showStory(index) {
let suffix;
2020-01-10 20:00:42 +00:00
2021-08-31 07:30:21 +00:00
switch(this.scope) {
case 'home':
suffix = '/?t=1';
break;
case 'local':
suffix = '/?t=2';
break;
case 'network':
suffix = '/?t=3';
break;
2020-01-10 20:00:42 +00:00
2021-08-31 07:30:21 +00:00
}
window.location.href = this.stories[index].url + suffix;
2020-01-10 20:00:42 +00:00
}
}
}
</script>
2021-08-31 07:30:21 +00:00
<style lang="scss" scoped>
.card {
height: 122px;
2020-01-10 20:00:42 +00:00
}
2021-08-31 07:30:21 +00:00
.ring {
display: block;
width: 66px;
height: 66px;
border-radius: 50%;
padding: 3px;
background: radial-gradient(ellipse at 70% 70%, #ee583f 8%, #d92d77 42%, #bd3381 58%);
&.remote {
background: radial-gradient(ellipse at 70% 70%, #f64f59 8%, #c471ed 42%, #12c2e9 58%);
}
&.not-seen {
opacity: 0.55;
background: #ccc;
}
img {
background: #fff;
padding: 3px;
}
2020-01-10 20:00:42 +00:00
}
2021-08-31 07:30:21 +00:00
.scrolly {
-ms-overflow-style: none;
scrollbar-width: none;
overflow-y: scroll;
&::-webkit-scrollbar {
display: none;
}
2020-01-10 20:00:42 +00:00
}
</style>