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

Support for pseudo-selectors (ex, :hover) and pseudo-elements (ex, ::after) #14

Open
ZeeCoder opened this issue Mar 3, 2017 · 8 comments

Comments

@ZeeCoder
Copy link
Owner

ZeeCoder commented Mar 3, 2017

This would probably require a lot more thought put into it, but it should be possible to apply styles only on hover / focus etc events.

Example: Increasing font-size on hover.

@ZeeCoder ZeeCoder changed the title Support for pseudo-selectors, like :hover Support for pseudo-selectors (ex, :hover) and pseudo-elements (ex, ::after) Jan 3, 2018
@ZeeCoder
Copy link
Owner Author

ZeeCoder commented Jan 3, 2018

::before / ::after also should definitely be supported.

@ahmadalfy
Copy link

I would love to try and take a look at it.

@ZeeCoder
Copy link
Owner Author

Sounds good 👍

It might be a bit tricky, as what the plugin does is that instead of adding CSS to the DOM based on certain element conditions, it instead keeps track of all elements, and applies styles directly to them.

This means that to have support for pseudo-selectors, it would need to add / remove event listeners as conditions change.

If you want to give it a go, I can have a think of what the best solution would be, as it probably requires a refactor that either:

  1. Allows the code to react to these condition changes somewhere in a smarter way, or
  2. Replaces the current CSS-applying engine with one that injects actual CSS into the DOM, in which case implementing pseudo-selectors would be a no-brainer. 🤔

I have a gut-feeling the second option is probably the best one.

@ZeeCoder
Copy link
Owner Author

Actually, using something like styletron to handle css applying based on style objects would be the easiest, since then we wouldn't need to come up with a way to apply styles for only certain elements ourselves.

@ahmadalfy
Copy link

Thanks for the insights, I am currently examining the code and checking what can be done. Will keep your words in mind and update you with the results.

@ZeeCoder
Copy link
Owner Author

Sure, no worries 👍
Have you tried the package in a project already, or just planning to?

@ahmadalfy
Copy link

ahmadalfy commented Apr 23, 2018

I am currently using the package in a project and it fits perfectly really. I've a valid use case for container query (or element query whatever people prefer to call it) and I was hit by the lack of support for the pseudo-classes 😆 and this is why I am seeing how to contribute 😄

@ZeeCoder
Copy link
Owner Author

Got it, thanks 👍

I thought someone would sooner or later want this feature. 😅

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants