Issue #16: Grid en search y recomended

This commit is contained in:
Daniel Cortes
2020-06-19 14:04:04 -04:00
parent 3bf86c74da
commit 8ed4ad16e1
7 changed files with 258 additions and 229 deletions

15
src/components/Grid.jsx Normal file
View File

@@ -0,0 +1,15 @@
import React from 'react';
import './Grid.scss';
export const Col = (props) => {
return <div className="col">{props.children}</div>
}
export const Row = (props) => {
return <div className="row">{props.children}</div>
}
export const Grid = (props) => {
return <div className="grid">{props.children}</div>
}

View File

@@ -1,5 +1,5 @@
.grid { .grid {
--gutter: 1em; --gutter: 1rem;
width: 100%; width: 100%;
.row { .row {

View File

@@ -1,7 +1,4 @@
.searchbar { .searchbar {
margin-bottom: 2em;
margin-top: 1em;
input { input {
border: var(--line-width) solid var(--accent); border: var(--line-width) solid var(--accent);
border-right: none; border-right: none;

View File

@@ -4,7 +4,6 @@ import ReactDOM from 'react-dom';
import './styles/reset.css'; import './styles/reset.css';
import './styles/main.scss'; import './styles/main.scss';
import './styles/grid.scss';
import './styles/tabs.scss'; import './styles/tabs.scss';
import {Nav} from "./components/Nav"; import {Nav} from "./components/Nav";

View File

@@ -2,10 +2,10 @@ ul.tabs {
display: flex; display: flex;
align-items: stretch; align-items: stretch;
border-bottom: var(--line-width) var(--gray-1) solid; border-bottom: var(--line-width) var(--gray-1) solid;
margin: 1rem 0; margin-top: 1em;
li.tab { li.tab {
padding: .5rem 1em; padding: .5em 1em;
margin-bottom: -2px; margin-bottom: -2px;
cursor: pointer; cursor: pointer;

View File

@@ -5,6 +5,7 @@ import {getArtist, getDisc, getSong} from '../services/entity_service';
import {EntityList} from '../components/EntityList'; import {EntityList} from '../components/EntityList';
import {CoverArt} from '../components/CoverArt'; import {CoverArt} from '../components/CoverArt';
import {Grid, Row, Col} from '../components/Grid';
const PopularArtists = () => { const PopularArtists = () => {
const artistIDs = ['fa3b825f-7c85-4377-b393-d28a2016e293', 'b2d122f9-eadb-4930-a196-8f221eeb0c66', const artistIDs = ['fa3b825f-7c85-4377-b393-d28a2016e293', 'b2d122f9-eadb-4930-a196-8f221eeb0c66',
@@ -91,23 +92,23 @@ export const Recomended = () => {
// TODO crear una forma de obtener cosas populares // TODO crear una forma de obtener cosas populares
// Esto es un por mientras hago todo el resto y la pagina de inicio no se vea tan vacia // Esto es un por mientras hago todo el resto y la pagina de inicio no se vea tan vacia
return ( return (
<div class='grid'> <Grid>
<div class='row'> <Row>
<div class='col'> <Col>
<h3>Artistas Populares</h3> <h3>Artistas Populares</h3>
<PopularArtists/> <PopularArtists/>
</div> </Col>
<div class='col'> <Col>
<h3>Canciones Populares</h3> <h3>Canciones Populares</h3>
<PopularSongs/> <PopularSongs/>
</div> </Col>
</div> </Row>
<div className="row"> <Row>
<div className="col"> <Col>
<h3>Discos Populares</h3> <h3>Discos Populares</h3>
<PopularDiscs/> <PopularDiscs/>
</div> </Col>
</div> </Row>
</div> </Grid>
) )
} }

View File

@@ -8,6 +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';
const SearchSongs = (props) => { const SearchSongs = (props) => {
@@ -115,25 +116,25 @@ const SearchDiscs = (props) => {
'items': items 'items': items
}] }]
discsComponent = <EntityList list={list} grid={true}/> discsComponent = <EntityList list={list} grid={true}/>
} }
let paginateComponent; let paginateComponent;
if (paginate) { if (paginate) {
const total = paginate.total; const total = paginate.total;
const currentPage = paginate.current_page; const currentPage = paginate.current_page;
const pageLimit = paginate.per_page; const pageLimit = paginate.per_page;
paginateComponent = <Paginate totalRecords={total} pageLimit={pageLimit} currentPage={currentPage} pageNeighbours={2} onPageChanged={handlePageChange} makeLink={makeLink}/> paginateComponent = <Paginate totalRecords={total} pageLimit={pageLimit} currentPage={currentPage} pageNeighbours={2} onPageChanged={handlePageChange} makeLink={makeLink}/>
} }
return ( return (
<Fragment> <Fragment>
<ul className='entity_list'> <ul className='entity_list'>
{discsComponent} {discsComponent}
</ul> </ul>
{paginateComponent} {paginateComponent}
</Fragment> </Fragment>
) )
} }
const SearchArtists = (props) => { const SearchArtists = (props) => {
@@ -188,12 +189,20 @@ const SearchArtists = (props) => {
} }
return ( return (
<Fragment> <Grid>
<Row>
<Col>
<ul className='entity_list'> <ul className='entity_list'>
{artistsContent} {artistsContent}
</ul> </ul>
</Col>
</Row>
<Row>
<Col>
{paginateContent} {paginateContent}
</Fragment> </Col>
</Row>
</Grid>
) )
} }
@@ -258,19 +267,27 @@ export const Search = (props) => {
navigateTo(who, query, page); navigateTo(who, query, page);
}; };
const content = _ => { const content = (() => {
if (query) { if (query) {
return <SearchTabs query={query} onTabChanged={handleTabChange} onPageChange={handlePageChange} selected={who} page={page}/> return <SearchTabs query={query} onTabChanged={handleTabChange} onPageChange={handlePageChange} selected={who} page={page}/>
} else { } else {
return null; return null;
} }
} })();
return ( return (
<Fragment> <Grid>
<h1>Búsqueda</h1> <Row><Col><h1>Búsqueda</h1></Col></Row>
<Row>
<Col>
<SearchBar query={query} onQueryChanged={handleQueryChange} history={props.history}/> <SearchBar query={query} onQueryChanged={handleQueryChange} history={props.history}/>
{content()} </Col>
</Fragment> </Row>
<Row>
<Col>
{content}
</Col>
</Row>
</Grid>
); );
} }