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

perf(docs): optimize ComponentProps #2012

Merged
merged 5 commits into from
Sep 11, 2017
Merged

perf(docs): optimize ComponentProps #2012

merged 5 commits into from
Sep 11, 2017

Conversation

layershifter
Copy link
Member

@layershifter layershifter commented Aug 28, 2017

ComponentProps

Components was splitted to multiple sub-components. Props info transforms was moved to our gulp doc plugin.

Before

Action Time
Show/hide enums (4 times) 40.88
Switch props tab (4 times) 37.03

After

Action Time
Show/hide enums (4 times) 11.16
Switch props tab (4 times) 36.67

@codecov-io
Copy link

codecov-io commented Aug 28, 2017

Codecov Report

Merging #2012 into master will not change coverage.
The diff coverage is n/a.

Impacted file tree graph

@@           Coverage Diff           @@
##           master    #2012   +/-   ##
=======================================
  Coverage   99.76%   99.76%           
=======================================
  Files         148      148           
  Lines        2561     2561           
=======================================
  Hits         2555     2555           
  Misses          6        6

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 7f39631...650068d. Read the comment docs.

@layershifter layershifter changed the title perf(docs): optimize ComponentProps perf(docs): optimize ComponentProps and ComponentExample Aug 28, 2017
@layershifter layershifter changed the title perf(docs): optimize ComponentProps and ComponentExample perf(docs): optimize ComponentProps Sep 1, 2017
Copy link
Member Author

@layershifter layershifter left a comment

Choose a reason for hiding this comment

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

@levithomason I wanted to add there changes that will affect ComponentExample, but later I understood that it has already enough changes. So, it's ready for review.

}
}

export default pure
Copy link
Member

Choose a reason for hiding this comment

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

I believe this can be replaced by extending React.PureComponent, correct?

{...item}
key={item.name}
showEnums={showEnumsFor[item.name]}
onToggleEnum={this.toggleEnumsFor(item.name)}
Copy link
Member

Choose a reason for hiding this comment

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

Since the showEnums state is only needed within ComponentPropsRow, I think we can push it down another level. The parent doesn't need to re-render when the child shows/hides enums.

@@ -7,7 +7,9 @@ import ComponentPropsExtra from './ComponentPropsExtra'
import ComponentPropsToggle from './ComponentPropsEnumToggle'
import ComponentPropsValue from './ComponentPropsEnumValue'

const ComponentPropsEnum = ({ limit, showAll, toggle, values }) => {
const ComponentPropsEnum = ({ limit, showAll, toggle, type, values }) => {
Copy link
Member

Choose a reason for hiding this comment

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

The limit was added because of the Icon names and Flag names. However, those props do not show enums as they are {custom}. I almost want to just show all enums and do away with the state.

At the least, let's increase the limit to 50. Most examples have much less than 50 enums, and 50 will still fit OK. Here are a few examples of our larger lists that show we can easily work with a limit of 50:

Grid.Row
color is especially funny as it a very common prop and we hide only 3 of them 😂
http://g.recordit.co/27LVhsq9Rj.gif

Transition
http://g.recordit.co/JYMjLC3xIP.gif

Copy link
Member Author

Choose a reason for hiding this comment

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

Thanks for reminding, customPropTypes.suggest should be also parsed as enum, I will update it separate PR.

Copy link
Member Author

@layershifter layershifter left a comment

Choose a reason for hiding this comment

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

@levithomason I've applied requested changes 👍

@levithomason levithomason merged commit 598212f into master Sep 11, 2017
@levithomason
Copy link
Member

💥

@levithomason levithomason deleted the perf/docs-stage2 branch September 11, 2017 03:34
@levithomason
Copy link
Member

Released in semantic-ui-react@0.73.0

layershifter added a commit that referenced this pull request Sep 11, 2017
* perf(docs): optimize ComponentProps

* fix(HOC): use PureComponent for pure() HOC

* fix(ComponentProps): update `limit` value

* feat(ComponentProps): make ComponentProps functional component, move toggleEnums logic down
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants