For people using SASS in their themes, it is extra hassle to define colour swatches manually, given that they are likely to define colour variables in code.

It would be useful to scan the SASS files and parse any colour variables that are defined.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

malcomio’s picture

Status: Active » Needs review
FileSize
2.52 KB

Here's a patch that provides this functionality.

Status: Needs review » Needs work

The last submitted patch, 1: automatically_extract-2468765-1.patch, failed testing.

malcomio’s picture

New patch that doesn't change the template file, so as not to fail the tests.

malcomio’s picture

Status: Needs work » Needs review
dead_arm’s picture

I think this is a cool feature request but I have some suggestions. It would be more ideal if we pulled in all colors from .css sheets per theme. That way it would highlight how many colors the theme is using, and also then it wouldn't require hardcoding each file extension, for example .sass, .less, etc.

malcomio’s picture

Yes that would be nice, but more complex - one reason I went with SASS variables rather than CSS values was that the variables have names, and the regex to parse them is much simpler.

I guess we'd need to get any hex values at all, whether they're in color, background-color, background, border, etc.

The other thing to consider is rgb and rgba values, but that's a separate issue...

malcomio’s picture

Here's an attempt at getting CSS, SASS and LESS.

Not 100% sure of the regex though - trying to avoid matching ID selectors in CSS.

Status: Needs review » Needs work

The last submitted patch, 7: automatically_extract-2468765-7.patch, failed testing.

malcomio’s picture

Test failed because the palette is no longer empty initially - re-rolled the patch.