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

Improvement to autocomplete for camelization of classnames #3

Closed
kumarharsh opened this issue Mar 2, 2017 · 11 comments
Closed

Improvement to autocomplete for camelization of classnames #3

kumarharsh opened this issue Mar 2, 2017 · 11 comments

Comments

@kumarharsh
Copy link
Contributor

Hi, it's really good to see the autocomplete coming to imported css-modules. I'm using a flag in my css-loader named camelCase which lets me write camelCase class names in my javascript, but still let me write kebab-case classes in my css file. Can this plugin support that usecase? I can submit a PR if you'd like to include it in the plugin.

@clinyong
Copy link
Owner

clinyong commented Mar 2, 2017

Yes, I am so glad to see your PR.

@evisong
Copy link

evisong commented Mar 2, 2017

I've got the same requirement: styles['link-label-disabled']. Looking forward to this PR.

Also, thanks for the plugin.

@evisong
Copy link

evisong commented Mar 6, 2017

Hi, @kumarharsh and @clinyong , we have different use case in our project.

To our developers, CSSModule's camelCase=true changes link-label-disabled to linkLabelDisabled, which seems kinds of "magic" and is implicit. They prefer to keep using styles['link-label-disabled'] instead of styles.linkLabelDisabled in JS so that future search/replace would be easier.

Btw, in bundled JS, CSSModule's camelCase=true keeps the original key and appends a new camelCase key, which is somehow a duplicate. This may add 70 kB bundle size when there is 1000 CSS Module classes in the project.

Is it possible to support such use case in the plugin as well?

Looking forward to your feedback. Thanks.

@kumarharsh
Copy link
Contributor Author

@evisong If your devs use the kebab-case classes in JS, then you don't need to set camelCase property at all.

@clinyong
Copy link
Owner

clinyong commented Mar 6, 2017

@kumarharsh is right. And I prefer camelCase classes in JS.

Btw, in bundled JS, CSSModule's camelCase=true keeps the original key and appends a new camelCase key, which is somehow a duplicate. This may add 70 kB bundle size when there is 1000 CSS Module classes in the project.

The plugin can not do this.

@kumarharsh
Copy link
Contributor Author

kumarharsh commented Mar 7, 2017

The plugin can not do this.

@evisong The retention of the original key and the camelized keys is done by the css-loader plugin. You'll have to ask them for this. This is just an editor plugin.

@evisong
Copy link

evisong commented Mar 13, 2017

If your devs use the kebab-case classes in JS, then you don't need to set camelCase property at all.

@kumarharsh, thanks for your timely response, sorry I didn't notice the email notification.

Maybe a picture would better explain my proposed feature:

src_spark_spark-link_components_link_jsx_-_spark-ui

Please look into the yellow text, when selecting ['link-in-group'] option, the plugin will automatically delete the . and append ['link-in-group'] in editor, @clinyong do you think this is a valid use case?

Thanks.

@evisong
Copy link

evisong commented Mar 13, 2017

The retention of the original key and the camelized keys is done by the css-loader plugin. You'll have to ask them for this.

@kumarharsh You're right. Will do, thanks.

@kumarharsh
Copy link
Contributor Author

@evisong it's already done actually 😉 webpack-contrib/css-loader#440 (comment)

@evisong
Copy link

evisong commented Mar 14, 2017

it's already done actually 😉 webpack-contrib/css-loader#440 (comment)

You're super! Thanks.

@evisong
Copy link

evisong commented Mar 14, 2017

Just created a similar ticket to css-modules-require-hook: css-modules/css-modules-require-hook#89, as we're using babel-plugin-css-modules-transform instead of css-loader.

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

No branches or pull requests

3 participants