Skip to content
This repository has been archived by the owner on Mar 13, 2023. It is now read-only.

Automatically parse CSS to grab targets for the Customizer APIs #45

Closed
frankiejarrett opened this issue Jul 29, 2016 · 6 comments
Closed
Assignees

Comments

@frankiejarrett
Copy link
Member

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.

@tobeycodes
Copy link
Contributor

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

@frankiejarrett
Copy link
Member Author

Yep, that's exactly what I'm doing.

@frankiejarrett
Copy link
Member Author

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...

@tobeycodes
Copy link
Contributor

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

@frankiejarrett
Copy link
Member Author

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.

@frankiejarrett
Copy link
Member Author

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.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants