Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
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.
Comment | File | Size | Author |
---|---|---|---|
#9 | automatically_extract-2468765-9.patch | 3.2 KB | malcomio |
#7 | automatically_extract-2468765-7.patch | 3.2 KB | malcomio |
#3 | interdiff-2468765-1-3.txt | 646 bytes | malcomio |
#3 | automatically_extract-2468765-3.patch | 1.74 KB | malcomio |
#1 | automatically_extract-2468765-1.patch | 2.52 KB | malcomio |
Comments
Comment #1
malcomio CreditAttribution: malcomio commentedHere's a patch that provides this functionality.
Comment #3
malcomio CreditAttribution: malcomio commentedNew patch that doesn't change the template file, so as not to fail the tests.
Comment #4
malcomio CreditAttribution: malcomio commentedComment #5
dead_armI 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.
Comment #6
malcomio CreditAttribution: malcomio commentedYes 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...
Comment #7
malcomio CreditAttribution: malcomio commentedHere's an attempt at getting CSS, SASS and LESS.
Not 100% sure of the regex though - trying to avoid matching ID selectors in CSS.
Comment #9
malcomio CreditAttribution: malcomio commentedTest failed because the palette is no longer empty initially - re-rolled the patch.