bmbrands/theme_bootstrap — pull request #261 by jobyh (2014-05-04 19:53:59+00:00)
Title: SVG colour replace

Hi all,

Apologies in advance for lengthy comment - it's all important though as there has been a fair bit of refactoring and I want to explain the reasoning behind the changes.

It would be great if @ds125v could cast an eye over this update as he wrote the original SVG replace code and would be good to get his feedback / review that I've not missed something / royally cocked up important functionality :)

This branch iterates on the SVG text replacement code so that it is no longer necessary to store hex colour values for the bundled swatches in the gruntfile. This functionality should also work with any new swatches added without needing to update any code.

It uses a regular expression to infer the value of `@link-color` by finding the CSS `color` value assigned to `a` elements (used for the SVG fills). The trade-off is that the code which does this might need updating if the output of `moodle.less` changes significantly but in terms of ongoing maintenance effort I believe this is a good trade (I've tried to make the pattern as flexible as possible to allow for a certain amount of wiggle-room).

The other significant change is that the `replace` task now uses a regular expression as the pattern match for the SVG fill replacement. This means that (as far as I can make out) there's no longer a need for the `pix_core_originals` directory. I've renamed it to `pix_core` and removed that from `.gitignore`. However this means that whenever the swatch is changed all the `*.svg` files show as modified on `git status`. I think that this is acceptable though as is consistent with what happens to the included CSS files and it seems likely that someone using the theme to create their own would want these changes to the SVG icons be tracked by version control. It means also that the dependency `grunt-contrib-copy` is no longer required.

Phew! :)