(Go: >> BACK << -|- >> HOME <<)

Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(List): Added list pagination alignment option #39858

Merged
merged 1 commit into from
Dec 31, 2022

Conversation

Yuiai01
Copy link
Contributor
@Yuiai01 Yuiai01 commented Dec 27, 2022

[中文版模板 / Chinese template]

🤔 This is a ...

  • New feature
  • Bug fix
  • Site / documentation update
  • Demo update
  • Component style update
  • TypeScript definition update
  • Bundle size optimization
  • Performance optimization
  • Enhancement feature
  • Internationalization
  • Refactoring
  • Code style optimization
  • Test Case
  • Branch merge
  • Workflow
  • Other (about what?)

🔗 Related issue link

想实现类似Table组件的分页位置设置 https://codesandbox.io/s/ekl5og?file=/demo.tsx

💡 Background and solution

在最近的业务开发过程中,由于数据源内容简单,因此采用了List组件进行展示,但是发现分页需要导入后手动实现底部居中的效果(设计大大设计的居中😭)。因此在原有的基础上增加了设置分页对齐的选项,实现了不用导入即可实现居中或者左对齐的功能。

📝 Changelog

Language Changelog
🇺🇸 English Added list pagination alignment option
🇨🇳 Chinese List组件的分页增加对齐位置的选项

☑️ Self-Check before Merge

⚠️ Please check all items below before requesting a reviewing. ⚠️

  • Doc is updated/provided or not needed
  • Demo is updated/provided or not needed
  • TypeScript definition is updated/provided or not needed
  • Changelog is provided or not needed

@github-actions
Copy link
Contributor
github-actions bot commented Dec 27, 2022

@afc163
Copy link
Member
afc163 commented Dec 28, 2022

feature branch please~

@Yuiai01 Yuiai01 changed the base branch from master to feature December 28, 2022 05:36
@Yuiai01
Copy link
Contributor Author
Yuiai01 commented Dec 28, 2022

feature branch please~

ok

@@ -206,7 +206,10 @@ function List<T>({
paginationProps.current = largestPage;
}
const paginationContent = pagination ? (
<div className={`${prefixCls}-pagination`}>
<div
className={`${prefixCls}-pagination`}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

放到 style 里面去实现吧

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

嗯嗯,大佬我的想法是将 align 这个属性透传到 style 里面去,但是小弟不知道咋整进去,不知道大佬有没有相关的例子。o(╥﹏╥)o

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@afc163 大佬我这里借鉴了一下 table 里 pagination 的做法

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

那先这样好了。

@afc163
Copy link
Member
afc163 commented Dec 28, 2022

看一下 ci 报错,你需要更新一下 test snapshot。

@Yuiai01
Copy link
Contributor Author
Yuiai01 commented Dec 29, 2022

看一下 ci 报错,你需要更新一下 test snapshot。

嗯嗯 我按照提示更新了 test snapshot

@codecov
Copy link
codecov bot commented Dec 29, 2022

Codecov Report

Base: 100.00% // Head: 99.98% // Decreases project coverage by -0.01% ⚠️

Coverage data is based on head (eb7b309) compared to base (7823562).
Patch coverage: 100.00% of modified lines in pull request are covered.

Additional details and impacted files
@@             Coverage Diff             @@
##           feature   #39858      +/-   ##
===========================================
- Coverage   100.00%   99.98%   -0.02%     
===========================================
  Files          557      557              
  Lines         9638     9639       +1     
  Branches      2732     2733       +1     
===========================================
  Hits          9638     9638              
- Misses           0        1       +1     
Impacted Files Coverage Δ
components/pagination/Pagination.tsx 100.00% <ø> (ø)
components/list/index.tsx 100.00% <100.00%> (ø)
components/tooltip/index.tsx 98.96% <0.00%> (-1.04%) ⬇️

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

☔ View full report at Codecov.
📢 Do you have feedback about the report comment? Let us know in this issue.

@@ -13,6 +13,7 @@ interface ListToken extends FullToken<'List'> {
listItemPaddingLG: string;
listItemPaddingSM: string;
listItemPadding: string;
listPaginationTA: string;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这个是啥?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这个是啥?

害 病糊涂了 昨天想试试 能不能透传进去 忘记删除了 o(╥﹏╥)o

@@ -28,6 +28,7 @@ const App: React.FC = () => (
console.log(page);
},
pageSize: 3,
align: 'center',
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

建议单独加个例子,不改这个。

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

建议单独加个例子,不改这个。

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

建议单独加个例子,不改这个。

大佬 我在查看示例的时候发现了 list doc 切换至英文 会出现这种情况:
image
然后我也发现了问题所在
image
那么这个我是一起提交还是再单独提交一次呢?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这个可以单独提交到 master 分支

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这个可以单独提交到 master 分支

嗯呐

Comment on lines 139 to 150

'&-align-start': {
textAlign: 'start',
},

'&-align-center': {
textAlign: 'center',
},

'&-align-end': {
textAlign: 'end',
},
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

图片

体积稍微增加了一点。

这一段代码是可以直接 ['start', 'center', 'end'].map(...) 出来的,可以试着改写下。

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

图片

体积稍微增加了一点。

这一段代码是可以直接 ['start', 'center', 'end'].map(...) 出来的,可以试着改写下。

嗯嗯

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

图片

体积稍微增加了一点。

这一段代码是可以直接 ['start', 'center', 'end'].map(...) 出来的,可以试着改写下。

代码体积的增加应该是我示例的部分和一些可优化点没有做好,我再次优化一下

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

大佬小弟发现这里用 map 好像行不通,不过我用 reduce 写出来但是很不优雅

 ...['start', 'center', 'end'].reduce((obj, item) => {
          obj[`&-align-${item}`] = {
            textAlign: item,
          }
          return obj
        }, {} as any)

Copy link
Member
@afc163 afc163 Dec 30, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

可以在上面声明一个变量,不用都写在这里。

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

可以在上面声明一个变量,不用都写在这里。

@@ -23,8 +23,11 @@ export interface PaginationProps extends RcPaginationProps {

export type PaginationPosition = 'top' | 'bottom' | 'both';

export type paginationAlign = 'start' | 'center' | 'end';
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
export type paginationAlign = 'start' | 'center' | 'end';
export type PaginationAlign = 'start' | 'center' | 'end';

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

已修改

@afc163 afc163 merged commit 1fca9cf into ant-design:feature Dec 31, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants