Skip to content

Support for # id selectors #79

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

Closed
wants to merge 1 commit into from
Closed

Support for # id selectors #79

wants to merge 1 commit into from

Conversation

gregnb
Copy link

@gregnb gregnb commented Apr 23, 2017

Working on a recent project I needed support for # id selectors. I see that they are being passed in but there was no transformation for them. Only classes. Using the JSX attribute 'styleId' this will override the "id" attribute and fill it with the namespaced style using either string literal/JSX expressions

Usage:

Demo.css

#simpleEl {
   background-color: #FF0000;
}

Demo.js

import React from 'react';
import './demo.css';

export default () => {
  return (
    <div>
      <div styleId='simpleEl'>
      </div>
      <div styleId={'simpleEl'}>
      </div>
  ); 
};

@tyler-dot-earth
Copy link

What you're requesting is a change to CSS modules concept itself, I think. Feels outside the scope of babel-plugin-react-css-modules to me.

@gregnb
Copy link
Author

gregnb commented Apr 23, 2017

Ah, ok no problem. I understand. Thanks @tsniemam - Just seeing those id computed styles still coming through css-loader figured things would be ok.

@gajus
Copy link
Owner

gajus commented Apr 24, 2017

Working on a recent project I needed support for # id selectors. I see that they are being passed in but there was no transformation for them.

There is just no use for them in css-modules.

You can simply convert CSS to use classes and still assign the element an ID for whatever JS manipulation.

@gajus gajus closed this Apr 24, 2017
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.

3 participants