afonsolage / bevy_ecss

Bevy crate which uses a subset of CSS to update Bevy ECS components
Apache License 2.0
98 stars 11 forks source link

Any (*) Component Selector #44

Closed TheDudeFromCI closed 6 months ago

TheDudeFromCI commented 7 months ago

The inclusion of an "any" selector would be useful for defining global rules across the entire style sheet. This would also help to close the gap slightly between bevy_ecss and pure css.

afonsolage commented 7 months ago

This seems very reasonable.

* {
    color: red
}

Selects all entities.

* text {
    color: red
}

Selects any entity which has a Text components and is descendant or not of any another entity.

Bevy 0.13 is right around the corner, I'll add this when upgrading to Bevy 0.13

reference: https://developer.mozilla.org/en-US/docs/Web/CSS/Universal_selectors

TheDudeFromCI commented 7 months ago

As a workaround, I've found using the node component selector has effectively the same function in most cases, since all bevy_ui components implement this component. It's not quite the same (such as if using a custom UI crate, or just readability), but close enough for practical purposes.