Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
86 changes: 50 additions & 36 deletions assets/index.less
Original file line number Diff line number Diff line change
Expand Up @@ -71,10 +71,17 @@
cursor: pointer;
user-select: none;

a {
a,
button {
display: block;
width: 100%;
height: 100%;
padding: 0 6px;
color: rgba(0, 0, 0, 0.85);
background: transparent;
border: 0;
cursor: pointer;
outline: none;
transition: none;

&:hover {
Expand All @@ -83,10 +90,12 @@
}

&:focus,
&:focus-within,
&:hover {
border-color: @primary-color;
transition: all 0.3s;
a {
a,
button {
color: @primary-color;
}
}
Expand All @@ -96,17 +105,23 @@
background: @pagination-item-bg-active;
border-color: @primary-color;

a {
a,
button {
color: @primary-color;
}

&:focus,
&:focus-within,
&:hover {
border-color: #40a9ff;
}

&:focus a,
&:hover a {
&:hover a,
&:focus-within a,
&:focus button,
&:hover button,
&:focus-within button {
color: #40a9ff;
}
}
Expand All @@ -115,18 +130,6 @@
&-jump-prev,
&-jump-next {
outline: 0;

button {
background: transparent;
border: none;
cursor: pointer;
color: #666;
}

button:after {
display: block;
content: '•••';
}
}

&-prev,
Expand All @@ -153,20 +156,14 @@
}

&-prev,
&-next {
&-next,
&-jump-prev,
&-jump-next {
outline: 0;

button {
color: rgba(0, 0, 0, 0.85);
cursor: pointer;
user-select: none;
}

&:hover button {
border-color: #40a9ff;
}

.@{pagination-prefix-cls}-item-link {
button,
.@{pagination-prefix-cls}-item-link,
.@{pagination-prefix-cls}-item-button {
display: block;
width: 100%;
height: 100%;
Expand All @@ -176,32 +173,45 @@
border: 1px solid #d9d9d9;
border-radius: 2px;
outline: none;
cursor: pointer;
user-select: none;
transition: all 0.3s;
}

button:focus,
&:focus .@{pagination-prefix-cls}-item-link,
&:hover .@{pagination-prefix-cls}-item-link {
&:focus .@{pagination-prefix-cls}-item-button,
&:hover .@{pagination-prefix-cls}-item-link,
&:hover .@{pagination-prefix-cls}-item-button,
&:hover button {
color: @primary-color;
border-color: @primary-color;
}
}

&-prev button:after {
&-prev .@{pagination-prefix-cls}-item-link::after {
content: '‹';
display: block;
}

&-next button:after {
&-next .@{pagination-prefix-cls}-item-link::after {
content: '›';
display: block;
}

&-jump-prev .@{pagination-prefix-cls}-item-link::after,
&-jump-next .@{pagination-prefix-cls}-item-link::after {
display: block;
content: '•••';
}

&-disabled {
&,
&:hover,
&:focus {
cursor: not-allowed;
.@{pagination-prefix-cls}-item-link {
.@{pagination-prefix-cls}-item-link,
.@{pagination-prefix-cls}-item-button {
color: fade(#000, 25%);
border-color: #d9d9d9;
cursor: not-allowed;
Expand Down Expand Up @@ -250,7 +260,8 @@
height: @pagination-item-size-sm;
line-height: @pagination-item-size-sm;
vertical-align: top;
.@{pagination-prefix-cls}-item-link {
.@{pagination-prefix-cls}-item-link,
.@{pagination-prefix-cls}-item-button {
height: @pagination-item-size-sm;
background-color: transparent;
border: 0;
Expand Down Expand Up @@ -293,7 +304,8 @@
border-color: #d9d9d9;
cursor: not-allowed;

a {
a,
button {
color: fade(#000, 25%);
background: transparent;
border: none;
Expand All @@ -303,13 +315,15 @@
&-active {
background: @pagination-item-disabled-bg-active;
border-color: transparent;
a {
a,
button {
color: @pagination-item-disabled-color-active;
}
}
}

.@{pagination-prefix-cls}-item-link {
.@{pagination-prefix-cls}-item-link,
.@{pagination-prefix-cls}-item-button {
color: fade(#000, 25%);
background: hsv(0, 0, 96%);
border-color: #d9d9d9;
Expand Down
40 changes: 29 additions & 11 deletions src/Pager.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,14 @@ import { clsx } from 'clsx';
import React from 'react';
import type { PaginationProps } from './interface';

export interface PagerProps extends Pick<PaginationProps, 'itemRender'> {
export interface PagerProps extends Pick<
PaginationProps,
'disabled' | 'itemRender'
> {
rootPrefixCls: string;
page: number;
pageLabel?: string;
defaultItemRender?: boolean;
active?: boolean;
className?: string;
style?: React.CSSProperties;
Expand All @@ -24,6 +28,8 @@ const Pager: React.FC<PagerProps> = (props) => {
rootPrefixCls,
page,
pageLabel,
disabled,
defaultItemRender,
active,
className,
style,
Expand Down Expand Up @@ -52,24 +58,36 @@ const Pager: React.FC<PagerProps> = (props) => {
onKeyPress(e, onClick, page);
};

const pager = itemRender(
page,
'page',
<a tabIndex={-1} aria-hidden="true" rel="nofollow">
{page}
</a>,
);
const pagerLabel = `${pageLabel} ${page}`.trim();
const pagerLabel = pageLabel ? `${pageLabel} ${page}` : String(page);
const itemTitle = showTitle ? String(page) : undefined;

if (defaultItemRender) {
return (
<li className={cls} style={style}>
<button
type="button"
onClick={handleClick}
title={itemTitle}
aria-label={pagerLabel}
aria-current={active ? 'page' : undefined}
disabled={disabled || cls.includes(`${prefixCls}-disabled`)}
>
{page}
</button>
</li>
Comment thread
ZQDesigned marked this conversation as resolved.
);
}

const pager = itemRender(page, 'page', <a rel="nofollow">{page}</a>);

return pager ? (
<li
title={showTitle ? String(page) : null}
title={itemTitle}
className={cls}
style={style}
onClick={handleClick}
onKeyDown={handleKeyPress}
tabIndex={0}
role="button"
aria-label={pagerLabel}
aria-current={active ? 'page' : undefined}
>
Expand Down
Loading
Loading