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
Open
guoyunhe
wants to merge
2
commits into
ant-design:master
Choose a base branch
from
guoyunhe:fix-modal-icon-color
base: master
Could not load branches
Branch not found: {{ refName }}
Could not load tags
Nothing to show
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 结构。 |
||||||
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, | ||||||
}, | ||||||
}; | ||||||
|
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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