Skip to content

feat(Slider): unify orientation attribute usage#53671

Merged
thinkasany merged 17 commits intoant-design:nextfrom
EmilyyyLiu:next-slider-orientation
May 16, 2025
Merged

feat(Slider): unify orientation attribute usage#53671
thinkasany merged 17 commits intoant-design:nextfrom
EmilyyyLiu:next-slider-orientation

Conversation

@EmilyyyLiu
Copy link
Contributor

🤔 This is a ...

  • 🆕 New feature

🔗 Related Issues

  • Describe the source of related requirements, such as links to relevant issue discussions.
  • For example: close #xxxx, fix #xxxx

💡 Background and Solution

FRC #53328

📝 Change Log

Language Changelog
🇺🇸 English Add the 'orientation' attribute to Slider components for orientation configuration
🇨🇳 Chinese 对Slider组件增加使用“orientation”属性用于方向布局配置

@bolt-new-by-stackblitz
Copy link

Review PR in StackBlitz Codeflow Run & review this pull request in StackBlitz Codeflow.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Apr 27, 2025

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Explain this complex logic.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai explain this code block.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and explain its main purpose.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@github-actions
Copy link
Contributor

github-actions bot commented Apr 27, 2025

👁 Visual Regression Report for PR #53671 Passed ✅

🎯 Target branch: next (cf83295)
📖 View Full Report ↗︎
📖 Alternative Report ↗︎

🎊 Congrats! No visual-regression diff found.

@github-actions
Copy link
Contributor

github-actions bot commented Apr 27, 2025

Preview is ready

@petercat-assistant
Copy link

Walkthrough

This pull request introduces a new feature to the Slider component by adding an 'orientation' attribute. This attribute allows for configuration of the slider's orientation, providing more flexibility in layout design. The changes include updates to the component logic, tests, and documentation to reflect this new feature.

Changes

Files Summary
components/_util/tests/hooks.test.tsx Added tests for new hooks useOrientation and useVertical.
components/_util/hooks/useOrientation.ts Introduced useOrientation and useVertical hooks to handle orientation logic.
components/slider/tests/index.test.tsx Added tests for the new 'orientation' attribute in the Slider component.
components/slider/demo/vertical.tsx Updated demo to use the new 'orientation' attribute.
components/slider/index.en-US.md, components/slider/index.zh-CN.md Updated documentation to include the new 'orientation' attribute.
components/slider/index.tsx Integrated the 'orientation' attribute into the Slider component logic.

@pkg-pr-new
Copy link

pkg-pr-new bot commented Apr 27, 2025

@codecov
Copy link

codecov bot commented Apr 27, 2025

Bundle Report

Changes will increase total bundle size by 466 bytes (0.01%) ⬆️. This is within the configured threshold ✅

Detailed changes
Bundle name Size Change
antd.min-array-push 3.75MB 466 bytes (0.01%) ⬆️

Affected Assets, Files, and Routes:

view changes for bundle: antd.min-array-push

Assets Changed:

Asset Name Size Change Total Size Change (%)
antd-with-locales.min.js 233 bytes 2.06MB 0.01%
antd.min.js 233 bytes 1.69MB 0.01%

@EmilyyyLiu EmilyyyLiu force-pushed the next-slider-orientation branch 2 times, most recently from 53e4a6c to 7e0439d Compare April 27, 2025 09:51
@EmilyyyLiu EmilyyyLiu force-pushed the next-slider-orientation branch from 7e0439d to dc6dda2 Compare May 6, 2025 01:28
@codecov
Copy link

codecov bot commented May 6, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 100.00%. Comparing base (cf83295) to head (92a4e15).
Report is 1 commits behind head on next.

Additional details and impacted files
@@            Coverage Diff            @@
##              next    #53671   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files          787       788    +1     
  Lines        14291     14304   +13     
  Branches      3780      3786    +6     
=========================================
+ Hits         14291     14304   +13     

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

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@EmilyyyLiu EmilyyyLiu force-pushed the next-slider-orientation branch 2 times, most recently from a45fb7b to b922ddc Compare May 9, 2025 08:35
@EmilyyyLiu EmilyyyLiu force-pushed the next-slider-orientation branch 2 times, most recently from fa29ff3 to c38785f Compare May 15, 2025 08:46
@EmilyyyLiu EmilyyyLiu force-pushed the next-slider-orientation branch 2 times, most recently from 51fa7a3 to 6c3163e Compare May 15, 2025 09:12
@EmilyyyLiu EmilyyyLiu force-pushed the next-slider-orientation branch from a1498d7 to 69fc3d2 Compare May 15, 2025 09:39
Copy link

@accesslint accesslint bot left a comment

Choose a reason for hiding this comment

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

There are accessibility issues in these changes.

disabled,
};

return <Input ref={composeRef<InputRef>(inputRef, ref)} {...inputProps} />;
Copy link

Choose a reason for hiding this comment

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

Looks like this element is missing an accessible name or label. That makes it hard for people using screen readers or voice control to use the control.

@EmilyyyLiu EmilyyyLiu force-pushed the next-slider-orientation branch 2 times, most recently from f202472 to f2fc016 Compare May 15, 2025 09:49
@EmilyyyLiu EmilyyyLiu changed the title feat(Slider): unify orientation attribute usage [WIP]feat(Slider): unify orientation attribute usage May 15, 2025
@EmilyyyLiu EmilyyyLiu changed the title [WIP]feat(Slider): unify orientation attribute usage feat(Slider): unify orientation attribute usage May 16, 2025
): [Orientation, boolean] {
return useMemo(() => {
const validOrientation = orientation === 'horizontal' || orientation === 'vertical';
let mergedOrientation: Orientation = 'horizontal';
Copy link
Member

Choose a reason for hiding this comment

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

这里不用预填,你下面已经兜底了

@EmilyyyLiu EmilyyyLiu force-pushed the next-slider-orientation branch from 8a0e55a to de92088 Compare May 16, 2025 06:11
[['invalid'] as any, ['horizontal', false]],
];

it.each(testCases)('with args %j should return %s', (params, expected) => {
Copy link
Member

Choose a reason for hiding this comment

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

👍 这个测试很全~

| vertical | If true, the slider will be vertical. Simultaneously existing with orientation, orientation takes priority | boolean | false | |
| onChangeComplete | Fire when `mouseup` or `keyup` is fired | (value) => void | - | |
| onChange | Callback function that is fired when the user changes the slider's value | (value) => void | - | |
| orientation | Orientation | `horizontal` \| `vertical` | `horizontal` | |
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.

👌


const { vertical } = props;

const { vertical, orientation } = props;
Copy link
Member

Choose a reason for hiding this comment

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

和上面的合并一下吧,这个看起来不需要单独从 props 里取


const { vertical, orientation } = props;
const [, mergedVertical] = useOrientation(orientation, vertical);
restProps.vertical = mergedVertical;
Copy link
Member

Choose a reason for hiding this comment

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

下面都是以 mergedVertical 为准了,不需要这个代码,另外也不应填结构出来的 object,否则有问题很难找。

@dosubot dosubot bot added the lgtm This PR has been approved by a maintainer label May 16, 2025
@EmilyyyLiu EmilyyyLiu force-pushed the next-slider-orientation branch from 45a48ce to 92a4e15 Compare May 16, 2025 07:32
@thinkasany thinkasany merged commit 7baf185 into ant-design:next May 16, 2025
38 of 39 checks passed
@EmilyyyLiu EmilyyyLiu deleted the next-slider-orientation branch May 28, 2025 05:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

lgtm This PR has been approved by a maintainer

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants