-
-
Notifications
You must be signed in to change notification settings - Fork 438
/
Copy pathPaginationButton.tsx
80 lines (71 loc) · 1.76 KB
/
PaginationButton.tsx
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
69
70
71
72
73
74
75
76
77
78
79
80
import classNames from 'classnames';
import type { ComponentProps, FC, ReactEventHandler, ReactNode } from 'react';
import type { DeepPartial } from '../../';
import { useTheme } from '../../';
import { mergeDeep } from '../../helpers/merge-deep';
export interface FlowbitePaginationButtonTheme {
base: string;
active: string;
disabled: string;
}
export interface PaginationButtonProps extends ComponentProps<'button'> {
active?: boolean;
children?: ReactNode;
className?: string;
onClick?: ReactEventHandler<HTMLButtonElement>;
theme?: DeepPartial<FlowbitePaginationButtonTheme>;
}
export interface PaginationPrevButtonProps extends Omit<PaginationButtonProps, 'active'> {
disabled?: boolean;
}
export const PaginationButton: FC<PaginationButtonProps> = ({
active,
children,
className,
onClick,
theme: customTheme = {},
...props
}) => {
const theme = mergeDeep(useTheme().theme.pagination, customTheme);
return (
<button
className={classNames(
{
[theme.pages.selector.active]: active,
},
className,
)}
onClick={onClick}
{...props}
>
{children}
</button>
);
};
PaginationButton.displayName = 'Pagination.Button';
export const PaginationNavigation: FC<PaginationPrevButtonProps> = ({
children,
className,
onClick,
theme: customTheme = {},
disabled = false,
...props
}) => {
const theme = mergeDeep(useTheme().theme.pagination, customTheme);
return (
<button
className={classNames(
{
[theme.pages.selector.disabled]: disabled,
},
className,
)}
disabled={disabled}
onClick={onClick}
{...props}
>
{children}
</button>
);
};
PaginationNavigation.displayName = 'Pagination.Navigation';