Skip to content

Commit 85197c4

Browse files
committed
feat: pagination add responsive
1 parent 00cf241 commit 85197c4

File tree

7 files changed

+57
-11
lines changed

7 files changed

+57
-11
lines changed

components/modal/style/confirm.less

+1-1
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
overflow: hidden;
2424
color: @heading-color;
2525
font-weight: 500;
26-
font-size: @font-size-lg;
26+
font-size: @modal-confirm-title-font-size;
2727
line-height: 1.4;
2828
}
2929

components/pagination/Pagination.tsx

+5-1
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import VcPagination from '../vc-pagination';
1111
import enUS from '../vc-pagination/locale/en_US';
1212
import classNames from '../_util/classNames';
1313
import useConfigInject from '../_util/hooks/useConfigInject';
14+
import useBreakpoint from '../_util/hooks/useBreakpoint';
1415

1516
export const paginationProps = () => ({
1617
total: Number,
@@ -43,6 +44,7 @@ export const paginationProps = () => ({
4344
}) => any
4445
>,
4546
role: String,
47+
responsive: Boolean,
4648
showLessItems: { type: Boolean, default: undefined },
4749
onChange: Function as PropType<(page: number, pageSize: number) => void>,
4850
onShowSizeChange: Function as PropType<(current: number, size: number) => void>,
@@ -82,6 +84,7 @@ export default defineComponent({
8284
const selectPrefixCls = computed(() =>
8385
configProvider.getPrefixCls('select', props.selectPrefixCls),
8486
);
87+
const breakpoint = useBreakpoint();
8588
const [locale] = useLocaleReceiver('Pagination', enUS, toRef(props, 'locale'));
8689
const getIconsProps = (pre: string) => {
8790
const ellipsis = <span class={`${pre}-item-ellipsis`}>•••</span>;
@@ -132,10 +135,11 @@ export default defineComponent({
132135
itemRender = slots.itemRender,
133136
buildOptionText = slots.buildOptionText,
134137
selectComponentClass,
138+
responsive,
135139
...restProps
136140
} = props;
137141

138-
const isSmall = size === 'small';
142+
const isSmall = size === 'small' || !!(breakpoint.value?.xs && !size && responsive);
139143
const paginationProps = {
140144
...restProps,
141145
...getIconsProps(prefixCls.value),

components/pagination/demo/custom-changer.vue

+1-1
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,10 @@ Customize dropdown options such as adding all options
1818
<template>
1919
<a-pagination
2020
v-model:current="current"
21+
v-model:page-size="pageSize"
2122
:page-size-options="pageSizeOptions"
2223
:total="total"
2324
show-size-changer
24-
:page-size="pageSize"
2525
@showSizeChange="onShowSizeChange"
2626
>
2727
<template #buildOptionText="props">

components/pagination/demo/total.vue

+6-2
Original file line numberDiff line numberDiff line change
@@ -19,16 +19,16 @@ You can show the total number of data by setting `showTotal`.
1919
<div>
2020
<a-pagination
2121
v-model:current="current1"
22+
v-model:page-size="pageSize1"
2223
:total="85"
2324
:show-total="total => `Total ${total} items`"
24-
:page-size="20"
2525
/>
2626
<br />
2727
<a-pagination
2828
v-model:current="current2"
29+
v-model:page-size="pageSize2"
2930
:total="85"
3031
:show-total="(total, range) => `${range[0]}-${range[1]} of ${total} items`"
31-
:page-size="20"
3232
/>
3333
</div>
3434
</template>
@@ -38,12 +38,16 @@ export default defineComponent({
3838
setup() {
3939
const current1 = ref<number>(1);
4040
const current2 = ref<number>(2);
41+
const pageSize1 = ref<number>(20);
42+
const pageSize2 = ref<number>(20);
4143
const onChange = (pageNumber: number) => {
4244
console.log('Page: ', pageNumber);
4345
};
4446
return {
4547
current1,
4648
current2,
49+
pageSize1,
50+
pageSize2,
4751
onChange,
4852
};
4953
},

components/pagination/index.en-US.md

+1
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ A long list can be divided into several pages using `Pagination`, and only one p
2929
| itemRender | to customize item innerHTML | (page, type: 'page' \| 'prev' \| 'next', originalElement) => vNode \| v-slot | - | |
3030
| pageSize(v-model) | number of data items per page | number | - | |
3131
| pageSizeOptions | specify the sizeChanger options | string\[] | \['10', '20', '30', '40'] | |
32+
| responsive | If `size` is not specified, `Pagination` would resize according to the width of the window | boolean | - | 3.1 |
3233
| showLessItems | Show less page items | boolean | false | 1.5.0 |
3334
| showQuickJumper | determine whether you can jump to pages directly | boolean | false | |
3435
| showSizeChanger | determine whether `pageSize` can be changed | boolean | false | |

components/pagination/index.zh-CN.md

+1
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ cover: https://gw.alipayobjects.com/zos/alicdn/1vqv2bj68/Pagination.svg
2424
| itemRender | 用于自定义页码的结构,可用于优化 SEO | ({page, type: 'page' \| 'prev' \| 'next', originalElement}) => vNode \| v-slot | - | |
2525
| pageSize(v-model) | 每页条数 | number | - | |
2626
| pageSizeOptions | 指定每页可以显示多少条 | string\[] | \['10', '20', '30', '40'] | |
27+
| responsive | 当 size 未指定时,根据屏幕宽度自动调整尺寸 | boolean | - | 3.1 |
2728
| showLessItems | 是否显示较少页面内容 | boolean | false | 1.5.0 |
2829
| showQuickJumper | 是否可以快速跳转至某页 | boolean | false | |
2930
| showSizeChanger | 是否可以改变 pageSize | boolean | false | |

components/pagination/style/index.less

+42-6
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,6 @@
5959
}
6060
}
6161

62-
&:focus-visible,
6362
&:hover {
6463
border-color: @primary-color;
6564
transition: all 0.3s;
@@ -69,6 +68,17 @@
6968
}
7069
}
7170

71+
// cannot merge with `&:hover`
72+
// see https://github.com/ant-design/ant-design/pull/34002
73+
&:focus-visible {
74+
border-color: @primary-color;
75+
transition: all 0.3s;
76+
77+
a {
78+
color: @primary-color;
79+
}
80+
}
81+
7282
&-active {
7383
font-weight: @pagination-font-weight-active;
7484
background: @pagination-item-bg-active;
@@ -78,15 +88,21 @@
7888
color: @primary-color;
7989
}
8090

81-
&:focus-visible,
8291
&:hover {
8392
border-color: @primary-5;
8493
}
8594

86-
&:focus-visible a,
95+
&:focus-visible {
96+
border-color: @primary-5;
97+
}
98+
8799
&:hover a {
88100
color: @primary-5;
89101
}
102+
103+
&:focus-visible a {
104+
color: @primary-5;
105+
}
90106
}
91107
}
92108

@@ -130,7 +146,6 @@
130146
}
131147
}
132148

133-
&:focus-visible,
134149
&:hover {
135150
.@{pagination-prefix-cls}-item-link-icon {
136151
opacity: 1;
@@ -139,6 +154,15 @@
139154
opacity: 0;
140155
}
141156
}
157+
158+
&:focus-visible {
159+
.@{pagination-prefix-cls}-item-link-icon {
160+
opacity: 1;
161+
}
162+
.@{pagination-prefix-cls}-item-ellipsis {
163+
opacity: 0;
164+
}
165+
}
142166
}
143167

144168
&-prev,
@@ -194,7 +218,11 @@
194218
transition: all 0.3s;
195219
}
196220

197-
&:focus-visible .@{pagination-prefix-cls}-item-link,
221+
&:focus-visible .@{pagination-prefix-cls}-item-link {
222+
color: @primary-color;
223+
border-color: @primary-color;
224+
}
225+
198226
&:hover .@{pagination-prefix-cls}-item-link {
199227
color: @primary-color;
200228
border-color: @primary-color;
@@ -203,7 +231,15 @@
203231

204232
&-disabled {
205233
&,
206-
&:hover,
234+
&:hover {
235+
cursor: not-allowed;
236+
.@{pagination-prefix-cls}-item-link {
237+
color: @disabled-color;
238+
border-color: @border-color-base;
239+
cursor: not-allowed;
240+
}
241+
}
242+
207243
&:focus-visible {
208244
cursor: not-allowed;
209245
.@{pagination-prefix-cls}-item-link {

0 commit comments

Comments
 (0)