Skip to content

Commit 9436309

Browse files
author
liyuan-meng
committed
[Pagination]极简分页的下拉列表替换成 Dropdown
1 parent 2f2588b commit 9436309

2 files changed

Lines changed: 27 additions & 59 deletions

File tree

src/components/pagination/index.js

Lines changed: 16 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import { noop, prefixCls } from '@utils';
66
import Icon from '../icon';
77
import Input from '../input';
88
import Select from '../select';
9-
import Popover from '../popover';
9+
import Dropdown from '../c-dropdown';
1010

1111
import './index.less';
1212

@@ -435,37 +435,29 @@ class Pagination extends Component {
435435
{this.totalPage}
436436
</span>
437437
) : (
438-
<Popover
439-
trigger="click"
440-
placement="bottom-center"
441-
className={`${prefixCls}-pagination-mini-container`}
442-
content={(
443-
<div className="mini-page-list">
444-
{pageList.map((page) => (
445-
<span
446-
key={page}
447-
className={`mini-page-item ${prefixCls}-popover-cancel ${
448-
`${page}` === `${this.state.current}` ? 'active' : ''
449-
}`}
450-
onClick={() => {
451-
this.goPage(page);
452-
}}
453-
>
454-
<span>{page}</span>
455-
{`${page}` === `${this.state.current}` && (
456-
<Icon type="finish" />
457-
)}
458-
</span>
438+
<Dropdown
439+
placement="bottom"
440+
overlay={(
441+
<Dropdown.Menu
442+
checkedId={this.state.current}
443+
className={`${prefixCls}-pagination-min-list`}
444+
onClick={page => {
445+
this.goPage(page);
446+
}}
447+
>
448+
{pageList.map(page => (
449+
<Dropdown.Item key={page} id={page}>{page}</Dropdown.Item>
459450
))}
460-
</div>
451+
</Dropdown.Menu>
461452
)}
453+
trigger={['click']}
462454
>
463455
<span className="current-page">
464456
{this.state.current}
465457
/
466458
{this.totalPage}
467459
</span>
468-
</Popover>
460+
</Dropdown>
469461
);
470462
};
471463

src/components/pagination/index.less

Lines changed: 11 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -225,9 +225,12 @@
225225

226226
&.@{pagination-prefix-cls}-mini-page {
227227
.current-page {
228+
display: inline-flex;
229+
align-items: center;
230+
justify-content: center;
228231
height: 32px;
229232
line-height: 32px;
230-
min-width: 48px;
233+
min-width: 48px!important;
231234
text-align: center;
232235
color: @blue-4;
233236
cursor: pointer;
@@ -284,40 +287,13 @@
284287
}
285288
}
286289

287-
.@{pagination-prefix-cls}-mini-container {
288-
padding: 0!important;
289-
290-
.mini-page-list {
291-
width: 72px;
292-
293-
.mini-page-item {
294-
display: flex;
295-
align-items: center;
296-
justify-content: space-between;
297-
cursor: pointer;
298-
height: 31px;
299-
padding-left: 12px;
300-
padding-right: 14px;
301-
302-
&:hover {
303-
background: @indigo-1;
304-
}
305-
306-
&.active {
307-
background: @indigo-2;
308-
}
309-
310-
.icon-finish {
311-
color: @blue-4;
312-
}
313-
}
314-
}
315-
316-
&.@{prefix}-tooltip.is-light {
317-
box-shadow: @border-shadow-3;
318-
}
290+
.@{pagination-prefix-cls}-min-list {
291+
max-height: 190px;
292+
overflow: auto;
319293

320-
&.@{prefix}-tooltip.bottom-center.is-light:after {
321-
display: none;
294+
&::-webkit-scrollbar {
295+
background: transparent;
296+
width: 0;
297+
height: 0;
322298
}
323299
}

0 commit comments

Comments
 (0)