JonHMChan / descartes

Descartes | Write CSS in JavaScript
https://descartes.io/slides
MIT License
444 stars 21 forks source link

Handling multiple style trees #41

Open JonHMChan opened 8 years ago

JonHMChan commented 8 years ago

A very common practice is to split styles into multiple files, typically so that certain parts are reusable throughout a site (like grids, fonts, etc.) and others are more specific in scope (styles for a specific page). There's currently no way for Descartes to handle multiple style trees at once, or to have some concept of merging multiple trees so that it cascades predictably. Currently, end users would have to merge the style trees on their own, then pass it into the constructor.

The approach we probably want to take is to have helper functions that merge multiple style trees into a single style tree with the correct prioritization.

Here's the specification we could take:

JonHMChan commented 7 years ago

https://github.com/JonHMChan/descartes/commit/87016af23bbdc972067d5819a1e91393c39d9cd8 is the first implementation of this method. Needs some usability testing to figure out how styles in multiple files can be structured to make use of this method.