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

Reference another stylesheet #1656

Open
bsShoham opened this issue Feb 5, 2024 · 0 comments
Open

Reference another stylesheet #1656

bsShoham opened this issue Feb 5, 2024 · 0 comments

Comments

@bsShoham
Copy link

bsShoham commented Feb 5, 2024

Is your feature request related to a problem? Please describe.

As a user of React-JSS I would like to override children component styles without specifity hacks.
For example I have a Button component that its background color is red , and I have a Button Group component that sets the default background color of all child buttons to yellow, I would like to reference the button to sheet to override it.
The current outcome css would be something like

// from createUseStyles at "button.tsx"
{
  small: {},
  primary: {},
  button: {
   "&$primary$small": {
       backgroundColor: "red"
     }
  }
}

turns into

.button-1-0-1.primary-1-2-0.small-1-0-0 {
  background-color: "red"
}

and

// from createUseStyles at "button-group.tsx"
{
  childButton: {}, // given through className to all children buttons
  buttonGroup: {
   "& > $childButton": {
       backgroundColor: "yellow"
     }
  }
}

turns into

.buttonGroup-2-2-1 > .childButton-1-0-2 {
 background-color: "yellow"
}

the specifity of the button sheet is stronger,
currently to beat it I would have to do some hacks like that

{
  childButton: {},
  buttonGroup: {
   "& > $childButton$childButton$childButton": {
       backgroundColor: "yellow"
     }
  }
}

Describe the solution you'd like
I would like to be able to reference another sheet perhaps by code (importing the other use styles and referencing it in mine),
another option is to add another special reference syntax maybe something like

{
  childButton: {},
  buttonGroup: {
   "& > $childButton%buttonSheet$button": {
       backgroundColor: "yellow"
     }
  }
}

Are you willing to implement it?
Willing to try, would love maybe some guidance to start

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

1 participant