-
Notifications
You must be signed in to change notification settings - Fork 298
refactor(Rate): v16 适配 #3487
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
Merged
Merged
refactor(Rate): v16 适配 #3487
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
71a5a15
refactor(Rate): v16适配 - 新增layout/label属性,重构尺寸体系
xiyehutao 16aa92e
feat(Rate): 新增选中过渡动画(尺寸≥20px自动启用)
xiyehutao f959a54
docs(Rate): 新增过渡动画 demo
xiyehutao 1c94d7d
fix(Rate): 补充主题变量文件中缺失的 $rate-label-color
xiyehutao a1ac0c2
chore(Rate): 同步 NutCSSVariables 类型声明
xiyehutao bd44d3f
refactor(Rate): 将 layout 属性重命名为 direction
xiyehutao File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 |
|---|---|---|
| @@ -0,0 +1,21 @@ | ||
| import React from 'react' | ||
| import { Rate, Space } from '@nutui/nutui-react' | ||
|
|
||
| const Demo13 = () => { | ||
| return ( | ||
| <Space direction="vertical" style={{ width: '100%' }}> | ||
| <Rate | ||
| defaultValue={4} | ||
| direction="vertical" | ||
| label={['不满意', '', '', '', '非常满意']} | ||
| /> | ||
| <Rate | ||
| defaultValue={4} | ||
| direction="vertical" | ||
| size="large" | ||
| label={['不满意', '', '', '', '非常满意']} | ||
| /> | ||
| </Space> | ||
| ) | ||
| } | ||
| export default Demo13 |
This file contains hidden or 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 |
|---|---|---|
| @@ -0,0 +1,19 @@ | ||
| import React from 'react' | ||
| import { Rate, Space } from '@nutui/nutui-react' | ||
|
|
||
| const Demo14 = () => { | ||
| return ( | ||
| <Space direction="vertical" style={{ width: '100%' }}> | ||
| <Rate defaultValue={4} size="small" label="一键评分" /> | ||
| <Rate defaultValue={4} label="一键评分" /> | ||
| <Rate defaultValue={4} size="large" label="一键评分" /> | ||
| <Rate | ||
| defaultValue={4} | ||
| direction="vertical" | ||
| size="large" | ||
| label={['非常不满', '不满意', '一般', '满意', '非常满意']} | ||
| /> | ||
| </Space> | ||
| ) | ||
| } | ||
| export default Demo14 |
This file contains hidden or 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 |
|---|---|---|
| @@ -0,0 +1,12 @@ | ||
| import React from 'react' | ||
| import { Rate, Space } from '@nutui/nutui-react' | ||
|
|
||
| const Demo15 = () => { | ||
| return ( | ||
| <Space direction="vertical" style={{ width: '100%' }}> | ||
| <Rate defaultValue={0} size="large" /> | ||
| <Rate defaultValue={0} direction="vertical" size="large" /> | ||
| </Space> | ||
| ) | ||
| } | ||
| export default Demo15 |
This file contains hidden or 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 |
|---|---|---|
| @@ -1,7 +1,12 @@ | ||
| import React from 'react' | ||
| import { Rate } from '@nutui/nutui-react' | ||
| import { Rate, Space } from '@nutui/nutui-react' | ||
|
|
||
| const Demo9 = () => { | ||
| return <Rate defaultValue={3} readOnly /> | ||
| return ( | ||
| <Space direction="vertical"> | ||
| <Rate defaultValue={3} readOnly /> | ||
| <Rate defaultValue={4} readOnly showScore label="评分" /> | ||
| </Space> | ||
| ) | ||
| } | ||
| export default Demo9 |
This file contains hidden or 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 hidden or 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 |
|---|---|---|
| @@ -0,0 +1,21 @@ | ||
| import React from 'react' | ||
| import { Rate, Space } from '@nutui/nutui-react-taro' | ||
|
|
||
| const Demo13 = () => { | ||
| return ( | ||
| <Space direction="vertical" style={{ width: '100%' }}> | ||
| <Rate | ||
| defaultValue={4} | ||
| direction="vertical" | ||
| label={['不满意', '', '', '', '非常满意']} | ||
| /> | ||
| <Rate | ||
| defaultValue={4} | ||
| direction="vertical" | ||
| size="large" | ||
| label={['不满意', '', '', '', '非常满意']} | ||
| /> | ||
| </Space> | ||
| ) | ||
| } | ||
| export default Demo13 |
Oops, something went wrong.
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.
避免在 Line 39 用条件分支包裹核心断言,防止测试静默通过。
这里把所有关键校验都放进
if (el && valueEl),一旦选择器失效会直接跳过断言,测试会误通过。建议先显式断言节点存在,再执行后续行为断言。建议修改
const valueEl = container.querySelector('.score') const el = container.querySelectorAll('.nut-rate-item') - if (el && valueEl) { - expect(el.length).toBe(state.count) - expect(el[2].childNodes[0]).toHaveClass('nut-rate-item-icon') - expect(el[2].childNodes[0].childNodes[0]).toHaveClass('nut-icon-HeartFill') - expect(el[3].childNodes[0]).toHaveClass('nut-rate-item-icon-disabled') - expect(el[3].childNodes[0].childNodes[0]).toHaveClass('nut-icon-Heart') - fireEvent.click(el[1]) - expect(valueEl.innerHTML).toBe('2') - } + expect(valueEl).toBeTruthy() + expect(el.length).toBe(state.count) + expect(el[2].childNodes[0]).toHaveClass('nut-rate-item-icon') + expect(el[2].childNodes[0].childNodes[0]).toHaveClass('nut-icon-HeartFill') + expect(el[3].childNodes[0]).toHaveClass('nut-rate-item-icon-disabled') + expect(el[3].childNodes[0].childNodes[0]).toHaveClass('nut-icon-Heart') + fireEvent.click(el[1]) + expect(valueEl!.innerHTML).toBe('2')🤖 Prompt for AI Agents