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

Idea: make the class name prefix 'x' a parameter #83

Open
rlopes opened this issue Sep 10, 2017 · 4 comments
Open

Idea: make the class name prefix 'x' a parameter #83

rlopes opened this issue Sep 10, 2017 · 4 comments

Comments

@rlopes
Copy link

rlopes commented Sep 10, 2017

I have a few components that are built separately as different bundles. They come with their own styles and get merged into an app.
However, I am not sure cxs supports that kind of use case. Since style tags are added to the parent HTML document there are collisions.

in src/cxs/index.js, line 20 we have this: const className = 'x' + (rules.length).toString(36)
'x' is a hardcoded prefix. What if we allow alternative prefixes to be passed? Ideally once at initialization of the library.

That way we could define separate prefixes in different projects and when they get mashed up (at runtime for example), the written styles do not collide.

@rlopes rlopes changed the title Idea: make the class name suffix 'x' a parameter Idea: make the class name prefix 'x' a parameter Sep 10, 2017
@jxnblk
Copy link
Collaborator

jxnblk commented Sep 17, 2017

Yeah, I've thought about exposing cxs.prefix to allow that to be changes like so:

import cxs from 'cxs'
cxs.prefix = '_cxs'

As far as importing components that use cxs, I haven't run into issues with my own use FWIW. There should only be one cxs instance when you're using a bundler like webpack, so all components in a bundle/app should be working off of the same ID system

@richard-lopes
Copy link
Contributor

Sounds good. Yes in our case these are components (mini apps) imported and rendered at runtime not compile. In that case cxs is bundled several times if you see what I mean.

@aaronyo
Copy link
Contributor

aaronyo commented Sep 20, 2017

+1

I'm using cxs for a chrome extension that augments gmail, but gmail declares several two character classnames matching x*.

The PR sounds straightforward enough. Should I submit one?

@richard-lopes
Copy link
Contributor

The new monolithic.js fie seems to have the feature. It is used by the monocomponent.
It that same feature coming in vanilla cxs?
I have a feeling there is bit of documentation to write with all the goodies you have been working on in the past 2 weeks 👍

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

4 participants