diff --git a/src/components/History/History.js b/src/components/History/History.js
index 3332e92..010b77a 100644
--- a/src/components/History/History.js
+++ b/src/components/History/History.js
@@ -6,17 +6,17 @@ import PlayingContext from '../../contexts/Playing'
import './History.css'
-function History(props) {
- let playing = useContext(PlayingContext)
+function History({ next, tracks }) {
+ const playing = useContext(PlayingContext)
return (
Następny:
-
+
Gra teraz:
Poprzednie:
- {props.tracks.map((track) => {
+ {tracks.map((track) => {
return
})}
diff --git a/src/components/Info/Info.js b/src/components/Info/Info.js
index b636a1b..6620333 100644
--- a/src/components/Info/Info.js
+++ b/src/components/Info/Info.js
@@ -5,10 +5,10 @@ import { get } from '../../Cache'
import './Info.css'
function Info() {
- let { id } = useParams(),
+ const { id } = useParams(),
track = get(id)
- let percent = (track.votes.up / (track.votes.up + track.votes.down)) * 100
+ const percent = (track.votes.up / (track.votes.up + track.votes.down)) * 100
document.title = `${track.title} | radio-rolnik`
diff --git a/src/components/Main/Main.js b/src/components/Main/Main.js
index b623d2b..6cea793 100644
--- a/src/components/Main/Main.js
+++ b/src/components/Main/Main.js
@@ -24,7 +24,7 @@ document.setTitle = (prefix, suffix) => {
}
function Main() {
- let [playing] = useState({
+ const [playing] = useState({
...get('2340q8ghedsnawg1'),
})
diff --git a/src/components/Nav/Nav.js b/src/components/Nav/Nav.js
index 1d06e01..a69bba0 100644
--- a/src/components/Nav/Nav.js
+++ b/src/components/Nav/Nav.js
@@ -2,25 +2,24 @@ import { useEffect, useState } from 'react'
import { Link } from 'react-router-dom'
import { useLocation } from 'react-router-dom'
-
import './Nav.css'
-function Button(props) {
+function Button({ to, onClick, active, icon, label }) {
return (
-
- {props.label}
+
+ {label}
)
}
-function Nav(props) {
+function Nav({ buttons }) {
function getTab() {
- return props.buttons
+ return buttons
.slice()
.reverse()
.find((button) =>
@@ -28,12 +27,12 @@ function Nav(props) {
).label
}
- let [current, setCurrent] = useState(getTab()),
+ const [current, setCurrent] = useState(getTab()),
location = useLocation()
useEffect(() => {
setCurrent(getTab())
- let label = (function () {
+ const label = (function () {
switch (current) {
default:
case 'History':
@@ -52,14 +51,14 @@ function Nav(props) {
return (
diff --git a/src/components/Search/Search.js b/src/components/Search/Search.js
index 38cb02c..35d59b3 100644
--- a/src/components/Search/Search.js
+++ b/src/components/Search/Search.js
@@ -7,9 +7,9 @@ import { search } from '../../Cache'
import './Search.css'
function Search(props) {
- let { query } = useParams(),
- [results, setResults] = useState([]),
- timeout
+ const { query } = useParams(),
+ [results, setResults] = useState([])
+ let timeout
document.setTitle(`"${query}"`)
@@ -17,7 +17,7 @@ function Search(props) {
return () => {
clearTimeout(timeout)
}
- }, [])
+ }, []) // eslint-disable-line react-hooks/exhaustive-deps
return (
diff --git a/src/components/Status/Status.js b/src/components/Status/Status.js
index ac4492d..e52cb7b 100644
--- a/src/components/Status/Status.js
+++ b/src/components/Status/Status.js
@@ -6,23 +6,32 @@ import PlayingContext from '../../contexts/Playing'
import './Status.css'
function Status(props) {
- let playing = useContext(PlayingContext),
+ const { id, album, title, duration, artists } = useContext(PlayingContext),
[progress, setProgress] = useState(0)
- let step = 1 / playing.duration
+ const step = 1 / duration
- useEffect(() => {
- let anim = setInterval(() => {
- setProgress((progress += step))
- if (progress >= 1) clearInterval(anim)
- }, 1e3)
- }, [])
+ useEffect(
+ (anim) => {
+ if (progress < 1) {
+ anim = setTimeout(() => {
+ setProgress(progress + step)
+ }, 1e3)
+ } else if (progress > 1) {
+ setProgress(1) // if FPU decides that 1 / duration * duration !== 1
+ }
+ return () => {
+ clearInterval(anim)
+ }
+ },
+ [progress, step]
+ )
return (
-
-

-
{playing.title}
-
{playing.artists.join(', ')}
+
+

+
{title}
+
{artists.join(', ')}
-
- {props.timestamp && (
-
{props.timestamp}
- )}
- {props.rank &&
{props.rank}}
+
+ {timestamp &&
{timestamp}}
+ {rank &&
{rank}}
-
- {props.title}
+
+ {title}
- {props.artists.join(', ')}
+ {artists.join(', ')}
@@ -45,7 +39,7 @@ function Track(props) {
-
+