Issue #16: incluyendo ultimas paginas con grid

This commit is contained in:
Daniel Cortes
2020-06-19 19:25:55 -04:00
parent cf7b968911
commit 8f9c4e7952
6 changed files with 100 additions and 104 deletions

View File

@@ -1,5 +1,5 @@
import {BrowserRouter, Switch, Route} from "react-router-dom"; import {BrowserRouter, Switch, Route} from "react-router-dom";
import React, {Fragment} from 'react'; import React from 'react';
import ReactDOM from 'react-dom'; import ReactDOM from 'react-dom';
import './styles/reset.css'; import './styles/reset.css';
@@ -16,25 +16,28 @@ import {DiscView} from "./views/Disc";
import {ReleaseView} from "./views/Release"; import {ReleaseView} from "./views/Release";
import {Recomended} from "./views/Recomended"; import {Recomended} from "./views/Recomended";
import {SongView} from "./views/Song"; import {SongView} from "./views/Song";
import {Grid, RowCol} from './components/Grid';
const Main = (props) => { const Main = (props) => {
const navigate = (query) => props.history.push(`/search?query=${query}`); const navigate = (query) => props.history.push(`/search?query=${query}`);
return ( return (
<Fragment> <Grid>
<h1>Busca la musica que te gusta!</h1> <RowCol><h1>Busca la musica que te gusta!</h1></RowCol>
<SearchBar history={props.history} onQueryChanged={navigate}/> <RowCol><SearchBar history={props.history} onQueryChanged={navigate}/></RowCol>
<Recomended/> <RowCol><Recomended/></RowCol>
</Fragment> </Grid>
) )
} }
const NoRoute = (props) => { const NoRoute = (props) => {
return ( return (
<div> <Grid>
<h1>Esa pagina no existe</h1> <RowCol><h1>Esa pagina no existe</h1></RowCol>
<RowCol>
<button className='link' onClick={() => props.history.goBack()}>Volver</button> <button className='link' onClick={() => props.history.goBack()}>Volver</button>
</div> </RowCol>
</Grid>
); );
} }

View File

