import React from 'react'; import styled from 'styled-components'; import { color, space, typography } from 'styled-system'; import { MaterialPlayArrow } from '@t3n/icons'; import Box from '../Box'; import Icon from '../Icon'; import Text from '../Text'; export interface LegacyPaginationProps { currentPage: number; totalPages: number; maxPageLinks: number; onClick: (currentPage: number) => void; } export interface LegacyPaginationContainerProps { disabled?: boolean; } const RotatedIcon = styled(Icon)` transform: rotate(180deg); `; const LegacyPaginationContainer = styled(Box)` height: 3.75rem; width: 3.75rem; display: flex; justify-content: center; align-content: center; align-items: center; ${({ theme }) => space({ theme, mr: '10px' })} ${({ theme, disabled }) => color({ theme, bg: 'shades.grey232', color: disabled ? 'text.secondary' : 'text.highlight', })} ${({ theme }) => typography({ theme, fontSize: 0 })} &:hover { ${({ theme, disabled }) => color({ theme, bg: disabled ? 'shades.grey232' : 'shades.grey204' })} cursor: ${({ disabled }) => (disabled ? 'default' : 'pointer')} } &:last-child { margin-right: 0; } `; const LegacyPaginationElipses = () => ( ... ); const LegacyPagination: React.FC = ({ currentPage, totalPages, maxPageLinks, onClick, }) => { const prevPage = currentPage - 1; return ( {currentPage !== 1 && ( onClick(currentPage - 1)}> )} {prevPage >= 1 && ( onClick(1)}> 1 )} {currentPage - maxPageLinks - 1 > 1 && } {currentPage === totalPages && maxPageLinks === 1 && totalPages > 3 && ( onClick(currentPage - maxPageLinks - 1)} > {currentPage - maxPageLinks - 1} )} {currentPage !== 1 && Array(maxPageLinks) .fill(null) .map((x, i) => { if (currentPage - (maxPageLinks - i) <= 1) { return null; } return ( onClick(currentPage - (maxPageLinks - i))} > {currentPage - (maxPageLinks - i)} ); })} {currentPage} {Array(maxPageLinks) .fill(null) .map((x, i) => { if (currentPage + (i + 1) >= totalPages) { return null; } return ( onClick(currentPage + (i + 1))} > {currentPage + (i + 1)} ); })} {currentPage === 1 && maxPageLinks === 1 && totalPages > 3 && ( onClick(currentPage + maxPageLinks + 1)} > {currentPage + maxPageLinks + 1} )} {currentPage + maxPageLinks + 1 < totalPages && ( )} {currentPage < totalPages && ( onClick(totalPages)}> {totalPages} )} {currentPage !== totalPages && ( onClick(currentPage + 1)}> )} ); }; export default LegacyPagination;