-
-
Notifications
You must be signed in to change notification settings - Fork 51.6k
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
feat: Typography add suffix #20224
feat: Typography add suffix #20224
Conversation
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.
Could you please add tests to make sure this change works as expected?
Deploy preview for ant-design ready! Built with commit b342944 |
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 b342944:
|
Codecov Report
@@ Coverage Diff @@
## 4.0-prepare #20224 +/- ##
===============================================
+ Coverage 97.56% 97.56% +<.01%
===============================================
Files 295 295
Lines 6852 6853 +1
Branches 1842 1873 +31
===============================================
+ Hits 6685 6686 +1
Misses 167 167
Continue to review full report at Codecov.
|
components/typography/demo/suffix.md
Outdated
<Paragraph ellipsis={{ rows, suffix: songForDrinking }} title={poetry + songForDrinking}> | ||
<Text code strong> | ||
将进酒 | ||
</Text> |
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.
留一个英文的例子就行了
components/typography/demo/suffix.md
Outdated
</Text> | ||
{poetry} | ||
</Paragraph> | ||
<Paragraph ellipsis={{ rows, expandable: true, suffix: hamlet }} title={article + hamlet}> |
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.
suffix: hamlet
直接写到这里,不用经过 state
。让例子尽可能简单,用户易于理解。
为何 snapshot 会变? |
components/date-picker/__tests__/__snapshots__/other.test.js.snap
Outdated
Show resolved
Hide resolved
components/typography/util.tsx
Outdated
{(ellipsisStr + suffix) | ||
.split('') | ||
.reverse() | ||
.join('')} |
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.
如果后缀都溢出
那么后缀也需要开始省略,但是后缀省略是需要往前面省略的。
这样倒过来还是可以复用 measureText 方法
components/typography/Base.tsx
Outdated
// We move full content to outer element to avoid repeat read the content by accessibility | ||
textNode = ( | ||
<span title={String(children)} aria-hidden="true"> | ||
<span title={title} aria-hidden="true"> |
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.
这里有 title
用 title
,如果没有但是 children
是 string | number
则用 children
。
components/typography/Base.tsx
Outdated
const { children } = this.props; | ||
if (!rows || rows < 0 || !this.content || expanded) return; | ||
|
||
// Do not measure if css already support ellipsis | ||
if (this.canUseCSSEllipsis()) return; | ||
if (this.canUseCSSEllipsis() && !suffix) return; |
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.
suffix
移入 canUseCSSEllipsis
方法内。
components/typography/Base.tsx
Outdated
// We move full content to outer element to avoid repeat read the content by accessibility | ||
textNode = ( | ||
<span title={String(children)} aria-hidden="true"> | ||
<span title={title || String(children)} aria-hidden="true"> |
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.
这里和上面的 ariaLabel
已经一模一样了,直接放进来不用重复执行
希望后缀是 ReactNode 而不只是string |
🤔 This is a ...
🔗 Related issue link
💡 Background and solution
📝 Changelog
☑️ Self Check before Merge
View rendered components/typography/demo/suffix.md
View rendered components/typography/index.en-US.md
View rendered components/typography/index.zh-CN.md