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

[RFC] Define value for multiple pseudo-classes at one #504

Open
noghartt opened this issue Mar 24, 2024 · 2 comments
Open

[RFC] Define value for multiple pseudo-classes at one #504

noghartt opened this issue Mar 24, 2024 · 2 comments
Labels
enhancement New feature or request

Comments

@noghartt
Copy link

noghartt commented Mar 24, 2024

Describe the feature request

I have a specific approach where all my buttons should follow the same aspect while with disabled attribute. In that case, we should need to disable any style interaction when hovering. I think that would be a great DX improvement if we could handle more elements being applied into the same rules, or just to pseudo-class.

The current approach

This approach is what is working now:

const styles = stylex.create({
  root: {
    opacity: {
      default: 0.5,
      ':hover': 1,
      ':focus': 1,
    },
  },
};

Proposal

What I proposing is handle all these pseudo-class into just one object, for example:

const styles = stylex.create({
  root: {
    opacity: {
      default: 0.5,
      ':hover, :focus': 1,
    },
  },
};
@noghartt noghartt added the enhancement New feature or request label Mar 24, 2024
@necolas
Copy link
Contributor

necolas commented Mar 25, 2024

Typically you'd know when you're setting the disabled prop and can use the prop value as a condition to set the relevant disabled styles, rather than needing a CSS selector.

@nmn
Copy link
Contributor

nmn commented Mar 31, 2024

@noghartt I updated your proposal to use the correct syntax for using pseudo-classes in StyleX.

This is a known paper-cut and I'm considering possible ways to improve this, but it's currently a lower priority.

Alternative:

  • ':is(:hover, :focus)'

The benefit of this approach is that it works today and we can simply optimise this use-case in the future.

@nmn nmn changed the title Accept handle more pseudo-class for the same style [RFC] Define value for multiple pseudo-classes at one Mar 31, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants