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: Add option to show kebab-case component names #911

Merged
merged 3 commits into from
Jun 25, 2019

Conversation

Aareksio
Copy link
Contributor

@Aareksio Aareksio commented Mar 25, 2019

The change replaces classifyComponents setting with new componentNameStyle, allowing for additional styles of component names including kebab-case.Also provides somehow standardized approach to transforming component names for display.

preview

// Instead of:
return this.$shared.classifyComponents ? classify(this.instance.name) : this.instance.name

// We now do:
return getComponentDisplayName(this.instance.name, this.$shared.componentNameStyle)

I had to double check filter-instances, but it seem to work alright, as both the filtered value and component names are passed through classify (expect here, but it's dead code, so I left it untouched).

I am not particularly proud of kebabize function, I tried to keep it close to already existing, similiar functions (classify and camelize), but it turned rather ugly - I'll be glad if you suggest how it could be improved!

One other thing worth mention is that I initially considered using enum instead of a string value for componentNameStyle value, but since there are no enums currently in the project and similar properties (eg. displayDensity) uses strings as well, I dropped the idea.

Motivation

Inspired by #239, the style guide and my strong preferences towards kebab-case in anything HTML-alike.

Currently present "original" option often leaves us with inconsistencies when using 3rd party libraries which use different casing than the one adopted in the project.

Since there are 2 widely accepted casings, we should be able to coerce to either of them.

Afterthoughts

getComponentDisplayName could potentially return Anonymous Component when the name string is empty.

Consider renaming getComponentDisplayName to normalizeComponentName to match the label?

This change allows for multiple additional styles of component displayed names, most importantly kebab-case
src/util.js Outdated Show resolved Hide resolved
@Akryum Akryum changed the title Add option to show kebab-case component names feat: Add option to show kebab-case component names Jun 25, 2019
@Akryum Akryum merged commit 971e5e2 into vuejs:dev Jun 25, 2019
@vue-bot
Copy link

vue-bot commented Jun 25, 2019

Hey @Aareksio, thank you for your time and effort spent on this PR, contributions like yours help make Vue better for everyone. Cheers! 💚

sp1ker pushed a commit to sp1ker/vue-devtools that referenced this pull request Aug 24, 2020
* Replace `classifyComponents` with `componentNameStyle`

This change allows for multiple additional styles of component displayed names, most importantly kebab-case

* Remove leftover console.log


Co-authored-by: Guillaume Chau <[email protected]>
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.

4 participants