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

feat: support htmlTitle for label #19

Merged
merged 5 commits into from
Mar 30, 2022
Merged

feat: support htmlTitle for label #19

merged 5 commits into from
Mar 30, 2022

Conversation

vagusX
Copy link
Member

@vagusX vagusX commented Mar 28, 2022

规则

增加 title(html title) 属性

  • 非 object 格式则统一读取 value 值
  • object 格式则读取 label 值,label 为自定义 JSX 时则无
  • 通过 title 传入空字符串,可以覆盖掉组件默认添加 title 的行为

image

@vagusX vagusX requested review from afc163 and zombieJ March 28, 2022 11:51
@github-actions
Copy link

github-actions bot commented Mar 28, 2022

🎊 PR Preview 4d62801 has been successfully built and deployed to https://react-component-segmented-preview-pr-19.surge.sh

🕐 Build time: 154.176s

🤖 By surge-preview

src/index.tsx Outdated Show resolved Hide resolved
@codecov
Copy link

codecov bot commented Mar 28, 2022

Codecov Report

Merging #19 (4d62801) into master (7f9939f) will not change coverage.
The diff coverage is 100.00%.

@@            Coverage Diff            @@
##            master       #19   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files            1         1           
  Lines           65        72    +7     
  Branches        12        13    +1     
=========================================
+ Hits            65        72    +7     
Impacted Files Coverage Δ
src/index.tsx 100.00% <100.00%> (ø)

📣 Codecov can now indicate which changes are the most critical in Pull Requests. Learn more

@zombieJ
Copy link
Member

zombieJ commented Mar 29, 2022

选择系列的组件直接就叫 title...

src/index.tsx Outdated
@@ -33,13 +37,31 @@ export interface SegmentedProps extends React.HTMLProps<HTMLDivElement> {
motionName?: string;
}

function getValidHtmlTitle(option: SegmentedLabeledOption) {
Copy link
Member

Choose a reason for hiding this comment

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

感觉还可以再抽一个 getValid 判断 string 和 number 然后直接 return getValid(option.title) ?? getValid(option.label)

Copy link
Member Author

Choose a reason for hiding this comment

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

目前看起来这个判断是够用的,后面我考虑下,因为 title 其实要求是 string,而 label 其实在 options 下也应该要求是 string 才好,但是现在 label 是 ReactNode 所以这个判断处理起来有点怪,你可以看看新的写法

@vagusX vagusX merged commit d21beac into master Mar 30, 2022
@vagusX vagusX deleted the feat/support-html-title branch March 30, 2022 05:55
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

3 participants