Skip to content

Commit 183dfe0

Browse files
author
Maxim Komlev
committed
+ Pager control, actually it is not defined at matereal design but definitely it is helpful to have.
the control is based on react-toolbox controls and corresponds to matereal design. It is highly customisable and it follows default style patterns of react-toolbox components. actually what differentiate the control from others similar that it has always const set of buttons and the set depends on two properties: number of total pages (latsPage) and number of visible pages at block. e.g. [<][1][...][4][5][6][...][8][>] or [<][1][2][3][4][5][...][8][>] or [<][1][...][4][5][6][7][8][>] where block size is 3. it gives smooth user experience. A layouting is based on flex but easily can be rewritten using inline-block at custom theme. example is added to specs.
1 parent 7da10e9 commit 183dfe0

File tree

11 files changed

+597
-0
lines changed

11 files changed

+597
-0
lines changed

components/identifiers.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,3 +25,4 @@ export const TABLE = 'RTTable';
2525
export const TABS = 'RTTabs';
2626
export const TOOLTIP = 'RTTooltip';
2727
export const TIME_PICKER = 'RTTimePicker';
28+
export const PAGER = 'RTPager';

components/index.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,3 +28,4 @@ export Table from './table';
2828
export * from './tabs';
2929
export Tooltip from './tooltip';
3030
export TimePicker from './time_picker';
31+
export Pager from './pager';

components/pager/_config.scss

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
@import "../button/config";
2+
3+
$button-margin: 0rem .5rem 0rem 0rem !default;

components/pager/index.d.ts

Lines changed: 111 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,111 @@
1+
import * as React from "react";
2+
import ReactToolbox from "./index";
3+
4+
export interface PagerTheme {
5+
/**
6+
* Used for the root element.
7+
*/
8+
pager?: string;
9+
/**
10+
* Used for the active page.
11+
*/
12+
active?: string;
13+
/**
14+
* Used for the next and previous page buttons.
15+
*/
16+
leftRightArrowButton?: string;
17+
/**
18+
* Used for the next and previous range pages buttons.
19+
*/
20+
leftRightRangeButton?: string;
21+
/**
22+
* Used for the regular page buttons.
23+
*/
24+
pagesButton?: string;
25+
}
26+
27+
interface PagerProps extends ReactToolbox.Props {
28+
/**
29+
* Used for the previous button content.
30+
*/
31+
prevButtonContent?: string;
32+
/**
33+
* Used for the left range button content
34+
*/
35+
rangeLeftButtonContent?: string;
36+
/**
37+
* Used for the right range button content
38+
*/
39+
rangeRightButtonContent?: string;
40+
/**
41+
* Used for the next button content
42+
*/
43+
nextButtonContent?: string;
44+
/**
45+
* A Number with the currently selected page
46+
*/
47+
currentPage?: number;
48+
/**
49+
* A Number of last page.
50+
*/
51+
lastPage?: number;
52+
/**
53+
* A Number of pages visible in control except next, previous and ranges buttons, the minimum value is 2.
54+
*/
55+
visiblePagesBlockSize?: number;
56+
/**
57+
* Callback called when the page is changing.
58+
*/
59+
onPageChange?: Function;
60+
/**
61+
* Classnames object defining the component style.
62+
*/
63+
theme?: PagerTheme;
64+
/**
65+
* This class will be applied to the root elemt.
66+
*/
67+
pagerClassName?: string;
68+
/**
69+
* Defining default style of next, previous buttons.
70+
* it can have following styles:
71+
* accent,
72+
* flat,
73+
* inverse,
74+
* mini,
75+
* neutral,
76+
* primary,
77+
* raised,
78+
* toggle
79+
*/
80+
leftRightArrowButtonTypes?: object;
81+
/**
82+
* Defining default style of left, right range buttons.
83+
* it can have following styles:
84+
* accent,
85+
* flat,
86+
* inverse,
87+
* mini,
88+
* neutral,
89+
* primary,
90+
* raised,
91+
* toggle
92+
*/
93+
leftRightRangeButtonTypes?: object;
94+
/**
95+
* Defining default style of regular page buttons.
96+
* it can have following styles:
97+
* accent,
98+
* flat,
99+
* inverse,
100+
* mini,
101+
* neutral,
102+
* primary,
103+
* raised,
104+
* toggle
105+
*/
106+
pagesButtonTypes?: object;
107+
}
108+
109+
export class Pager extends React.Component<PagerProps, {}> { }
110+
111+
export default Pager;

components/pager/index.js

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
import { themr } from 'react-css-themr';
2+
import { PAGER } from '../identifiers.js';
3+
import { pagerFactory } from './pager.js';
4+
import { Button } from '../button';
5+
import theme from './theme.scss';
6+
7+
const Pager = pagerFactory(Button);
8+
9+
const ThemedPager = themr(PAGER, theme)(Pager);
10+
export default ThemedPager;
11+
export { ThemedPager as Pager };

0 commit comments

Comments
 (0)