container-query
container-query copied to clipboard
Support for pseudo-selectors (ex, :hover) and pseudo-elements (ex, ::after)
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.
::before
/ ::after
also should definitely be supported.
I would love to try and take a look at it.
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:
- Allows the code to react to these condition changes somewhere in a smarter way, or
- 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.
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.
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.
Sure, no worries 👍 Have you tried the package in a project already, or just planning to?
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 😄
Got it, thanks 👍
I thought someone would sooner or later want this feature. 😅