mirror of
https://github.com/Stremio/stremio-web.git
synced 2026-04-21 07:32:02 +00:00
library pagination added
This commit is contained in:
parent
e0707d6bd2
commit
b235cfc835
4 changed files with 74 additions and 5 deletions
|
|
@ -4,7 +4,7 @@ const React = require('react');
|
||||||
const PropTypes = require('prop-types');
|
const PropTypes = require('prop-types');
|
||||||
const classnames = require('classnames');
|
const classnames = require('classnames');
|
||||||
const NotFound = require('stremio/routes/NotFound');
|
const NotFound = require('stremio/routes/NotFound');
|
||||||
const { Button, Multiselect, MainNavBars, LibItem, Image, useProfile, routesRegexp } = require('stremio/common');
|
const { Button, Multiselect, MainNavBars, LibItem, Image, PaginationInput, useProfile, routesRegexp } = require('stremio/common');
|
||||||
const useLibrary = require('./useLibrary');
|
const useLibrary = require('./useLibrary');
|
||||||
const useSelectableInputs = require('./useSelectableInputs');
|
const useSelectableInputs = require('./useSelectableInputs');
|
||||||
const styles = require('./styles');
|
const styles = require('./styles');
|
||||||
|
|
@ -12,7 +12,7 @@ const styles = require('./styles');
|
||||||
const Library = ({ model, urlParams, queryParams }) => {
|
const Library = ({ model, urlParams, queryParams }) => {
|
||||||
const profile = useProfile();
|
const profile = useProfile();
|
||||||
const library = useLibrary(model, urlParams, queryParams);
|
const library = useLibrary(model, urlParams, queryParams);
|
||||||
const [typeSelect, sortSelect] = useSelectableInputs(library);
|
const [typeSelect, sortSelect, paginationInput] = useSelectableInputs(library);
|
||||||
return (
|
return (
|
||||||
<MainNavBars className={styles['library-container']} route={model}>
|
<MainNavBars className={styles['library-container']} route={model}>
|
||||||
<div className={styles['library-content']}>
|
<div className={styles['library-content']}>
|
||||||
|
|
@ -21,6 +21,13 @@ const Library = ({ model, urlParams, queryParams }) => {
|
||||||
<div className={styles['selectable-inputs-container']}>
|
<div className={styles['selectable-inputs-container']}>
|
||||||
<Multiselect {...typeSelect} className={styles['select-input-container']} />
|
<Multiselect {...typeSelect} className={styles['select-input-container']} />
|
||||||
<Multiselect {...sortSelect} className={styles['select-input-container']} />
|
<Multiselect {...sortSelect} className={styles['select-input-container']} />
|
||||||
|
<div className={styles['spacing']} />
|
||||||
|
{
|
||||||
|
paginationInput !== null ?
|
||||||
|
<PaginationInput {...paginationInput} className={styles['pagination-input']} />
|
||||||
|
:
|
||||||
|
<PaginationInput label={'1'} className={classnames(styles['pagination-input'], styles['pagination-input-placeholder'])} />
|
||||||
|
}
|
||||||
</div>
|
</div>
|
||||||
:
|
:
|
||||||
null
|
null
|
||||||
|
|
|
||||||
|
|
@ -7,6 +7,13 @@
|
||||||
multiselect-menu-container: menu-container;
|
multiselect-menu-container: menu-container;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
:import('~stremio/common/PaginationInput/styles.less') {
|
||||||
|
pagination-prev-button-container: prev-button-container;
|
||||||
|
pagination-next-button-container: next-button-container;
|
||||||
|
pagination-button-icon: icon;
|
||||||
|
pagination-label: label;
|
||||||
|
}
|
||||||
|
|
||||||
.library-container {
|
.library-container {
|
||||||
width: 100%;
|
width: 100%;
|
||||||
height: 100%;
|
height: 100%;
|
||||||
|
|
@ -41,6 +48,44 @@
|
||||||
overflow: auto;
|
overflow: auto;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.spacing {
|
||||||
|
flex: 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
.pagination-input {
|
||||||
|
flex: none;
|
||||||
|
height: 3.5rem;
|
||||||
|
margin-left: 1.5rem;
|
||||||
|
|
||||||
|
&.pagination-input-placeholder {
|
||||||
|
pointer-events: none;
|
||||||
|
|
||||||
|
.pagination-prev-button-container, .pagination-next-button-container {
|
||||||
|
.pagination-button-icon {
|
||||||
|
fill: @color-surface-dark5-90;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
.pagination-label {
|
||||||
|
color: @color-surface-dark5-90;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
.pagination-prev-button-container, .pagination-next-button-container {
|
||||||
|
width: 3.5rem;
|
||||||
|
height: 3.5rem;
|
||||||
|
|
||||||
|
.pagination-button-icon {
|
||||||
|
width: 1rem;
|
||||||
|
height: 1rem;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
.pagination-label {
|
||||||
|
width: 3rem;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
.message-container {
|
.message-container {
|
||||||
|
|
|
||||||
|
|
@ -7,7 +7,9 @@ const init = () => ({
|
||||||
selected: null,
|
selected: null,
|
||||||
selectable: {
|
selectable: {
|
||||||
types: [],
|
types: [],
|
||||||
sorts: []
|
sorts: [],
|
||||||
|
prevPage: null,
|
||||||
|
nextPage: null
|
||||||
},
|
},
|
||||||
catalog: []
|
catalog: []
|
||||||
});
|
});
|
||||||
|
|
@ -20,7 +22,8 @@ const useLibrary = (model, urlParams, queryParams) => {
|
||||||
args: {
|
args: {
|
||||||
request: {
|
request: {
|
||||||
type: typeof urlParams.type === 'string' ? urlParams.type : null,
|
type: typeof urlParams.type === 'string' ? urlParams.type : null,
|
||||||
sort: queryParams.has('sort') ? queryParams.get('sort') : undefined
|
sort: queryParams.has('sort') ? queryParams.get('sort') : undefined,
|
||||||
|
page: queryParams.has('page') ? parseInt(queryParams.get('page'), 10) : 1
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -31,7 +31,21 @@ const mapSelectableInputs = (library) => {
|
||||||
window.location = event.value;
|
window.location = event.value;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
return [typeSelect, sortSelect];
|
const paginationInput = library.selectable.prevPage || library.selectable.nextPage ?
|
||||||
|
{
|
||||||
|
label: library.selected.request.page.toString(),
|
||||||
|
onSelect: (event) => {
|
||||||
|
if (event.value === 'prev' && library.selectable.prevPage) {
|
||||||
|
window.location = library.selectable.prevPage.deepLinks.library;
|
||||||
|
}
|
||||||
|
if (event.value === 'next' && library.selectable.nextPage) {
|
||||||
|
window.location = library.selectable.nextPage.deepLinks.library;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
:
|
||||||
|
null;
|
||||||
|
return [typeSelect, sortSelect, paginationInput];
|
||||||
};
|
};
|
||||||
|
|
||||||
const useSelectableInputs = (library) => {
|
const useSelectableInputs = (library) => {
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue