pager update
This commit is contained in:
1 parent
5a3fc93c4f
commit
406c660f41
5 files changed
+37
-35
No files matched your search
@@ -1,5 +1,5 @@
|
|||||||
import Paginator from './Paginator'
|
|
||||||
import { ArticleCard } from './ArticleCard'
|
import { ArticleCard } from './ArticleCard'
|
||||||
|
import { Pager } from './Pager'
|
||||||
|
|
||||||
export interface IArticleCardListProps {
|
export interface IArticleCardListProps {
|
||||||
articles: any[]
|
articles: any[]
|
||||||
@@ -19,7 +19,7 @@ export const ArticleCardList:React.FC<IArticleCardListProps> = ({ articles, next
|
|||||||
`}</style>
|
`}</style>
|
||||||
|
|
||||||
{!prevPage ? null : (
|
{!prevPage ? null : (
|
||||||
<Paginator url={`/articles/${prevPage}`} type="top" />
|
<Pager url={`/articles/${prevPage}`} position={'top'} />
|
||||||
)}
|
)}
|
||||||
|
|
||||||
<div className={'body'}>
|
<div className={'body'}>
|
||||||
@@ -41,7 +41,7 @@ export const ArticleCardList:React.FC<IArticleCardListProps> = ({ articles, next
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
{!nextPage ? null : (
|
{!nextPage ? null : (
|
||||||
<Paginator url={`/articles/${nextPage}`} type="bottom" />
|
<Pager url={`/articles/${nextPage}`} position={'bottom'} />
|
||||||
)}
|
)}
|
||||||
</div>
|
</div>
|
||||||
)
|
)
|
||||||
@@ -0,0 +1,34 @@
|
|||||||
|
const text = ['↑', '↓']
|
||||||
|
const linkText = ['Предыдущая страница', 'Следующая страница']
|
||||||
|
|
||||||
|
type Position = 'top' | 'bottom'
|
||||||
|
const i = (type: Position) => type === 'top'
|
||||||
|
? 0
|
||||||
|
: 1
|
||||||
|
|
||||||
|
export type PagerProps = {
|
||||||
|
url: string
|
||||||
|
position: Position
|
||||||
|
}
|
||||||
|
|
||||||
|
export const Pager: React.FC<PagerProps> = ({ url, position }) => (
|
||||||
|
<div>
|
||||||
|
<style jsx>{`
|
||||||
|
div {
|
||||||
|
text-align: center;
|
||||||
|
margin-top: var(--size-m);
|
||||||
|
margin-bottom: var(--size-m);
|
||||||
|
}
|
||||||
|
|
||||||
|
span {
|
||||||
|
margin: 0 var(--size-s);
|
||||||
|
}
|
||||||
|
`}</style>
|
||||||
|
|
||||||
|
<span>
|
||||||
|
{text[i(position)]}
|
||||||
|
</span>
|
||||||
|
|
||||||
|
<a href={url}>{linkText[i(position)]}</a>
|
||||||
|
</div>
|
||||||
|
)
|
||||||
@@ -1,21 +0,0 @@
|
|||||||
const React = require('react')
|
|
||||||
|
|
||||||
const text = ['↑', '↓']
|
|
||||||
const linkText = ['Предыдущая страница', 'Следующая страница']
|
|
||||||
|
|
||||||
const i = type => type === 'top'
|
|
||||||
? 0
|
|
||||||
: 1
|
|
||||||
|
|
||||||
const Icon = ({children}) => (
|
|
||||||
<span className="Paginator-Icon">{children}</span>
|
|
||||||
)
|
|
||||||
|
|
||||||
const Paginator = ({url, type}) => (
|
|
||||||
<div className="Paginator">
|
|
||||||
<Icon>{text[i(type)]}</Icon>
|
|
||||||
<a href={url}>{linkText[i(type)]}</a>
|
|
||||||
</div>
|
|
||||||
)
|
|
||||||
|
|
||||||
module.exports = Paginator
|
|
||||||
@@ -1,10 +0,0 @@
|
|||||||
.Paginator {
|
|
||||||
text-align: center;
|
|
||||||
font-size: var(--font-size-second);
|
|
||||||
|
|
||||||
margin: var(--single-margin) 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
.Paginator-Icon {
|
|
||||||
margin: 0 10px;
|
|
||||||
}
|
|
||||||
@@ -6,7 +6,6 @@
|
|||||||
@import "components/schedule-table";
|
@import "components/schedule-table";
|
||||||
@import "components/footer-links";
|
@import "components/footer-links";
|
||||||
@import "components/Article";
|
@import "components/Article";
|
||||||
@import "components/Paginator";
|
|
||||||
@import "components/album";
|
@import "components/album";
|
||||||
@import "components/ArticleTags";
|
@import "components/ArticleTags";
|
||||||
|
|
||||||
|
|||||||
Reference in new issue
Block a user