-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathreactstrap.js
68 lines (58 loc) · 1.7 KB
/
reactstrap.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
import React from 'react' // eslint-disable-line
import {
Pagination as BootstrapPagination,
PaginationItem,
PaginationLink,
} from 'reactstrap' // eslint-disable-line
import BasicPagination from './index'
import { omit } from './util'
const SPACER = '...'
const DEFAULT_CONTEXT = 2 // number of pages to show before and after current page.
const Pagination = props => {
const previous = _page => (
<PaginationItem key="previous">
<PaginationLink
role="button"
href={props.href(_page)}
onClick={props.onClick}
>Previous</PaginationLink>
</PaginationItem>
)
const next = _page => (
<PaginationItem key="next">
<PaginationLink
role="button"
href={props.href(_page)}
onClick={props.onClick}
>Next</PaginationLink>
</PaginationItem>
)
const spacer = _page => (
<PaginationItem key={_page}>
<PaginationLink>{SPACER}</PaginationLink>
</PaginationItem>
)
const item = (_page, active) => (
<PaginationItem active={active} key={_page}>
<PaginationLink
role="button"
href={props.href(_page)}
onClick={props.onClick}
>{_page}</PaginationLink>
</PaginationItem>
)
return (
<BasicPagination
previous={previous}
next={next}
item={item}
spacer={spacer}
wrapper={BootstrapPagination}
{...omit(props, ['href', 'onClick'])}
/>
)
}
Pagination.defaultProps = {
context: DEFAULT_CONTEXT,
}
export default Pagination