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

Injection order handling as jss does #57

Closed
basile-savouret opened this issue Feb 3, 2022 · 2 comments
Closed

Injection order handling as jss does #57

basile-savouret opened this issue Feb 3, 2022 · 2 comments

Comments

@basile-savouret
Copy link

Hi, thank you for the awesome work you are providing here.

I'm using tss to replace makestyles on a mui migration.
I have a component library that i use in an application i am currently migrating to mui v5.
Both of them are using tss and i am struggling with style injection, the same way i struggled with the makeStyle back to mui v4.

here in my application:
image
The first tss class is comming from my library and should be placed below the second.

My classes are declared with clsx like so:

className={clsx(
     className,
     'AruiAppBar-root',
     defaultStyles.classes.root
)}

For jss i quickly found the index option provided on a makestyle that can tell the injection priority.
Is there anything similar in tss?

I saw in this ticket #56 that the placement of the classes does a difference in the cx function.
Is it the same foc clsx? I remember on mui they specified that the placement does not impact the injection of the styles.
Do i have to use the function cx insted of clsx?

@garronej
Copy link
Owner

garronej commented Feb 3, 2022

@basile-savouret,

Thank you for the kind words,

cx is a lot smarter than cslx, it is capable of enforcing that if you call cx(className1, className2) the styles of className2 will have a higher priority than the styles of className1.

It is a great emotion feature that gives you control over how things are rendered. You should definitely stop using cslx in favor of cx.

You optain cx this way:

const { classes, cx } = useStyles();

Just in case you didn't notice, there is a new documentation website:

https://docs.tss-react.dev/setup

There is a mention about cx in the setup page.

Best regards

@basile-savouret
Copy link
Author

@garronej ,

Thank you for your answer. I have looked up at the new documentation but i was mainly researching a similar approach as jss index in tss.

You could add a brief sentence about the injection priority handling with cx in your docs, just to clarify it.
I'm going to migrate all my cslx.

Thank you for your precious help, i wish you the best for the future.

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

2 participants