main: handle theme from a dedicated module

This commit is contained in:
jean-emmanuel 2018-03-04 10:47:14 +01:00
parent ca8770615b
commit d73f39fead
5 changed files with 85 additions and 58 deletions

View file

@ -1,24 +1,20 @@
var path = require('path'),
{BrowserWindow, Menu, dialog} = require('electron'),
shortcut = require('electron-localshortcut'),
settings = require('./settings')
settings = require('./settings'),
theme = require('./theme')
module.exports = function(options={}) {
var window
var theme = settings.read('theme'),
bgColor = theme && theme.join('\n').indexOf('--color-bg:') != -1 ?
theme.join('\n').match(/--color-bg:([^;]*);/)[1].trim()
: '#191f2a'
window = new BrowserWindow({
width: options.width || 800,
height: options.height || 600,
title: options.title || settings.read('appName'),
icon: path.resolve(__dirname + '/../browser/logo.png'),
backgroundColor: options.color || bgColor,
backgroundColor: options.color || theme.backgroundColor,
type: options.type,
fullscreen: options.fullscreen,
useContentSize: true,