Paginate y SearchPlaceholder
This commit is contained in:
@@ -143,14 +143,14 @@ export default class Paginate extends Component {
|
|||||||
if (page === LEFT_PAGE) return (
|
if (page === LEFT_PAGE) return (
|
||||||
<li key={page} className="page-item">
|
<li key={page} className="page-item">
|
||||||
<a className="page-link" href={this.makePageLink(this.state.currentPage - 1)} onClick={this.handleMoveLeft}>
|
<a className="page-link" href={this.makePageLink(this.state.currentPage - 1)} onClick={this.handleMoveLeft}>
|
||||||
<span>« Anterior</span>
|
<span>«</span>
|
||||||
</a>
|
</a>
|
||||||
</li>
|
</li>
|
||||||
);
|
);
|
||||||
if (page === RIGHT_PAGE) return (
|
if (page === RIGHT_PAGE) return (
|
||||||
<li key={page} className="page-item">
|
<li key={page} className="page-item">
|
||||||
<a className="page-link" href={this.makePageLink(this.state.currentPage + 1)} onClick={this.handleMoveRight}>
|
<a className="page-link" href={this.makePageLink(this.state.currentPage + 1)} onClick={this.handleMoveRight}>
|
||||||
<span>Siguiente »</span>
|
<span>»</span>
|
||||||
</a>
|
</a>
|
||||||
</li>
|
</li>
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -7,6 +7,11 @@ import Paginate from "./Paginate";
|
|||||||
import {Link} from "react-router-dom";
|
import {Link} from "react-router-dom";
|
||||||
import {Tab, TabList, TabPanel, Tabs} from "react-tabs";
|
import {Tab, TabList, TabPanel, Tabs} from "react-tabs";
|
||||||
|
|
||||||
|
const SearchPlaceholder = () => (
|
||||||
|
<Fragment>
|
||||||
|
{[...Array(10)].map((e, i) => <li key={i} className='entity'/>)}
|
||||||
|
</Fragment>
|
||||||
|
)
|
||||||
|
|
||||||
class SearchArtist extends React.Component {
|
class SearchArtist extends React.Component {
|
||||||
render() {
|
render() {
|
||||||
@@ -32,8 +37,13 @@ class SearchArtists extends React.Component {
|
|||||||
|
|
||||||
componentDidUpdate = (prevProps, prevState) => {
|
componentDidUpdate = (prevProps, prevState) => {
|
||||||
if(prevProps.query !== this.props.query || prevState.page !== this.state.page) {
|
if(prevProps.query !== this.props.query || prevState.page !== this.state.page) {
|
||||||
this.setState({artists: null, paginate: null})
|
|
||||||
this.loadArtists(this.props.query, this.state.page)
|
this.loadArtists(this.props.query, this.state.page)
|
||||||
|
|
||||||
|
if(prevState.page !== this.state.page){
|
||||||
|
this.setState({artists: null})
|
||||||
|
}else{
|
||||||
|
this.setState({artists: null, paginate: null})
|
||||||
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -48,7 +58,6 @@ class SearchArtists extends React.Component {
|
|||||||
page = page ? page : 1;
|
page = page ? page : 1;
|
||||||
|
|
||||||
searchArtist(query, page).then((response) => {
|
searchArtist(query, page).then((response) => {
|
||||||
console.log(response);
|
|
||||||
this.setState({
|
this.setState({
|
||||||
artists: response.artists,
|
artists: response.artists,
|
||||||
paginate: response.paginate
|
paginate: response.paginate
|
||||||
@@ -57,7 +66,7 @@ class SearchArtists extends React.Component {
|
|||||||
};
|
};
|
||||||
|
|
||||||
render = () => {
|
render = () => {
|
||||||
let artists = <p>Cargando...</p>;
|
let artists = <SearchPlaceholder/>;
|
||||||
if(this.state.artists) {
|
if(this.state.artists) {
|
||||||
artists = this.state.artists.map((artist) => <SearchArtist key={artist.id} artist={artist}/>);
|
artists = this.state.artists.map((artist) => <SearchArtist key={artist.id} artist={artist}/>);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -61,7 +61,7 @@ h1, h2, h3, h4 {
|
|||||||
}
|
}
|
||||||
|
|
||||||
.nav .branding {
|
.nav .branding {
|
||||||
margin: 0;
|
margin: 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
.nav-links {
|
.nav-links {
|
||||||
@@ -89,6 +89,12 @@ ul.pagination {
|
|||||||
padding: 0 1rem;
|
padding: 0 1rem;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@media (max-width: 767px) {
|
||||||
|
.page-link {
|
||||||
|
padding: 0 .4rem;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
.page-item.active {
|
.page-item.active {
|
||||||
background-color: var(--accent);
|
background-color: var(--accent);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user