forked from AdaGold/radio-lovelace
-
Notifications
You must be signed in to change notification settings - Fork 43
/
Copy pathTrack.js
51 lines (42 loc) · 1.36 KB
/
Track.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
import React from 'react'
import PropTypes from 'prop-types'
import "./styles/Track.css";
// Here we use destructuring to extract the props into separate variables
// See https://wesbos.com/destructuring-objects/
const Track = ({title, artist, playtime, albumart, favorite, index, id,toTopCallback,listSwitchCallback, listFavoriteCallback}) => {
return (
<li className="track">
<img className="track--albumart" alt={`album art for ${title}`} src={albumart} />
<h3 className="track--title">{title}</h3>
<input
type="checkbox"
className="track--favorite"
// checked={!favorite}
defaultChecked={!favorite}
onChange={listFavoriteCallback}
/>
<p className="track--artist">{artist}</p>
<p className="track--playtime">{playtime}</p>
<button
className="track--control track--to-top"
onClick ={toTopCallback}
>
<span role="img" aria-label="send to top">🔝</span>
</button>
<button
className="track--control track--switch"
onClick={listSwitchCallback}
>
<span role="img" aria-label="switch lists">↔</span>
</button>
</li>
);
};
Track.propTypes = {
title: PropTypes.string,
artist: PropTypes.string,
playtime: PropTypes.string,
albumart: PropTypes.string,
favorite: PropTypes.bool,
}
export default Track;