From 52054e1c2af9a5b2a25a26ba21ab0f8e2642d3ce Mon Sep 17 00:00:00 2001 From: myronliu347 Date: Mon, 5 Aug 2019 20:18:36 +0800 Subject: [PATCH] feat(Pagination): support device --- src/pagination/pagination.jsx | 10 +++++++++- test/pagination/index-spec.js | 9 +++++++++ 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/src/pagination/pagination.jsx b/src/pagination/pagination.jsx index 749211e436..12b9996592 100644 --- a/src/pagination/pagination.jsx +++ b/src/pagination/pagination.jsx @@ -20,6 +20,7 @@ class Pagination extends Component { prefix: PropTypes.string, pure: PropTypes.bool, rtl: PropTypes.bool, + device: PropTypes.oneOf(['desktop', 'tablet', 'phone']), className: PropTypes.string, /** * 自定义国际化文案对象 @@ -579,7 +580,8 @@ class Pagination extends Component { prefix, pure, rtl, - type, + device, + type: paginationType, size, shape, className, @@ -612,6 +614,12 @@ class Pagination extends Component { const sizeSelector = this.renderPageSizeSelector(); const isStart = pageSizePosition === 'start'; + let type = paginationType; + + if (device === 'phone' && type === 'normal') { + type = 'simple'; + } + const classes = cx({ [`${prefix}pagination`]: true, [`${prefix}${size}`]: size, diff --git a/test/pagination/index-spec.js b/test/pagination/index-spec.js index dd948e2421..7d69d27dbc 100644 --- a/test/pagination/index-spec.js +++ b/test/pagination/index-spec.js @@ -680,4 +680,13 @@ describe('Pagination', () => { ) ); }); + + it('should support device transfer type to simple', () => { + wrapper.setProps({ + device: 'phone', + type: 'normal' + }); + + assert(wrapper.find('.next-simple').length > 0); + }) });