Files
zoff/frontend/components/playlist/Song.vue
Kasper Rynning-Tønnesen 4aa216947a playlist
2019-11-16 23:04:35 +01:00

136 lines
2.7 KiB
Vue
Raw Permalink Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<template>
<div class="song-container">
<div
class="song-voteable-container"
@click="clickedSong"
@contextmenu="$emit('contextmenu', $event, id)"
>
<div class="song-thumbnail">
<img :src="thumbnail" :alt="title" />
<span class="song-duration">{{ durationInString }}</span>
</div>
<div class="song-info">
<div class="song-title">{{ title }}</div>
<div class="song-votes">{{ votes }} vote{{votes > 1 || votes == 0 ? "s" : null }}</div>
</div>
</div>
</div>
</template>
<script>
import ContextMenu from "@/components/playlist/ContextMenu";
export default {
components: {
ContextMenu
},
props: {
id: {
required: true,
type: String
},
thumbnail: {
required: true,
type: String
},
title: {
required: true,
type: String
},
votes: {
required: true,
type: Number
},
addedBy: {
required: true,
type: String
},
type: {
required: true,
type: String
},
duration: {
required: true,
type: Number
}
},
data() {
return {
contextMenuOpen: false,
mouseX: 0,
mouseY: 0
};
},
computed: {
durationInString: function() {
let time = this.duration;
let minutes = Math.floor(time / 60);
time = time - minutes * 60;
let minutesString = (minutes + "").padStart(2, "0");
let secondString = (time + "").padStart(2, "0");
return `${minutesString}:${secondString}`;
}
},
methods: {
clickedSong: function() {
console.log("Clicked on song with info", this.title, this.id);
}
}
};
</script>
<style scoped lang="scss">
.song-container {
display: flex;
flex-direction: row;
color: white;
.song-voteable-container {
width: 75%;
display: flex;
& .song-votes {
color: lightgrey;
}
& .song-thumbnail {
width: 25%;
position: relative;
& img {
width: 100%;
height: 100%;
border-top-left-radius: 7.5px;
border-bottom-left-radius: 7.5px;
}
& .song-duration {
position: absolute;
bottom: 5px;
left: 0px;
border-top-left-radius: 4px;
border-top-right-radius: 4px;
border-bottom-left-radius: 5px;
padding: 0 5px;
background: #000000A0;
color:white;
}
}
& .song-info {
width: 100%;
padding-left: 10px;
display: flex;
justify-content: space-evenly;
flex-direction: column;
}
}
& .song-mutation {
width: 25%;
display: flex;
align-items: center;
justify-content: center;
}
}
</style>