@@ -10,6 +10,10 @@ export const pad2 = (n) => {
} }
export const toDuration = (miliseconds) => { export const toDuration = (miliseconds) => {
if(!miliseconds){
return '';
}
const base = Math.round(miliseconds / 1000); const base = Math.round(miliseconds / 1000);
const hours = Math.floor(base / 3600); const hours = Math.floor(base / 3600);

View File

@@ -29,11 +29,11 @@ const Versions = (props) => {
const items = versions.map((version) => { const items = versions.map((version) => {
const cover = (<CoverArt release={version} size={3}/>); const cover = (<CoverArt release={version} size={3}/>);
const subtitle = ( const subtitle = (
<Grid> <div>
<RowCol><span>{version.date}</span></RowCol> <div>{version.date}</div>
<RowCol><span>{version.country}</span></RowCol> <div>{version.country}</div>
<RowCol><span>{capitalize(version.disambiguation)}</span></RowCol> <div>{capitalize(version.disambiguation)}</div>
</Grid> </div>
); );
return { return {

View File

@@ -1,4 +1,4 @@
import React, {Fragment, useEffect, useState} from 'react'; import React, {useEffect, useState} from 'react';
import {Link} from "react-router-dom"; import {Link} from "react-router-dom";
import {capitalize, toDuration} from "../services/utils"; import {capitalize, toDuration} from "../services/utils";
@@ -8,6 +8,7 @@ import {CoverArt} from "../components/CoverArt";
import {Entity} from "../components/Entity"; import {Entity} from "../components/Entity";
import {EntityList} from "../components/EntityList"; import {EntityList} from "../components/EntityList";
import {Comments} from "../components/Comments"; import {Comments} from "../components/Comments";
import {Grid, RowCol} from "../components/Grid";
const Recordings = (props) => { const Recordings = (props) => {
@@ -28,10 +29,12 @@ const Recordings = (props) => {
} }
for(const recording of media.recordings) { for(const recording of media.recordings) {
const subtitle = <Fragment> const subtitle = (
{recording.length &&<div>[{toDuration(recording.length)}]</div>} <div>
{recording.disambiguation && <div>{capitalize(recording.disambiguation)}</div>} <div>[{toDuration(recording.length)}]</div>
</Fragment> <div>{capitalize(recording.disambiguation)}</div>
</div>
);
group.items.push({ group.items.push({
id: recording.id, id: recording.id,
@@ -44,15 +47,17 @@ const Recordings = (props) => {
list.push(group); list.push(group);
} }
console.log(list)
mediasComponent = <EntityList list={list}/> mediasComponent = <EntityList list={list}/>
} }
return ( return (
<Fragment> <Grid>
<RowCol>
<h2>Canciones</h2> <h2>Canciones</h2>
{mediasComponent} {mediasComponent}
</Fragment> </RowCol>
</Grid>
) )
} }
@@ -64,11 +69,10 @@ const Release = (props) => {
{`${release.artist.name} (${release.date})`} {`${release.artist.name} (${release.date})`}
</Link> </Link>
) )
return <Entity title={release.title} return <Entity title={release.title} subtitle={subtitle}
subtitle={subtitle}
cover={<CoverArt release={release} popup={true} size={4}/>}/> cover={<CoverArt release={release} popup={true} size={4}/>}/>
} else { } else {
return <Fragment></Fragment> return null;
} }
} }
@@ -89,13 +93,10 @@ export const ReleaseView = (props) => {
}, [mbid]) }, [mbid])
return ( return (
<Fragment> <Grid>
<Release release={release}/> <RowCol><Release release={release}/></RowCol>
{release && <RowCol><Recordings render={release}medias={medias} selected={currentRecording}/></RowCol>
<Recordings medias={medias} <RowCol><Comments render={release}/></RowCol>
selected={currentRecording}/> </Grid>
}
<Comments/>
</Fragment>
) )
} }

View File

@@ -1,4 +1,4 @@
import React, {Fragment, useEffect, useState} from "react"; import React, {useEffect, useState} from "react";
import {Tab, TabList, TabPanel, Tabs} from "react-tabs"; import {Tab, TabList, TabPanel, Tabs} from "react-tabs";
import queryString from "query-string"; import queryString from "query-string";
@@ -8,7 +8,7 @@ import {SearchBar} from "../components/SearchBar";
import {Paginate} from "../components/Paginate"; import {Paginate} from "../components/Paginate";
import {CoverArt} from "../components/CoverArt"; import {CoverArt} from "../components/CoverArt";
import {EntityList} from "../components/EntityList"; import {EntityList} from "../components/EntityList";
import {Grid, Col, Row} from '../components/Grid'; import {Grid, RowCol} from '../components/Grid';
const SearchSongs = (props) => { const SearchSongs = (props) => {
@@ -67,12 +67,14 @@ const SearchSongs = (props) => {
} }
return ( return (
<Fragment> <Grid>
<RowCol>
<ul className='entity_list'> <ul className='entity_list'>
{songsComponent} {songsComponent}
</ul> </ul>
{paginateComponent} </RowCol>
</Fragment> <RowCol>{paginateComponent}</RowCol>
</Grid>
) )
} }
@@ -104,10 +106,10 @@ const SearchDiscs = (props) => {
}) })
}; };
let discsComponent = <EntityList placeholder={true} grid={true} size={16} cover={true}/>; let discsComponent = (<EntityList placeholder={true} grid={true} size={16} cover={true}/>);
if (discs) { if (discs) {
const items = discs.map((disc) => ({ const items = discs.map((disc) => ({
'cover': <CoverArt disc={disc} size={3}/>, 'cover': (<CoverArt disc={disc} size={3}/>),
'link': `/disc/${disc.id}`, 'link': `/disc/${disc.id}`,
'title': disc.title, 'title': disc.title,
'subtitle': disc.artist.name 'subtitle': disc.artist.name
@@ -128,12 +130,14 @@ if (paginate) {
} }
return ( return (
<Fragment> <Grid>
<RowCol>
<ul className='entity_list'> <ul className='entity_list'>
{discsComponent} {discsComponent}
</ul> </ul>
{paginateComponent} </RowCol>
</Fragment> <RowCol>{paginateComponent}</RowCol>
</Grid>
) )
} }
@@ -190,18 +194,12 @@ const SearchArtists = (props) => {
return ( return (
<Grid> <Grid>
<Row> <RowCol>
<Col>
<ul className='entity_list'> <ul className='entity_list'>
{artistsContent} {artistsContent}
</ul> </ul>
</Col> </RowCol>
</Row> <RowCol>{paginateContent}</RowCol>
<Row>
<Col>
{paginateContent}
</Col>
</Row>
</Grid> </Grid>
) )
} }
@@ -277,17 +275,11 @@ export const Search = (props) => {
return ( return (
<Grid> <Grid>
<Row><Col><h1>Búsqueda</h1></Col></Row> <RowCol><h1>Búsqueda</h1></RowCol>
<Row> <RowCol>
<Col>
<SearchBar query={query} onQueryChanged={handleQueryChange} history={props.history}/> <SearchBar query={query} onQueryChanged={handleQueryChange} history={props.history}/>
</Col> </RowCol>
</Row> <RowCol>{content}</RowCol>
<Row>
<Col>
{content}
</Col>
</Row>
</Grid> </Grid>
); );
} }

View File

@@ -1,17 +1,16 @@
import React, {Fragment, useEffect, useState} from 'react'; import React, {useEffect, useState} from 'react';
import {capitalize, toDuration} from "../services/utils"; import {capitalize, toDuration} from "../services/utils";
import {getSong} from "../services/entity_service"; import {getSong} from "../services/entity_service";
import {Entity} from "../components/Entity"; import {Entity} from "../components/Entity";
import {Comments} from "../components/Comments"; import {Comments} from "../components/Comments";
import {Grid, RowCol} from "../components/Grid";
const Song = (props) => { const Song = (props) => {
const song = props.song; const song = props.song;
if(!song) { if(!song) { return null}
return <Fragment/>
}
let subtitle = '' let subtitle = ''
@@ -38,12 +37,9 @@ export const SongView = (props) => {
}, [mbid]); }, [mbid]);
return ( return (
<div> <Grid>
<Song song={song}/> <RowCol><Song song={song}/></RowCol>
{song && <RowCol><Comments render={song}/></RowCol>
<Comments/> </Grid>
}
</div>
) )
} }