Mailspring/src/theme-package.coffee
Juan Tejada b3bf4ad65d feat(theme-selector): Add theme selector to preferences page
Summary:
- Adds a couple of helper methods to theme manager and updates how
a theme package is enabled to be consistent with how we actually want to
activate themes.
- Adds small select component to choose a theme or install a new one.

Test Plan: - Manual

Reviewers: evan, bengotow

Reviewed By: bengotow

Differential Revision: https://phab.nylas.com/D2355
2015-12-15 10:29:58 -08:00

32 lines
716 B
CoffeeScript

Q = require 'q'
Package = require './package'
module.exports =
class ThemePackage extends Package
getType: -> 'theme'
getStyleSheetPriority: -> 1
enable: ->
NylasEnv.themes.setActiveTheme(@name)
disable: ->
NylasEnv.config.removeAtKeyPath('core.themes', @name)
load: ->
@measure 'loadTime', =>
try
@metadata ?= Package.loadMetadata(@path)
catch error
console.warn "Failed to load theme named '#{@name}'", error.stack ? error
this
activate: ->
return @activationDeferred.promise if @activationDeferred?
@activationDeferred = Q.defer()
@measure 'activateTime', =>
@loadStylesheets()
@activateNow()
@activationDeferred.promise