mozilla / brackets

An open source code editor for the web, written in JavaScript, HTML and CSS.
http://brackets.io
MIT License
176 stars 278 forks source link

Theme switching for light and dark theme #334

Closed humphd closed 9 years ago

humphd commented 9 years ago

It looks like the Thimble UI is going to want dynamic theme switching via some kind of API call. Ideally we'll implement this in a postMessage way to the the Bramble code (i.e., our extension). Brackets appears to ship with both a light and dark theme by default, so ti should be easy enough to tap into this now. All the code for managing the current theme is in https://github.com/adobe/brackets/tree/3d68a76430c1ab453d6dd9db17c944b3007611a7/src/view, specifically look at ThemeManager. My gut tells me that it might be easiest to just change the theme pref programmatically, since Brackets has an event handler on this changing, see https://github.com/adobe/brackets/blob/3d68a76430c1ab453d6dd9db17c944b3007611a7/src/view/ThemeManager.js#L325-L339. That's what appears to be happening here: https://github.com/adobe/brackets/blob/3d68a76430c1ab453d6dd9db17c944b3007611a7/src/view/ThemeSettings.js#L119-L135.

Later we can file a bug on specifying exactly what each theme should look like in Bramble.

sedge commented 9 years ago

Update:

Theme extensions aren't being loaded, because it fails to determine if an extension is a theme brackets when it tries to examine the package.json file. It tries to load it from the filesystem using loadPackageJson rather than using require to grab it from the server, causing a filesystem error.

This doesn't break anything because package.json files only seem to indicate if an extension is a theme, and the lack of metadata is handled automatically.

At first glance, the loadPackageJson function seems to be the best place to make a change.