Commit c1ccb022 authored by Rob Stupay's avatar Rob Stupay

successful 1st part of implementing the theme switch

parent 4ff076a6
...@@ -17,10 +17,10 @@ var csjs = require('csjs-inject') ...@@ -17,10 +17,10 @@ var csjs = require('csjs-inject')
// var styles = styleGuide() // var styles = styleGuide()
var styleGuide = require('../theme/theme-chooser') var styleGuide = require('../theme/theme-chooser')
console.log(styleGuide) // console.log(styleGuide)
// var styleGuide = remixLib.ui.styleGuide // var styleGuide = remixLib.ui.styleGuide
// var styles = styleGuide('fred') // var styles = styleGuide('fred')
var styles = styleGuide() var styles = styleGuide.chooser()
var css = csjs` var css = csjs`
.panel { .panel {
......
...@@ -2,12 +2,12 @@ ...@@ -2,12 +2,12 @@
var $ = require('jquery') var $ = require('jquery')
var yo = require('yo-yo') var yo = require('yo-yo')
var QueryParams = require('../../lib/query-params') var QueryParams = require('../../lib/query-params')
var Storage = require('../../storage')
var styleGuide = require('../theme/theme-chooser')
// -------------- styling ---------------------- // -------------- styling ----------------------
var csjs = require('csjs-inject') var csjs = require('csjs-inject')
var remixLib = require('remix-lib') var styles = styleGuide.chooser()
var styleGuide = remixLib.ui.styleGuide
var styles = styleGuide()
var helper = require('../../lib/helper') var helper = require('../../lib/helper')
var modal = require('../ui/modal-dialog-custom') var modal = require('../ui/modal-dialog-custom')
...@@ -37,6 +37,9 @@ var css = csjs` ...@@ -37,6 +37,9 @@ var css = csjs`
.select { .select {
${styles.rightPanel.settingsTab.dropdown_SelectCompiler} ${styles.rightPanel.settingsTab.dropdown_SelectCompiler}
} }
.heading {
margin-bottom: 0;
}
input { input {
margin-right: 3px; margin-right: 3px;
} }
...@@ -81,11 +84,20 @@ function SettingsTab (container, appAPI, appEvents, opts) { ...@@ -81,11 +84,20 @@ function SettingsTab (container, appAPI, appEvents, opts) {
<hr> <hr>
<div class="${css.crowNoFlex}"> <div class="${css.crowNoFlex}">
<div>Plugin (<i title="Do not use this feature yet" class="fa fa-exclamation-triangle" aria-hidden="true"></i><span> Do not use this alpha feature if you are not sure what you are doing!</span>)</div> <div>Plugin (<i title="Do not use this feature yet" class="fa fa-exclamation-triangle" aria-hidden="true"></i><span> Do not use this alpha feature if you are not sure what you are doing!</span>)</div>
<div> <div>
<textarea rows="4" cols="70" id="plugininput" type="text" class="${css.pluginTextArea}" ></textarea> <textarea rows="4" cols="70" id="plugininput" type="text" class="${css.pluginTextArea}" ></textarea>
<input onclick=${loadPlugin} type="button" value="Load" class="${css.pluginLoad}"> <input onclick=${loadPlugin} type="button" value="Load" class="${css.pluginLoad}">
</div>
</div> </div>
</div>
<h4 class="${css.heading}">Themes</h4>
<div class="${css.crow}">
<div><input class="${css.col1}" name="theme" id="themeLight" type="radio"></div>
<span class="${css.radioText}">Light Theme</span>
</div>
<div class="${css.crow}">
<div><input class="${css.col1}" name="theme" id="themeDark" type="radio"></div>
<span class="${css.radioText}">Dark Theme</span>
</div>
</div> </div>
` `
...@@ -124,6 +136,29 @@ function SettingsTab (container, appAPI, appEvents, opts) { ...@@ -124,6 +136,29 @@ function SettingsTab (container, appAPI, appEvents, opts) {
appAPI.setOptimize(optimize, true) appAPI.setOptimize(optimize, true)
}) })
var themeStorage = new Storage('style:')
var currTheme = themeStorage.get('theme')
var themeDark = el.querySelector('#themeDark')
var themeLight = el.querySelector('#themeLight')
if (currTheme === 'dark') {
themeDark.setAttribute('checked', 'checked')
} else {
themeLight.setAttribute('checked', 'checked')
}
themeDark.addEventListener('change', function () {
console.log('change dark theme')
styleGuide.switchTheme('dark')
window.location.reload()
})
themeLight.addEventListener('change', function () {
console.log('change to light theme')
styleGuide.switchTheme('light')
window.location.reload()
})
// ----------------- version selector------------- // ----------------- version selector-------------
// clear and disable the version selector // clear and disable the version selector
......
var remixLib = require('remix-lib') var remixLib = require('remix-lib')
var styleGuide = remixLib.ui.styleGuide var styleGuideLight = remixLib.ui.styleGuide
var styleGuideDark = remixLib.ui.styleGuideDark var styleGuideDark = remixLib.ui.styleGuideDark
module.exports = function () { var Storage = require('../../storage')
// if (storage.get('theme') === 'light' ) { module.exports = {
// return styleGuide
// } else {
// return styleGuideDark
// }
return styleGuideDark()
//errors cannot find styleGuideDark
//return styleGuide() chooser: function () {
//works var themeStorage = new Storage('style:')
if (themeStorage.get('theme') === 'light') {
return styleGuideLight()
} else {
return styleGuideDark()
}
},
//return styleGuide switchTheme: function (theme) {
// does not work - it needs the prenthesies - to make it return the function var themeStorage = new Storage('style:')
themeStorage.set('theme', theme)
if (theme === 'dark') {
return styleGuideDark()
} else if (theme === 'light') {
return styleGuideLight()
} else {
return styleGuideLight()
}
}
} }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment