mirror of
https://github.com/shlinkio/shlink-web-client.git
synced 2025-01-03 23:07:26 +03:00
Created PaginationDropdown component
This commit is contained in:
parent
83704ca4b5
commit
c094a27c97
4 changed files with 38 additions and 5 deletions
|
@ -55,3 +55,7 @@ body,
|
||||||
.pagination .page-link {
|
.pagination .page-link {
|
||||||
cursor: pointer;
|
cursor: pointer;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.paddingless {
|
||||||
|
padding: 0;
|
||||||
|
}
|
||||||
|
|
33
src/utils/PaginationDropdown.js
Normal file
33
src/utils/PaginationDropdown.js
Normal file
|
@ -0,0 +1,33 @@
|
||||||
|
import React from 'react';
|
||||||
|
import { DropdownItem, DropdownMenu, DropdownToggle, UncontrolledDropdown } from 'reactstrap';
|
||||||
|
import * as PropTypes from 'prop-types';
|
||||||
|
|
||||||
|
const propTypes = {
|
||||||
|
toggleClassName: PropTypes.string,
|
||||||
|
ranges: PropTypes.arrayOf(PropTypes.number).isRequired,
|
||||||
|
value: PropTypes.number.isRequired,
|
||||||
|
setValue: PropTypes.func.isRequired,
|
||||||
|
};
|
||||||
|
|
||||||
|
const PaginationDropdown = ({ toggleClassName, ranges, value, setValue }) => (
|
||||||
|
<UncontrolledDropdown>
|
||||||
|
<DropdownToggle caret color="link" className={toggleClassName}>
|
||||||
|
Paginate
|
||||||
|
</DropdownToggle>
|
||||||
|
<DropdownMenu right>
|
||||||
|
{ranges.map((itemsPerPage) => (
|
||||||
|
<DropdownItem key={itemsPerPage} active={itemsPerPage === value} onClick={() => setValue(itemsPerPage)}>
|
||||||
|
<b>{itemsPerPage}</b> items per page
|
||||||
|
</DropdownItem>
|
||||||
|
))}
|
||||||
|
<DropdownItem divider />
|
||||||
|
<DropdownItem disabled={value === Infinity} onClick={() => setValue(Infinity)}>
|
||||||
|
<i>Clear pagination</i>
|
||||||
|
</DropdownItem>
|
||||||
|
</DropdownMenu>
|
||||||
|
</UncontrolledDropdown>
|
||||||
|
);
|
||||||
|
|
||||||
|
PaginationDropdown.propTypes = propTypes;
|
||||||
|
|
||||||
|
export default PaginationDropdown;
|
|
@ -33,7 +33,7 @@ const SortingDropdown = ({ items, orderField, orderDir, onChange, isButton, righ
|
||||||
<DropdownToggle
|
<DropdownToggle
|
||||||
caret
|
caret
|
||||||
color={isButton ? 'secondary' : 'link'}
|
color={isButton ? 'secondary' : 'link'}
|
||||||
className={classNames({ 'btn-block': isButton, 'btn-sm sorting-dropdown__paddingless': !isButton })}
|
className={classNames({ 'btn-block': isButton, 'btn-sm paddingless': !isButton })}
|
||||||
>
|
>
|
||||||
Order by
|
Order by
|
||||||
</DropdownToggle>
|
</DropdownToggle>
|
||||||
|
|
|
@ -10,7 +10,3 @@
|
||||||
margin: 3.5px 0 0;
|
margin: 3.5px 0 0;
|
||||||
float: right;
|
float: right;
|
||||||
}
|
}
|
||||||
|
|
||||||
.sorting-dropdown__paddingless.sorting-dropdown__paddingless {
|
|
||||||
padding: 0;
|
|
||||||
}
|
|
||||||
|
|
Loading…
Reference in a new issue