-
-
Notifications
You must be signed in to change notification settings - Fork 49k
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
fix(Modal): fix confirm icon style when using third-party icons #48490
base: master
Are you sure you want to change the base?
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -44,7 +44,8 @@ const genModalConfirmStyle: GenerateStyle<ModalToken> = (token) => { | |||||
flexWrap: 'nowrap', | ||||||
alignItems: 'start', | ||||||
|
||||||
[`> ${token.iconCls}`]: { | ||||||
[`> ${confirmComponentCls}-icon`]: { | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
这样吧。 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 我还是想尽量不动 dom 结构。 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ping |
||||||
display: 'flex', | ||||||
flex: 'none', | ||||||
fontSize: modalConfirmIconSize, | ||||||
marginInlineEnd: token.confirmIconMarginInlineEnd, | ||||||
|
@@ -53,7 +54,7 @@ const genModalConfirmStyle: GenerateStyle<ModalToken> = (token) => { | |||||
.div(2) | ||||||
.equal(), | ||||||
}, | ||||||
[`&-has-title > ${token.iconCls}`]: { | ||||||
[`&-has-title > ${confirmComponentCls}-icon`]: { | ||||||
marginTop: token | ||||||
.calc(token.calc(modalTitleHeight).sub(modalConfirmIconSize).equal()) | ||||||
.div(2) | ||||||
|
@@ -69,7 +70,7 @@ const genModalConfirmStyle: GenerateStyle<ModalToken> = (token) => { | |||||
}, | ||||||
|
||||||
// https://github.com/ant-design/ant-design/issues/48159 | ||||||
[`${token.iconCls} + ${confirmComponentCls}-paragraph`]: { | ||||||
[`${confirmComponentCls}-icon + ${confirmComponentCls}-paragraph`]: { | ||||||
maxWidth: `calc(100% - ${unit( | ||||||
token.calc(token.modalConfirmIconSize).add(token.marginSM).equal(), | ||||||
)})`, | ||||||
|
@@ -100,20 +101,21 @@ const genModalConfirmStyle: GenerateStyle<ModalToken> = (token) => { | |||||
}, | ||||||
}, | ||||||
|
||||||
[`${confirmComponentCls}-error ${confirmComponentCls}-body > ${token.iconCls}`]: { | ||||||
[`${confirmComponentCls}-error ${confirmComponentCls}-body > ${confirmComponentCls}-icon`]: { | ||||||
color: token.colorError, | ||||||
}, | ||||||
|
||||||
[`${confirmComponentCls}-warning ${confirmComponentCls}-body > ${token.iconCls}, | ||||||
${confirmComponentCls}-confirm ${confirmComponentCls}-body > ${token.iconCls}`]: { | ||||||
color: token.colorWarning, | ||||||
}, | ||||||
[`${confirmComponentCls}-warning ${confirmComponentCls}-body > ${confirmComponentCls}-icon, | ||||||
${confirmComponentCls}-confirm ${confirmComponentCls}-body > ${confirmComponentCls}-icon`]: | ||||||
{ | ||||||
color: token.colorWarning, | ||||||
}, | ||||||
|
||||||
[`${confirmComponentCls}-info ${confirmComponentCls}-body > ${token.iconCls}`]: { | ||||||
[`${confirmComponentCls}-info ${confirmComponentCls}-body > ${confirmComponentCls}-icon`]: { | ||||||
color: token.colorInfo, | ||||||
}, | ||||||
|
||||||
[`${confirmComponentCls}-success ${confirmComponentCls}-body > ${token.iconCls}`]: { | ||||||
[`${confirmComponentCls}-success ${confirmComponentCls}-body > ${confirmComponentCls}-icon`]: { | ||||||
color: token.colorSuccess, | ||||||
}, | ||||||
}; | ||||||
|
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.
直接这样改如何?
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.
@afc163 这样会覆盖掉原本的 icon 的 className 吧,而且也有可能组件不支持外部传入 className
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.
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.
效果相同的情况下,感觉使用 cloneElement 会更慢。
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.
感觉?没有道理更慢吧
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.
任何 clone 的过程都是耗时的。而且 React 官方文档里并不推荐用 cloneElement https://react.dev/reference/react/cloneElement