How do we reuse queries?
For example, we might want to style individual components, in separate files, and we want to use the same queries inside the components. That’s why in theory I like CSS in JS because it’s super easy to reuse functions.
For example, suppose we have a media query:
@media (max-width: 12450px) { ... }
then in five other components I want to style things based on the same (possibly long query):
@media (max-width: 12450px) { ... }
@media (max-width: 12450px) { ... }
@media (max-width: 12450px) { ... }
@media (max-width: 12450px) { ... }
@media (max-width: 12450px) { ... }
If we want to update the query, we have to do it in all places, which means more maintenance and chance of error. Sass/Stylus/etc solve this for us.
It’d be great to somehow be able to reuse a query (and same with @tomhodgins’ @element
queries). F.e.:
@media:name(max) (max-width: 12450px) { /* some styles here */ }
Then in other places
@media:use(max) {
/* styles for a component, perhaps an element query for scoping. Or add more globals styles, etc. */
}