-
Notifications
You must be signed in to change notification settings - Fork 36
Automatically parse CSS to grab targets for the Customizer APIs #45
Comments
This is useful for at least running once. Would be clever if we could just pass a color such as #fff and it would match it and return all the occurrences whether it was #fff or #ffffff and whether it was in a border, background, color, etc |
Yep, that's exactly what I'm doing. |
Well, I actually got this working, but there is a giant caveat: _No two colors can have the same default value._ This is potentially a deal-breaker. I am going to think on this one for a bit... |
Yeah, that's a problem. None of them use same colours now so it could be useful to speed up development now if we can dump them out but perhaps not something we bundle in the theme. If they have the same colors surely the css output is the same though. It only becomes a problem when you then change the colors and you need to know which go with which color. tough one |
The simplest work-around would be to change the last character in HEX values so colors are always unique but not noticeable to the naked eye. |
I'm giving up on this for now. May resurrect at a later time as a tool to aid developers, but for now all rules need to still be passed manually via the filter. There are too many edge cases to an automated solution. |
Rather than having to identify and insert CSS targets for every color and font, there should be an automated way to scan the main stylesheet for a particular rule to find which selectors need to be targeted for new colors.
I made a proof-of-concept: https://gist.github.com/fjarrett/eadafb0d6519a85d70c5b1cb34838ecc
If we do this, we will need to revisit #25 as there is no way we would want to do this on-the-fly for every page load.
The text was updated successfully, but these errors were encountered: