-
-
Notifications
You must be signed in to change notification settings - Fork 47k
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: FloatButton support css var #45861
Conversation
Run & review this pull request in StackBlitz Codeflow. |
@@ -32,7 +33,8 @@ const FloatButtonGroup: React.FC<FloatButtonGroupProps> = (props) => { | |||
|
|||
const { direction, getPrefixCls } = useContext<ConfigConsumerProps>(ConfigContext); | |||
const prefixCls = getPrefixCls(floatButtonPrefixCls, customizePrefixCls); | |||
const [wrapSSR, hashId] = useStyle(prefixCls); | |||
const [, hashId] = useStyle(prefixCls); | |||
const wrapCSSVar = useCSSVar(prefixCls); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
用 useCSSVarCls 取一个 roolCls 吧,FloatButton 那里也是。
这里 prefixCls 不是最外层,不会作用到最外层元素
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done~
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 de38f31:
|
/** | ||
* @desc 圆形按钮中徽章点的偏移量 | ||
* @descEN Offset of the badge dot in a circular button | ||
*/ | ||
dotOffsetInCircle: number; | ||
/** | ||
* @desc 方形按钮中徽章点的偏移量 | ||
* @descEN Offset of the badge dot in a square button | ||
*/ | ||
dotOffsetInSquare: number; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
这两个打上 @internal 或者直接移到 FloatButtonToken 里吧,不对外透出
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
只能放ComponentToken了,因为涉及到的计算在css实现不了
The latest updates on your projects. Learn more about Argos notifications ↗︎
|
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## feature #45861 +/- ##
=========================================
Coverage 100.00% 100.00%
=========================================
Files 706 706
Lines 12052 12083 +31
Branches 3197 3197
=========================================
+ Hits 12052 12083 +31 ☔ View full report in Codecov by Sentry. |
} = token; | ||
return { | ||
[componentCls]: { | ||
...resetComponent(token), | ||
border: 'none', | ||
position: 'fixed', | ||
cursor: 'pointer', | ||
zIndex: 99, | ||
zIndex: token.zIndexPopup, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
这个建议不改,容易 break,其他的 zIndex 也是
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
要不把 zIndexPopup 删了?因为现在这个token也没用到。
[中文版模板 / Chinese template]
🤔 This is a ...
🔗 Related issue link
💡 Background and solution
📝 Changelog
☑️ Self-Check before Merge
🚀 Summary
🤖 Generated by Copilot at 808dbd3
This pull request refactors the float button component and its group variant to use CSS variables for styling and customization. It introduces a new hook
useCSSVar
and a new functionwrapCSSVar
to register and apply the CSS variables. It also enhances the style and customization of the component by using the@ant-design/cssinjs
library and thezIndexPopup
token value. It adds a new filecomponents/float-button/style/cssVar.ts
to export theuseCSSVar
hook.🔍 Walkthrough
🤖 Generated by Copilot at 808dbd3
wrapSSR
function withwrapCSSVar
function and destructurehashId
fromuseStyle
hook inFloatButton
andFloatButtonGroup
components to use CSS variables (link,link,link,link)useCSSVar
hook from./style/cssVar
inFloatButton
andFloatButtonGroup
components to register and use CSS variables (link,link)components/float-button/style/cssVar.ts
file to exportuseCSSVar
hook that usesgenCSSVarRegister
andprepareComponentToken
functions to create a CSS variable provider and consumer for the float button component (link)unit
function from@ant-design/cssinjs
to convert numeric token values to CSS unit strings ininitFloatButtonGroupMotion
andsharedFloatButtonStyle
functions (link,link,link,link,link,link,link)calc
function from@ant-design/cssinjs
to create CSScalc
expressions for token values that accept custom CSS units or expressions infloatButtonGroupStyle
,sharedFloatButtonStyle
, and default export functions (link,link,link,link)zIndexPopup
token value instead of hard-coded99
value forzIndex
property ofFloatButton
andFloatButtonGroup
components (link,link)ComponentToken
interface to describe the meaning and usage of each token value (link)FloatButtonToken
interface to make some token values accept either a number or a string, such asfloatButtonIconSize
,floatButtonBodySize
, andbadgeOffset
(link)