Gisellameloni / svg-edit

Automatically exported from code.google.com/p/svg-edit
MIT License
0 stars 0 forks source link

Canvas background color in CSS #1214

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
I just answered this : 
http://stackoverflow.com/questions/23826962/how-to-change-color-canvas-svg-edito
r

And it's awkward the fact that this color value is not in the CSS file. Is 
there a good reason not to?

Original issue reported on code.google.com by rafaelcastrocouto on 23 May 2014 at 10:46

GoogleCodeExporter commented 8 years ago
Although your answer works to modify the default value (until modified by the 
user), I'd recommend instead using a new practice which avoids modifying the 
repository files. You can do this by creating a `config.js` file in your SVG 
Edit "editor" subdirectory, and add this line to it:

svgEditor.setConfig({bkgd_color: '<A DEFAULT COLOR>'});

To respect the user's preference the next time they load the page (as I'd 
strongly recommend), you should instead add something like this:

if (!$.pref('bkgd_color')) {
    svgEditor.setConfig({bkgd_color: '<A DEFAULT COLOR>'});
}

Note that the above solutions will still just provide a default: the user can 
override the value using the interface.

Because the editor itself has an interface (albeit a simple one) under "Editor 
Options" to allow users to change this value themselves, the color is not just 
a static value. We could use JavaScript to query the relevant style rule (using 
the CSSOM), I suppose, but that would still only work for default values. Would 
that interest you?

In any case, your question did suggest to me a concern about the general 
desirability for CSS customization, so I've modified trunk to allow 
customization in a manner which does not require hacking repository files' CSS. 
The editor now always looks for a "custom.css" file in the editor directory so 
you can add styles there without modifying the HTML (as with the config.js file 
for custom JavaScript), but this file is ignored in commits to the repository 
so future updates will not overwrite a user-created file (as with config.js).

Original comment by bret...@gmail.com on 23 May 2014 at 1:14

GoogleCodeExporter commented 8 years ago
Awesome job ... as always!

Original comment by rafaelcastrocouto on 24 May 2014 at 2:13

GoogleCodeExporter commented 8 years ago
Thanks!

Original comment by bret...@gmail.com on 1 Jun 2014 at 9:44