From 405b43bfb5b026c63bd158b9cb785bc73b543eb4 Mon Sep 17 00:00:00 2001 From: Daniel Cortes Date: Mon, 15 Jun 2020 03:22:21 -0400 Subject: [PATCH] Utilizando entity list en search --- src/components/EntityList.jsx | 28 ++++------- src/components/EntityList.scss | 5 +- src/components/Search.jsx | 90 +++++++++++----------------------- 3 files changed, 41 insertions(+), 82 deletions(-) diff --git a/src/components/EntityList.jsx b/src/components/EntityList.jsx index 32e089b..9fa9172 100644 --- a/src/components/EntityList.jsx +++ b/src/components/EntityList.jsx @@ -1,19 +1,14 @@ -import React, {Fragment, useEffect, useState} from "react"; +import React from "react"; import {Link} from "react-router-dom"; - -import {CoverArt} from "./CoverArt"; import "./EntityList.scss" -const EntityItem = (props) => { - const disc = { - 'id': '061f572e-7660-3c6b-b4cd-cf66d46da93c', - } +const Entity = (props) => { return (
  • {props.cover &&
    - + {props.cover}
    }
    @@ -26,18 +21,13 @@ const EntityItem = (props) => { } export const EntityList = (props) => { + const entities = props.items.map(item => ); + + const className = props.grid ? "grid" : "column"; return ( -
      - - - - - - - - - - +
        + {entities}
      ) } diff --git a/src/components/EntityList.scss b/src/components/EntityList.scss index 65e884c..63d5ea7 100644 --- a/src/components/EntityList.scss +++ b/src/components/EntityList.scss @@ -18,6 +18,9 @@ } .subtitle { font-size: .8em; + &:empty:before { + content: "\200b"; + } } } } @@ -33,7 +36,7 @@ display: flex; flex-direction: row; align-items: center; - padding: 1em 2em; + padding: 1em 1em; .body { display: flex; flex-direction: column; diff --git a/src/components/Search.jsx b/src/components/Search.jsx index 7579ae8..76b19d7 100644 --- a/src/components/Search.jsx +++ b/src/components/Search.jsx @@ -5,32 +5,9 @@ import {searchArtist, searchDisc, searchSong} from "../services/search_service"; import {SearchBar} from "./SearchBar"; import {Paginate} from "./Paginate"; import {CoverArt} from "./CoverArt"; -import {Link} from "react-router-dom"; +import {EntityList} from "./EntityList"; import {Tab, TabList, TabPanel, Tabs} from "react-tabs"; - -const SearchPlaceholder = (props) => { - return ( - - {[...Array(10)].map((e, i) =>
    • )} - - ) -} - -const SearchSong = (props) => { - const song = props.song; - return ( -
    • - -
      - {song.title} - {song.artist.name} -
      - -
    • - ) -} - const SearchSongs = (props) => { const [songs, setSongs] = useState(null); const [paginate, setPaginate] = useState(null); @@ -59,9 +36,18 @@ const SearchSongs = (props) => { }) }; - let songsComponent = ; + + let songsComponent = ; if (songs) { - songsComponent = songs.map((song) => ); + const items = songs.map((song) => { + return { + 'cover': null, + 'link': `/song/${song.id}`, + 'title': song.title, + 'subtitle': song.artist.name + }; + }); + songsComponent = } let paginateComponent; @@ -83,24 +69,6 @@ const SearchSongs = (props) => { ) } -const SearchDisc = (props) => { - const disc = props.disc; - - return ( -
    • - -
      - -
      -
      - {disc.title} - {/*{disc.artist[0].name}*/} -
      - -
    • - ) -} - const SearchDiscs = (props) => { const [discs, setDiscs] = useState(null); const [paginate, setPaginate] = useState(null); @@ -129,9 +97,15 @@ const SearchDiscs = (props) => { }) }; - let discsComponent = ; + let discsComponent = ; if (discs) { - discsComponent = discs.map((disc) => ); + const items = discs.map((disc) => ({ + 'cover': , + 'link': `/disc/${disc.id}`, + 'title': disc.title, + 'subtitle': disc.artist.name + })); + discsComponent = } let paginateComponent; @@ -153,20 +127,6 @@ const SearchDiscs = (props) => { ) } -const SearchArtist = (props) => { - const artist = props.artist; - return ( -
    • - - - {artist.name} - {[artist.type, artist.country].filter(Boolean).join(' - ')} - - -
    • - ) -} - const SearchArtists = (props) => { const [artists, setArtist] = useState(null); const [paginate, setPaginate] = useState(null); @@ -195,9 +155,15 @@ const SearchArtists = (props) => { }) }; - let artistsContent = ; + let artistsContent = ; if (artists) { - artistsContent = artists.map((artist) => ); + const items = artists.map((artist) => ({ + 'cover': null, + 'link': `/artist/${artist.id}`, + 'title': artist.name, + 'subtitle': [artist.type, artist.country].filter(Boolean).join(' - ') + })); + artistsContent = } let paginateContent;