Resizable

This commit is contained in:
Devine Lu Linvega
2019-02-21 15:13:29 +09:00
parent e4984a9df1
commit b506939ea8
5 changed files with 24 additions and 10 deletions

View File

@@ -9,7 +9,6 @@ function Theme (_default) {
this.el.type = 'text/css'
this.install = function (host = document.body, callback) {
console.log('Theme', 'Installing..')
host.appendChild(this.el)
this.callback = callback
}
@@ -19,7 +18,7 @@ function Theme (_default) {
if (isJson(localStorage.theme)) {
const storage = JSON.parse(localStorage.theme)
if (validate(storage)) {
console.log('Theme', 'Found theme in localStorage!')
console.log('Theme', 'Loading localStorage..')
this.load(storage)
return
}
@@ -30,7 +29,7 @@ function Theme (_default) {
this.load = function (data) {
const theme = parse(data)
if (!validate(theme)) { console.warn('Theme', 'Not a theme', theme); return }
console.log('Theme', `Loading theme with background ${theme.background}.`)
console.log('Theme', `Load theme, background: ${theme.background}.`)
this.el.innerHTML = `:root { --background: ${theme.background}; --f_high: ${theme.f_high}; --f_med: ${theme.f_med}; --f_low: ${theme.f_low}; --f_inv: ${theme.f_inv}; --b_high: ${theme.b_high}; --b_med: ${theme.b_med}; --b_low: ${theme.b_low}; --b_inv: ${theme.b_inv}; }`
localStorage.setItem('theme', JSON.stringify(theme))
this.active = theme
@@ -73,7 +72,7 @@ function Theme (_default) {
const fs = require('fs')
const { dialog, app } = require('electron').remote
let paths = dialog.showOpenDialog(app.win, { properties: ['openFile'], filters: [{ name: 'Themes', extensions: ['svg'] }] })
if (!paths) { console.log('Nothing to load'); return; }
if (!paths) { console.log('Nothing to load'); return }
fs.readFile(paths[0], 'utf8', function (err, data) {
if (err) throw err
themer.load(data)