From 8f9c4e7952c692d01fb691a030036a693a3252d5 Mon Sep 17 00:00:00 2001 From: Daniel Cortes Date: Fri, 19 Jun 2020 19:25:55 -0400 Subject: [PATCH] Issue #16: incluyendo ultimas paginas con grid --- src/index.jsx | 21 +++++---- src/services/utils.js | 4 ++ src/views/Disc.jsx | 10 ++-- src/views/Release.jsx | 45 +++++++++--------- src/views/Search.jsx | 106 +++++++++++++++++++----------------------- src/views/Song.jsx | 18 +++---- 6 files changed, 100 insertions(+), 104 deletions(-) diff --git a/src/index.jsx b/src/index.jsx index 512d059..cc17ff4 100644 --- a/src/index.jsx +++ b/src/index.jsx @@ -1,5 +1,5 @@ import {BrowserRouter, Switch, Route} from "react-router-dom"; -import React, {Fragment} from 'react'; +import React from 'react'; import ReactDOM from 'react-dom'; import './styles/reset.css'; @@ -16,25 +16,28 @@ import {DiscView} from "./views/Disc"; import {ReleaseView} from "./views/Release"; import {Recomended} from "./views/Recomended"; import {SongView} from "./views/Song"; +import {Grid, RowCol} from './components/Grid'; const Main = (props) => { const navigate = (query) => props.history.push(`/search?query=${query}`); return ( - -

Busca la musica que te gusta!

- - -
+ +

Busca la musica que te gusta!

+ + +
) } const NoRoute = (props) => { return ( -
-

Esa pagina no existe

+ +

Esa pagina no existe

+ -
+ + ); } diff --git a/src/services/utils.js b/src/services/utils.js index d9a5b1a..0ad803d 100644 --- a/src/services/utils.js +++ b/src/services/utils.js @@ -10,6 +10,10 @@ export const pad2 = (n) => { } export const toDuration = (miliseconds) => { + if(!miliseconds){ + return ''; + } + const base = Math.round(miliseconds / 1000); const hours = Math.floor(base / 3600); diff --git a/src/views/Disc.jsx b/src/views/Disc.jsx index 000157d..5b654b7 100644 --- a/src/views/Disc.jsx +++ b/src/views/Disc.jsx @@ -29,11 +29,11 @@ const Versions = (props) => { const items = versions.map((version) => { const cover = (); const subtitle = ( - - {version.date} - {version.country} - {capitalize(version.disambiguation)} - +
+
{version.date}
+
{version.country}
+
{capitalize(version.disambiguation)}
+
); return { diff --git a/src/views/Release.jsx b/src/views/Release.jsx index 6444830..59d0fce 100644 --- a/src/views/Release.jsx +++ b/src/views/Release.jsx @@ -1,4 +1,4 @@ -import React, {Fragment, useEffect, useState} from 'react'; +import React, {useEffect, useState} from 'react'; import {Link} from "react-router-dom"; import {capitalize, toDuration} from "../services/utils"; @@ -8,6 +8,7 @@ import {CoverArt} from "../components/CoverArt"; import {Entity} from "../components/Entity"; import {EntityList} from "../components/EntityList"; import {Comments} from "../components/Comments"; +import {Grid, RowCol} from "../components/Grid"; const Recordings = (props) => { @@ -28,10 +29,12 @@ const Recordings = (props) => { } for(const recording of media.recordings) { - const subtitle = - {recording.length &&
[{toDuration(recording.length)}]
} - {recording.disambiguation &&
{capitalize(recording.disambiguation)}
} -
+ const subtitle = ( +
+
[{toDuration(recording.length)}]
+
{capitalize(recording.disambiguation)}
+
+ ); group.items.push({ id: recording.id, @@ -44,15 +47,17 @@ const Recordings = (props) => { list.push(group); } - console.log(list) + mediasComponent = } return ( - -

Canciones

- {mediasComponent} -
+ + +

Canciones

+ {mediasComponent} +
+
) } @@ -64,11 +69,10 @@ const Release = (props) => { {`${release.artist.name} (${release.date})`} ) - return }/> - }else { - return + } else { + return null; } } @@ -89,13 +93,10 @@ export const ReleaseView = (props) => { }, [mbid]) return ( - - - {release && - - } - - + + + + + ) } diff --git a/src/views/Search.jsx b/src/views/Search.jsx index 6cfde70..2b71398 100644 --- a/src/views/Search.jsx +++ b/src/views/Search.jsx @@ -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 queryString from "query-string"; @@ -8,7 +8,7 @@ import {SearchBar} from "../components/SearchBar"; import {Paginate} from "../components/Paginate"; import {CoverArt} from "../components/CoverArt"; import {EntityList} from "../components/EntityList"; -import {Grid, Col, Row} from '../components/Grid'; +import {Grid, RowCol} from '../components/Grid'; const SearchSongs = (props) => { @@ -67,12 +67,14 @@ const SearchSongs = (props) => { } return ( - -
    - {songsComponent} -
- {paginateComponent} -
+ + +
    + {songsComponent} +
+
+ {paginateComponent} +
) } @@ -104,37 +106,39 @@ const SearchDiscs = (props) => { }) }; - let discsComponent = ; + let discsComponent = (); if (discs) { const items = discs.map((disc) => ({ - 'cover': , - 'link': `/disc/${disc.id}`, - 'title': disc.title, - 'subtitle': disc.artist.name - })); - const list = [{ - 'items': items - }] - discsComponent = -} + 'cover': (), + 'link': `/disc/${disc.id}`, + 'title': disc.title, + 'subtitle': disc.artist.name + })); + const list = [{ + 'items': items + }] + discsComponent = + } -let paginateComponent; -if (paginate) { - const total = paginate.total; - const currentPage = paginate.current_page; - const pageLimit = paginate.per_page; + let paginateComponent; + if (paginate) { + const total = paginate.total; + const currentPage = paginate.current_page; + const pageLimit = paginate.per_page; - paginateComponent = -} + paginateComponent = + } -return ( - -
    - {discsComponent} -
- {paginateComponent} -
-) + return ( + + +
    + {discsComponent} +
+
+ {paginateComponent} +
+ ) } const SearchArtists = (props) => { @@ -190,18 +194,12 @@ const SearchArtists = (props) => { return ( - - -
    - {artistsContent} -
- -
- - - {paginateContent} - - + +
    + {artistsContent} +
+
+ {paginateContent}
) } @@ -277,17 +275,11 @@ export const Search = (props) => { return ( -

Búsqueda

- - - - - - - - {content} - - +

Búsqueda

+ + + + {content}
); } diff --git a/src/views/Song.jsx b/src/views/Song.jsx index ea11af8..aa9648d 100644 --- a/src/views/Song.jsx +++ b/src/views/Song.jsx @@ -1,17 +1,16 @@ -import React, {Fragment, useEffect, useState} from 'react'; +import React, {useEffect, useState} from 'react'; import {capitalize, toDuration} from "../services/utils"; import {getSong} from "../services/entity_service"; import {Entity} from "../components/Entity"; import {Comments} from "../components/Comments"; +import {Grid, RowCol} from "../components/Grid"; const Song = (props) => { const song = props.song; - if(!song) { - return - } + if(!song) { return null} let subtitle = '' @@ -38,12 +37,9 @@ export const SongView = (props) => { }, [mbid]); return ( -
- - {song && - - } -
+ + + + ) - }