diff --git a/src/components/Info/Info.css b/src/components/Info/Info.css index 6f7500c..be32790 100644 --- a/src/components/Info/Info.css +++ b/src/components/Info/Info.css @@ -22,7 +22,6 @@ background: linear-gradient(180deg, white, transparent); height: 100%; padding: 1em; - padding-bottom: 6em; box-shadow: 0 -1px 11px 2px #6b6b6b52; } @@ -61,13 +60,27 @@ padding: 0; } -.info-list > div > i { +.info-list > .buttons > i { cursor: pointer; width: 100%; font-size: 1.5em; padding: 0.25em; } +.info-list > .buttons > i[data-set='true'] { + background-color: var(--light); + color: var(--main); +} + .info-list > div > i:hover { - background-color: #cccc; + /* background-color: #cccc; */ + color: var(--main); +} + +.info-data { + text-align: left; + font-size: 0.7em; + color: #6666; + padding: 0.1em 0 0 0.5em; + user-select: all; } diff --git a/src/components/Info/Info.js b/src/components/Info/Info.js index cb52b1e..c30325c 100644 --- a/src/components/Info/Info.js +++ b/src/components/Info/Info.js @@ -8,18 +8,35 @@ import './Info.css' function Info() { const { id } = useParams(), [track, setTrack] = useState({ - title: 'Tytuł', + title: '-', votes: {}, album: {}, - artists: ['Autor'], - }) + artists: ['-'], + }), + [meta, setMeta] = useState('...') useEffect(() => { - get(id).then((track) => { - setTrack(track) - }) + setMeta(`Pobieranie... ${id}`) + get(id) + .then((track) => { + setTrack(track) + setMeta(false) + }) + .catch((err) => { + setMeta(`Wystąpił błąd przy pobieraniu informacji o utworze`) + }) }, [id]) + function vote(value) { + track + .setVote(value) + .then((ok) => + ok + ? setMeta(`Zmieniono głos na ${{ up: '👎', down: '👍' }[value]}`) + : setMeta('Wystąpił bład przy zmienianiu głosu') + ) + } + const percent = (track.votes.up / (track.votes.up + track.votes.down)) * 100 document.title = `${track.title} | radio-rolnik` @@ -42,24 +59,64 @@ function Info() { {track.votes.down} -
-
- - + + {meta && {meta}} + + {track.id && ( +
+
+ vote('up')} + > + vote('down')} + > +
+
+ { + if (navigator.share) + navigator.share({ + url: track.share, + title: 'radio-rolnik', + text: `Sprawdź "${track.title}" na radio-rolnik`, + }) + }} + > + { + window.open(track.listen) + }} + > + { + let rly = window.confirm(`Napewno chcesz zgłosić ten utwór?`) + }} + > +
+
{`${track.title} - ${track.artists.join(', ')} - ${ + track.album.name ?? '-' + } (${track.album.year ?? '-'})`}
+
Liczba głosów: {track.votes.up + track.votes.down}
+
Miejsce: #{track.votes.rank}
+ {track.banned && ( +
+ + Utwór zablokowany + +
+ )}
-
- - - -
-
{`${track.title} - ${track.artists.join(', ')} - ${ - track.album.name - } (${track.album.year})`}
-
Liczba głosów: {track.votes.up + track.votes.down}
-
Miejsce: {track.votes.rank}
-
Zablokowane: {track.banned ? 'Tak' : 'Nie'}
-
+ )}
+ {id} ) }