minor fixes
This commit is contained in:
1 parent
16f3c27d99
commit
d4b22c1654
5 files changed
+40
-14
No files matched your search
+2
-2
@@ -26,7 +26,7 @@ var tracks = {
|
||||
art: '/media/default.png',
|
||||
year: '2020',
|
||||
},
|
||||
duration: 23231,
|
||||
duration: 156,
|
||||
explicit: true,
|
||||
banned: false,
|
||||
votes: {
|
||||
@@ -37,7 +37,7 @@ var tracks = {
|
||||
},
|
||||
}
|
||||
|
||||
var get = (id) => {
|
||||
function get(id) {
|
||||
return tracks[id]
|
||||
}
|
||||
|
||||
|
||||
@@ -1,14 +1,20 @@
|
||||
import { useContext } from 'react'
|
||||
|
||||
import Track from '../Track/Track'
|
||||
|
||||
import PlayingContext from '../../contexts/Playing'
|
||||
|
||||
import './History.css'
|
||||
|
||||
function History(props) {
|
||||
let playing = useContext(PlayingContext)
|
||||
|
||||
return (
|
||||
<div className="wrapper history">
|
||||
<span>Następny:</span>
|
||||
<Track {...props.next} timestamp=">" />
|
||||
<span>Gra teraz:</span>
|
||||
<Track {...props.playing} timestamp="~" />
|
||||
<Track {...playing} timestamp="~" />
|
||||
<span>Poprzednie:</span>
|
||||
{props.tracks.map((track) => {
|
||||
return <Track key={track.id} {...track} timestamp="14:33" />
|
||||
|
||||
@@ -4,6 +4,7 @@ import {
|
||||
Route,
|
||||
Redirect,
|
||||
} from 'react-router-dom'
|
||||
import { useEffect, useState } from 'react'
|
||||
|
||||
import Nav from '../Nav/Nav'
|
||||
import History from '../History/History'
|
||||
@@ -18,13 +19,23 @@ import PlayingContext from '../../contexts/Playing'
|
||||
|
||||
import './Main.css'
|
||||
|
||||
var playing = get('2340q8ghedsnawg1')
|
||||
|
||||
document.setTitle = (prefix, suffix) => {
|
||||
document.title = `${prefix} | ${suffix ?? 'radio-rolnik'}`
|
||||
}
|
||||
|
||||
function Main() {
|
||||
|
||||
let [playing, setPlaying] = useState({...get('2340q8ghedsnawg1'), progress: 0}),
|
||||
step = 1/playing.duration
|
||||
|
||||
useEffect(()=>{
|
||||
setInterval(()=> {
|
||||
console.log(playing.progress+=step)
|
||||
if(playing.progress >= 1) playing.progress = 0
|
||||
setPlaying({...playing })
|
||||
}, 1e3)
|
||||
}, [])
|
||||
|
||||
return (
|
||||
<PlayingContext.Provider value={playing}>
|
||||
<div className="main">
|
||||
@@ -33,19 +44,22 @@ function Main() {
|
||||
<Route exact path="/">
|
||||
<History
|
||||
next={get('8034thrgnu0380')}
|
||||
playing={playing}
|
||||
tracks={[get('2340q8ghedsnawg1'), get('8034thrgnu0380')]}
|
||||
/>
|
||||
</Route>
|
||||
|
||||
<Route path="/utwor/:id">
|
||||
<Info playing={playing} />
|
||||
<Info />
|
||||
</Route>
|
||||
|
||||
<Route path="/top">
|
||||
<Top tracks={[get('2340q8ghedsnawg1'), get('8034thrgnu0380')]} />
|
||||
</Route>
|
||||
|
||||
<Route path="/wyszukaj/:query?">
|
||||
<Search />
|
||||
</Route>
|
||||
|
||||
<Route render={() => <Redirect to="/" />} />
|
||||
</Switch>
|
||||
<Nav
|
||||
@@ -62,7 +76,7 @@ function Main() {
|
||||
{ label: 'Ustawienia', to: '/ustawienia', icon: 'cog-alt' },
|
||||
]}
|
||||
/>
|
||||
<Status track={playing} progress=".75" />
|
||||
<Status />
|
||||
</Router>
|
||||
</div>
|
||||
</PlayingContext.Provider>
|
||||
|
||||
@@ -45,7 +45,7 @@
|
||||
left: 1em;
|
||||
bottom: 0;
|
||||
border-bottom: 2px solid white;
|
||||
transition: 0.4s;
|
||||
transition: 1s linear;
|
||||
}
|
||||
|
||||
.status-progress:after {
|
||||
|
||||
@@ -1,20 +1,26 @@
|
||||
import { useContext } from 'react'
|
||||
import { Link } from 'react-router-dom'
|
||||
|
||||
import PlayingContext from '../../contexts/Playing'
|
||||
|
||||
import './Status.css'
|
||||
|
||||
function Status(props) {
|
||||
let playing = useContext(PlayingContext)
|
||||
|
||||
return (
|
||||
<Link className="status" to={`/utwor/${props.track.id}`}>
|
||||
<Link className="status" to={`/utwor/${playing.id}`}>
|
||||
<img
|
||||
className="status-image"
|
||||
alt="album cover"
|
||||
src={props.track.album.art}
|
||||
src={playing.album.art}
|
||||
/>
|
||||
<span className="status-track">{props.track.title}</span>
|
||||
<span className="status-artist">{props.track.artists.join(', ')}</span>
|
||||
<span className="status-track">{playing.title}</span>
|
||||
<span className="status-artist">{playing.artists.join(', ')}</span>
|
||||
<i className="icon-info"></i>
|
||||
<div
|
||||
className="status-progress"
|
||||
style={{ width: `calc(var(--max) * ${props.progress})` }}
|
||||
style={{ width: `calc(var(--max) * ${playing.progress})` }}
|
||||
></div>
|
||||
</Link>
|
||||
)
|
||||
|
||||
Reference in new issue
Block a user