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

refactor: Switch support css var #45867

Merged
merged 5 commits into from
Nov 16, 2023
Merged

Conversation

JarvisArt
Copy link
Contributor

@JarvisArt JarvisArt commented Nov 14, 2023

[中文版模板 / 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

💡 Background and solution

📝 Changelog

Language Changelog
🇺🇸 English Switch support css variables.
🇨🇳 Chinese Switch 组件支持 css 变量。

☑️ 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

🚀 Summary

🤖 Generated by Copilot at 89f075f

This pull request enhances the Switch component with CSS variables support and style refactoring. It introduces a new useCSSVar hook that registers and updates the CSS variables for the component. It also uses the @ant-design/cssinjs package to simplify the style calculations and units.

🔍 Walkthrough

🤖 Generated by Copilot at 89f075f

  • Add the useCSSVar hook to enable the use of CSS variables for the Switch component (link, link, link, link)
  • Import the unit function and the GetDefaultToken type to convert numeric values to CSS units and annotate the prepareComponentToken function (link)
  • Replace the numeric values and template literals with the calc function calls to simplify the arithmetic expressions and ensure valid CSS units in the Switch component styles (link, link, link, link, link, link, link, link, link, link, link, link, link, link, link, link)
  • Extract the prepareComponentToken function to calculate the token values for the Switch component from the useSwitchStyle hook in components/switch/style/index.ts (link, link)

Copy link

stackblitz bot commented Nov 14, 2023

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

Copy link
Contributor

github-actions bot commented Nov 14, 2023

Preview Is ready

Copy link

codesandbox-ci bot commented Nov 14, 2023

This pull request is automatically built and testable in CodeSandbox.

To see build info of the built libraries, click here or the icon next to each commit SHA.

Latest deployment of this branch, based on commit dee9f4e:

Sandbox Source
antd reproduction template (forked) Configuration

Copy link

argos-ci bot commented Nov 14, 2023

The latest updates on your projects. Learn more about Argos notifications ↗︎

Build Status Details Updated (UTC)
default (Inspect) 🧿 Changes detected (Review) 1 change Nov 15, 2023, 6:39 AM

@@ -401,29 +427,5 @@ export default genComponentStyleHook(
genSwitchSmallStyle(switchToken),
Copy link
Member

Choose a reason for hiding this comment

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

switchToken 里有个 switchLoadingIconSize 计算过

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done~

Copy link

codecov bot commented Nov 14, 2023

Codecov Report

All modified and coverable lines are covered by tests ✅

Comparison is base (8e32367) 100.00% compared to head (dee9f4e) 100.00%.
Report is 5 commits behind head on feature.

Additional details and impacted files
@@            Coverage Diff            @@
##           feature    #45867   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files          706       706           
  Lines        12084     12101   +17     
  Branches      3197      3197           
=========================================
+ Hits         12084     12101   +17     

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

@MadCcc
Copy link
Member

MadCcc commented Nov 14, 2023

点击时的动画没了

@MadCcc
Copy link
Member

MadCcc commented Nov 14, 2023

image
有三处 NaN

@JarvisArt
Copy link
Contributor Author

点击时的动画没了

image 有三处 NaN

会不会是之前的预览链接,点现在链接康康?

2023-11-14.16.38.53.mov

@MadCcc
Copy link
Member

MadCcc commented Nov 14, 2023

@JarvisArt check-cssinjs 的 switch 去掉跑一下 lint 看看?

@MadCcc
Copy link
Member

MadCcc commented Nov 14, 2023

点击的时候有一个白球拉长的动画

@JarvisArt
Copy link
Contributor Author

点击的时候有一个白球拉长的动画

确实

boxShadow: handleShadow,
transition: `all ${token.switchDuration} ease-in-out`,
content: '""',
},
},

[`&${componentCls}-checked ${switchHandleCls}`]: {
insetInlineStart: `calc(100% - ${handleSize + trackPadding}px)`,
insetInlineStart: `calc(100% - ${unit(calc(handleSize).add(trackPadding).equal())})`,
},

[`&:not(${componentCls}-disabled):active`]: motion
Copy link
Contributor Author

Choose a reason for hiding this comment

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

待处理 @MadCcc

@MadCcc MadCcc merged commit 9c29461 into ant-design:feature Nov 16, 2023
53 of 54 checks passed
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