added dominant color to ListItem component
parent
815b1eb65a
commit
f63f0b41ac
|
|
@ -1,7 +1,7 @@
|
||||||
<template>
|
<template>
|
||||||
<li>
|
<li>
|
||||||
<div class="song">
|
<div class="song">
|
||||||
<img :src="item.artwork" alt="Artwork">
|
<img @load="onLoad" :src="item.artwork" alt="Artwork">
|
||||||
{{item.title}}
|
{{item.title}}
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|
@ -16,9 +16,21 @@
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
|
import color from 'dominant-color'
|
||||||
export default {
|
export default {
|
||||||
name: 'ListItem',
|
name: 'ListItem',
|
||||||
props: ['item']
|
props: ['item'],
|
||||||
|
|
||||||
|
methods: {
|
||||||
|
onLoad () {
|
||||||
|
let img = this.$el.getElementsByTagName('img')[0]
|
||||||
|
let list = this.$el.getElementsByTagName('li')[0]
|
||||||
|
|
||||||
|
color(img.src, {format: 'hex'}, (_, color) => {
|
||||||
|
list.style.backgroundColor = `#${color}`
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
|
@ -34,6 +46,12 @@ li
|
||||||
display: flex
|
display: flex
|
||||||
align-items: center
|
align-items: center
|
||||||
flex: 1 0 50%
|
flex: 1 0 50%
|
||||||
|
|
||||||
|
img
|
||||||
|
width: 4rem
|
||||||
|
height: 4rem
|
||||||
|
margin-right: .6rem
|
||||||
|
border-radius: 50%
|
||||||
|
|
||||||
div.artist
|
div.artist
|
||||||
display: flex
|
display: flex
|
||||||
|
|
@ -46,10 +64,5 @@ li
|
||||||
justify-content: center
|
justify-content: center
|
||||||
flex: 1 0 15%
|
flex: 1 0 15%
|
||||||
|
|
||||||
img
|
|
||||||
width: 4rem
|
|
||||||
height: 4rem
|
|
||||||
margin-right: .6rem
|
|
||||||
border-radius: 10rem
|
|
||||||
</style>
|
</style>
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue