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(rate): add disabled prop and clean code #474

Merged
merged 54 commits into from
Jul 12, 2021

Conversation

doom-9-zz
Copy link
Contributor

No description provided.

doom-9 and others added 30 commits June 17, 2021 17:42
@vercel
Copy link

vercel bot commented Jul 11, 2021

This pull request is being automatically deployed with Vercel (learn more).
To see the status of your deployment, click below or on the icon next to each commit.

🔍 Inspect: https://vercel.com/tusimple/naive-ui/7mZ5dEwoAGSFBJiRmaZNEN7YH1vi
✅ Preview: https://naive-ui-git-fork-doom-9-featrate-tusimple.vercel.app

@codecov
Copy link

codecov bot commented Jul 11, 2021

Codecov Report

Merging #474 (fdc684c) into main (6ff56c5) will increase coverage by 0.01%.
The diff coverage is 75.00%.

Impacted file tree graph

@@            Coverage Diff             @@
##             main     #474      +/-   ##
==========================================
+ Coverage   37.05%   37.06%   +0.01%     
==========================================
  Files         507      507              
  Lines       12179    12180       +1     
  Branches     3351     3353       +2     
==========================================
+ Hits         4513     4515       +2     
+ Misses       6804     6803       -1     
  Partials      862      862              
Impacted Files Coverage Δ
src/rate/src/Rate.tsx 68.88% <75.00%> (+2.97%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 6ff56c5...fdc684c. Read the comment docs.

@Talljack
Copy link
Contributor

add test cases

Comment on lines 168 to 173
onClick={(e) => {
this.handleClick(index, e)
!disabled && this.handleClick(index, e)
}}
onMousemove={(e) => {
this.handleMouseMove(index, e)
!disabled && this.handleMouseMove(index, e)
}}
Copy link
Collaborator

Choose a reason for hiding this comment

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

话说都在这里用到了 disabled,那么不如直接在事件处理器层面优化一下

例如 :onMousemove={disabled ? undefined : (e) => { this.handleMouseMove(index, e) }},这种写法虽然在事件太多的时候可能记不起来,但是在事件少的时候性能会(无法感知)的稍微好一点。

@@ -0,0 +1,5 @@
# Read only
Copy link
Collaborator

Choose a reason for hiding this comment

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

readonly and disabled are 2 different concept. In the PR, readonly prop is better than disabled.

Compared with readonly, disabled awalys means different looking.

# Read only

```html
<n-rate disabled :default-value="3" />
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
<n-rate disabled :default-value="3" />
<n-rate readonly :default-value="3" />

c('&:active', {
transform: 'none'
})
])
]),
cE('half', `
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
cE('half', `
cNotM('readonly', [
cE('item', [
c('&:hover', transform: 'scale(1.05)')...
])
]),
cE('half', `

Comment on lines 41 to 50
cM('disabled', {
cursor: 'default'
}, [
c('&:hover', {
transform: 'none'
}),
c('&:active', {
transform: 'none'
})
])
Copy link
Collaborator

Choose a reason for hiding this comment

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

readonly 这种样式尽量加到最外层,因为全局生效的,除非不得不局部控制,比如说 tree,我们尽量把类都写在根部。

@XieZongChen
Copy link
Collaborator

以后可以尝试使用 git rebase 操作,这样的提交记录比 git pullgit merge 的提交记录更纯净

@doom-9-zz
Copy link
Contributor Author

以后可以尝试使用 git rebase 操作,这样的提交记录比 git pullgit merge 的提交记录更纯净
我就是rebase的main分支😄

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.

5 participants