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(CalendarPickerView): add renderTop and renderBottom hide logic #6735

Merged
merged 7 commits into from
Oct 29, 2024

Conversation

Layouwen
Copy link
Member

增加 renderTop 和 renderBottom false 隐藏

Copy link

codecov bot commented Aug 30, 2024

Codecov Report

Attention: Patch coverage is 94.44444% with 1 line in your changes missing coverage. Please review.

Project coverage is 92.70%. Comparing base (b805b5a) to head (78e56c2).
Report is 10 commits behind head on master.

Files with missing lines Patch % Lines
...ents/calendar-picker-view/calendar-picker-view.tsx 94.44% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master    #6735      +/-   ##
==========================================
+ Coverage   92.68%   92.70%   +0.02%     
==========================================
  Files         334      335       +1     
  Lines        7191     7199       +8     
  Branches     1795     1767      -28     
==========================================
+ Hits         6665     6674       +9     
  Misses        517      517              
+ Partials        9        8       -1     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Copy link
Contributor

PR preview has been successfully built and deployed to https://antd-mobile-preview-pr-6735.surge.sh

@@ -21,8 +21,8 @@ Only the simplest content area is shown here, and other more usages can be consu
| max | Maximum value of a selectable range. | `Date` | - |
| min | Minimum value of a selectable range. | `Date` | - | - |
| onChange | Trigger when selected date changes. | `(val: Date \| null) => void` when selection mode is "single". `(val: [Date, Date] \| null) => void` when selection mode is "range". | - |
| renderTop | The top information of date render function. | `(date: Date) => ReactNode \| null \| undefined` | - |
| renderBottom | The bottom information of date render function. | `(date: Date) => ReactNode \| null \| undefined` | - |
| renderTop | The top information of date render function. | `((date: Date) => ReactNode \| null \| undefined) \| false` | - |
Copy link
Member

Choose a reason for hiding this comment

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

false 这个加一下版本号说明,参考:
截屏2024-08-30 11 02 59

@@ -44,9 +44,9 @@ export type CalendarPickerViewProps = {
title?: React.ReactNode | false
confirmText?: string
weekStartsOn?: 'Monday' | 'Sunday'
renderTop?: (date: Date) => React.ReactNode
renderTop?: ((date: Date) => React.ReactNode) | false
Copy link
Member

Choose a reason for hiding this comment

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

加一下对应的测试用例

@Layouwen Layouwen requested a review from zombieJ August 30, 2024 03:12
@@ -243,6 +245,8 @@ export const CalendarPickerView = forwardRef<
(minDay && d.isBefore(minDay, 'day'))

const renderTop = () => {
if (props.renderTop === false) return
Copy link
Member

Choose a reason for hiding this comment

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

这个逻辑看起来没有用?下面的代码里已经写了

if (props.renderXXX === false) return

所有 renderXXX 走到的地方其实已经都判断过了

Copy link
Member Author

Choose a reason for hiding this comment

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

renderXXX 类型为 function | false
这里如果不把 boolean 过滤掉 ts 会报错, 所以才加上的

Copy link
Member

Choose a reason for hiding this comment

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

那可以考虑调整一下代码结构,也不需要这个 renderTop 函数了,直接内联写。

zombieJ
zombieJ previously approved these changes Oct 23, 2024
@Layouwen Layouwen force-pushed the feature/calendar-picker-view branch 2 times, most recently from 259489c to 5866c28 Compare October 23, 2024 08:30
Copy link
Contributor

github-actions bot commented Oct 29, 2024

Preview is ready

@Layouwen Layouwen force-pushed the feature/calendar-picker-view branch from cd6bc4a to b839f9d Compare October 29, 2024 08:36
@Layouwen Layouwen requested a review from zombieJ October 29, 2024 08:52
@zombieJ zombieJ merged commit 2a70c91 into ant-design:master Oct 29, 2024
10 checks passed
@Layouwen Layouwen deleted the feature/calendar-picker-view branch October 29, 2024 09:25
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.

2 participants