combine.fm/public/src/views/share.vue

145 lines
3.9 KiB
Vue
Raw Normal View History

<template>
<div class="container" v-if="item.name">
2017-10-24 13:01:34 +01:00
<social v-bind:name="item.name" v-bind:artist="item.artist.name" v-bind:url="`https://combine.fm/${item.service}/${item.type}/${item.externalId}`"></social>
<div class="share-heading">
<h3 class="title is-3">Matched {{ item.type === 'track' ? 'tracks' : 'albums' }} for</h3>
<h2 class="title is-2"><strong>{{ item.name }}</strong> - {{ item.artist.name }}</h2>
</div>
<ul class="columns is-multiline">
<li v-for="match in item.matches" class="column is-2">
<div v-if="match.externalId && match.id != 152">
2017-05-07 23:08:02 +01:00
<a v-bind:href="match.streamUrl"><div v-bind:style="{ backgroundImage: `url(${match.artworkLarge})` }" class="artwork" v-bind:class="{ 'artwork-youtube': match.service === 'youtube' }">
</div></a>
<div class='service-link has-text-centered'>
<a v-bind:href="match.streamUrl"><img v-bind:src="`/assets/images/${match.service}.png`" /></a>
</div>
</div>
<div v-if="match.matching || match.id === 152" class="service">
<div v-bind:style="{ backgroundImage: `url(${item.matches[0].artworkLarge})` }" class="artwork">
</div>
<div class='loading-wrap'>
<img src='/assets/images/eq.svg' class='loading' />
</div>
<div class='service-link has-text-centered'>
<img v-bind:src="`/assets/images/${match.service}.png`" />
</div>
</div>
<div class="service" v-if="!match.externalId && !match.matching">
<div v-bind:style="{ backgroundImage: `url(${item.matches[0].artworkLarge})` }" class="artwork not-found">
</div>
<div class='no-match'>
No Match
</div>
<div class='service-link has-text-centered not-found'>
<img v-bind:src="`/assets/images/${match.service}.png`" />
</div>
</div>
</li>
</ul>
</div>
</template>
<script>
2016-10-23 23:36:47 +01:00
import social from '../components/social.vue';
import { fetchItem } from '../store/api';
export default {
name: 'share-view',
2016-10-23 23:36:47 +01:00
components: { social },
data() {
return {
item: {},
};
},
created () {
// fetch the data when the view is created and the data is
// already being observed
this.fetch();
this.interval = setInterval(() => {
this.fetch();
2017-05-26 19:51:37 +01:00
}, 3000);
2016-10-24 00:18:36 +01:00
this.$store.state.share = true;
},
watch: {
// call again the method if the route changes
'$route': 'fetch',
},
methods: {
fetch () {
const item = this.$store.state.item;
const id = this.$route.params.id;
if (item && item.externalId === id && (typeof window === 'undefined' || !item.matches.some(match => match.matching))) {
this.item = this.$store.state.item;
2016-10-24 00:18:36 +01:00
} else if (id) {
fetchItem(this.$route.params.service, this.$route.params.type, id).then((res) => {
if(!res.body.matches.some(match => match.matching)) {
clearInterval(this.interval);
}
this.item = res.body;
2017-10-23 17:58:23 +01:00
document.title = `Combine.fm • ${this.item.name} by ${this.item.artist.name}`;
});
}
}
}
}
</script>
2018-04-28 20:56:20 +01:00
<style lang="scss">
2017-10-23 19:21:19 +01:00
.content ul {
margin-left: 0;
}
.share-heading {
margin-bottom: 50px
}
.share-heading .title {
color: #8396b0;
}
.share-heading .title strong {
color: #445470;
font-weight: 700;
}
.service {
2017-05-07 00:12:17 +01:00
position: relative;
margin-bottom: 10px;
}
.service-link img {
margin-top: 20px;
margin-bottom: 20px;
height: 40px;
}
img {
vertical-align: middle;
}
.not-found {
opacity: 0.2;
}
.match {
position: relative;
}
.no-match {
position: absolute;
top: 10px;
right: 10px;
background: #fff;
color: #FE4365;
padding: 3px 6px;
border-radius: 3px;
opacity: 0.7;
font-weight: bold;
}
.loading-wrap {
position: absolute;
top: 0;left: 0;
background: #fff;
height: 100%;
width: 100%;
opacity: 0.8;
}
.loading {
position: absolute;
top: 35%;
left: 40%;
width: 20%;
}
</style>