Update DiscoverComponent

pull/1565/head
Daniel Supernault 2019-08-05 21:39:11 -06:00
rodzic d4cab97f3a
commit 22362b9e88
Nie znaleziono w bazie danych klucza dla tego podpisu
ID klucza GPG: 0DEF1C662C9033F7
1 zmienionych plików z 94 dodań i 106 usunięć

Wyświetl plik

@ -1,117 +1,105 @@
<template> <template>
<div class="container"> <div>
<div v-if="!loaded" style="height: 70vh;" class="d-flex justify-content-center align-items-center">
<img src="/img/pixelfed-icon-grey.svg">
</div>
<div v-else>
<div class="d-block d-md-none px-0 border-top-0 mx-n3">
<input class="form-control rounded-0" placeholder="Search" v-model="searchTerm" v-on:keyup.enter="searchSubmit">
</div>
<section class="d-none d-md-flex mb-md-2 pt-5 discover-bar" style="width:auto; overflow: auto hidden;" v-if="categories.length > 0">
<a v-if="config.ab.loops == true" class="text-decoration-none bg-transparent border border-success rounded d-inline-flex align-items-center justify-content-center mr-3 card-disc" href="/discover/loops">
<p class="text-success lead font-weight-bold mb-0">Loops</p>
</a>
<a v-for="(category, index) in categories" :key="index+'_cat_'" class="bg-dark rounded d-inline-flex align-items-end justify-content-center mr-3 box-shadow card-disc" :href="category.url" :style="'background: linear-gradient(rgba(0, 0, 0, 0.3),rgba(0, 0, 0, 0.3)),url('+category.thumb+');'">
<p class="text-white font-weight-bold" style="text-shadow: 3px 3px 16px #272634;">{{category.name}}</p>
</a>
<section class="d-none d-md-flex mb-md-2 pt-2 discover-bar" style="width:auto; overflow: auto hidden;" v-if="categories.length > 0"> </section>
<a v-if="config.ab.loops == true" class="text-decoration-none bg-transparent border border-success rounded d-inline-flex align-items-center justify-content-center mr-3 card-disc" href="/discover/loops"> <section class="mb-5 section-explore">
<p class="text-success lead font-weight-bold mb-0">Loops</p> <div class="profile-timeline">
</a> <div class="row p-0">
<!-- <a class="text-decoration-none rounded d-inline-flex align-items-center justify-content-center mr-3 box-shadow card-disc" href="/discover/personal" style="background: rgb(255, 95, 109);"> <div class="col-4 p-1 p-sm-2 p-md-3" v-for="post in posts">
<p class="text-white lead font-weight-bold mb-0">For You</p> <a class="card info-overlay card-md-border-0" :href="post.url">
</a> --> <div class="square">
<span v-if="post.type == 'photo:album'" class="float-right mr-3 post-icon"><i class="fas fa-images fa-2x"></i></span>
<a v-for="(category, index) in categories" :key="index+'_cat_'" class="bg-dark rounded d-inline-flex align-items-end justify-content-center mr-3 box-shadow card-disc" :href="category.url" :style="'background: linear-gradient(rgba(0, 0, 0, 0.3),rgba(0, 0, 0, 0.3)),url('+category.thumb+');'"> <span v-if="post.type == 'video'" class="float-right mr-3 post-icon"><i class="fas fa-video fa-2x"></i></span>
<p class="text-white font-weight-bold" style="text-shadow: 3px 3px 16px #272634;">{{category.name}}</p> <span v-if="post.type == 'video:album'" class="float-right mr-3 post-icon"><i class="fas fa-film fa-2x"></i></span>
</a> <div class="square-content" v-bind:style="{ 'background-image': 'url(' + post.thumb + ')' }">
</div>
</section> </div>
<section class="mb-5 section-explore"> </a>
<div class="profile-timeline"> </div>
<div class="loader text-center"> </div>
<div class="lds-ring"><div></div><div></div><div></div><div></div></div> </div>
</div> </section>
<div class="row d-none"> <section class="mb-5">
<div class="col-4 p-0 p-sm-2 p-md-3" v-for="post in posts"> <p class="lead text-center">To view more posts, check the <a href="/" class="font-weight-bold">home</a> or <a href="/timeline/public" class="font-weight-bold">local</a> timelines.</p>
<a class="card info-overlay card-md-border-0" :href="post.url"> </section>
<div class="square"> </div>
<span v-if="post.type == 'photo:album'" class="float-right mr-3 post-icon"><i class="fas fa-images fa-2x"></i></span> </div>
<span v-if="post.type == 'video'" class="float-right mr-3 post-icon"><i class="fas fa-video fa-2x"></i></span>
<span v-if="post.type == 'video:album'" class="float-right mr-3 post-icon"><i class="fas fa-film fa-2x"></i></span>
<div class="square-content" v-bind:style="{ 'background-image': 'url(' + post.thumb + ')' }">
</div>
</div>
</a>
</div>
</div>
</div>
</section>
<section class="mb-5">
<p class="lead text-center">To view more posts, check the <a href="/" class="font-weight-bold">home</a> or <a href="/timeline/public" class="font-weight-bold">local</a> timelines.</p>
</section>
</div>
</template> </template>
<style type="text/css" scoped> <style type="text/css" scoped>
.discover-bar::-webkit-scrollbar { .discover-bar::-webkit-scrollbar {
display: none; display: none;
} }
.card-disc { .card-disc {
flex: 0 0 160px; flex: 0 0 160px;
width:160px; width:160px;
height:100px; height:100px;
background-size: cover !important; background-size: cover !important;
} }
.post-icon { .post-icon {
color: #fff; color: #fff;
position:relative; position:relative;
margin-top: 10px; margin-top: 10px;
z-index: 9; z-index: 9;
opacity: 0.6; opacity: 0.6;
text-shadow: 3px 3px 16px #272634; text-shadow: 3px 3px 16px #272634;
} }
</style> </style>
<script type="text/javascript"> <script type="text/javascript">
export default { export default {
data() { data() {
return { return {
config: window.App.config, loaded: false,
posts: {}, config: window.App.config,
trending: {}, posts: {},
categories: {}, trending: {},
allCategories: {}, categories: {},
} allCategories: {},
}, searchTerm: '',
mounted() { }
this.fetchData(); },
this.fetchCategories(); mounted() {
}, this.fetchData();
this.fetchCategories();
methods: {
followUser(id, event) {
axios.post('/i/follow', {
item: id
}).then(res => {
let el = $(event.target);
el.addClass('btn-outline-secondary').removeClass('btn-primary');
el.text('Unfollow');
}).catch(err => {
if(err.response.data.message) {
swal('Error', err.response.data.message, 'error');
}
});
},
fetchData() {
axios.get('/api/v2/discover/posts')
.then((res) => {
let data = res.data;
this.posts = data.posts;
if(this.posts.length > 1) {
$('.section-explore .loader').hide();
$('.section-explore .row.d-none').removeClass('d-none');
}
});
}, },
fetchCategories() { methods: {
axios.get('/api/v2/discover/categories') fetchData() {
.then(res => { axios.get('/api/v2/discover/posts')
this.allCategories = res.data; .then((res) => {
this.categories = res.data; this.posts = res.data.posts;
}); this.loaded = true;
}, });
},
fetchCategories() {
axios.get('/api/v2/discover/categories')
.then(res => {
this.allCategories = res.data;
this.categories = res.data;
});
},
searchSubmit() {
if(this.searchTerm.length > 1) {
window.location.href = '/i/results?q=' + this.searchTerm;
}
}
}
} }
}
</script> </script>