2019-12-14 23:39:40 -05:00
|
|
|
import React, { useState, useEffect } from 'react'
|
|
|
|
import './Artist.scss'
|
|
|
|
|
|
|
|
const star = (
|
|
|
|
<svg width="497" height="473" viewBox="0 0 512 512" xmlns="http://www.w3.org/2000/svg">
|
|
|
|
<g>
|
|
|
|
<title>Layer 1</title>
|
|
|
|
<polygon stroke="#b6b6b6" points="248.63946533203125,2.5 309.48846435546875,177.55484008789062 494.77880859375,181.33078002929688 347.09527587890625,293.2965545654297 400.761962890625,470.68504333496094 248.63946533203125,364.82884216308594 96.51692199707031,470.68504333496094 150.18370056152344,293.2965545654297 2.5,181.33078002929688 187.7904052734375,177.55484008789062 248.63946533203125,2.5 309.48846435546875,177.55484008789062 " strokeWidth="20" strokecolor="#000000" fill="#d7d7d7" orient="point" r2="47.37444" r="118.43611" point="5" shape="star" id="svg_1" cy="137.5" cx="221"/>
|
|
|
|
</g>
|
|
|
|
</svg>
|
|
|
|
)
|
2019-12-14 18:05:19 -05:00
|
|
|
|
2019-12-15 18:49:30 -05:00
|
|
|
function Artist({ props, callback }) {
|
2019-12-14 23:39:40 -05:00
|
|
|
let [rate, setRate] = useState([])
|
|
|
|
|
|
|
|
useEffect(() => {
|
|
|
|
let stars = []
|
2019-12-16 18:38:48 -05:00
|
|
|
for (let i=0; i<Math.ceil(props.popularity/20); i++) {
|
2019-12-14 23:39:40 -05:00
|
|
|
stars.push(star)
|
|
|
|
}
|
|
|
|
|
|
|
|
setRate(stars)
|
|
|
|
}, [props])
|
|
|
|
|
2019-12-15 18:49:30 -05:00
|
|
|
const openAlbums = () => {
|
|
|
|
callback(props.id)
|
|
|
|
}
|
|
|
|
|
2019-12-14 18:05:19 -05:00
|
|
|
return (
|
2019-12-15 18:49:30 -05:00
|
|
|
<div className='artist' onClick={openAlbums}>
|
2019-12-14 23:39:40 -05:00
|
|
|
<div className='picture'>
|
|
|
|
{props.images.length > 0 && (
|
|
|
|
<img src={props.images[0].url} />
|
|
|
|
)}
|
|
|
|
</div>
|
|
|
|
|
|
|
|
<div className='details'>
|
|
|
|
<div className='text'>
|
|
|
|
<h2>{props.name}</h2>
|
|
|
|
<p>{props.followers.total.toLocaleString()} followers</p>
|
|
|
|
</div>
|
|
|
|
|
|
|
|
<div className='rate'>
|
2019-12-15 18:49:30 -05:00
|
|
|
<ul>
|
|
|
|
{rate.map((point, index) => (
|
|
|
|
<li key={index}>
|
|
|
|
{point}
|
|
|
|
</li>
|
|
|
|
))}
|
|
|
|
</ul>
|
2019-12-14 23:39:40 -05:00
|
|
|
</div>
|
|
|
|
|
|
|
|
</div>
|
|
|
|
|
2019-12-14 18:05:19 -05:00
|
|
|
</div>
|
|
|
|
)
|
|
|
|
}
|
|
|
|
|
|
|
|
export default Artist
|