diff --git a/electron/config.js b/electron/config.js index b01390f1..63ae2d6c 100644 --- a/electron/config.js +++ b/electron/config.js @@ -25,6 +25,7 @@ const schema = { "emacsMetaKey": { "enum": [null, "alt", "meta"], default: null }, "showLineNumberGutter": {type: "boolean", default:true}, "showFoldGutter": {type: "boolean", default:true}, + "autoUpdate": {type: "boolean", default: true}, "allowBetaVersions": {type: "boolean", default: false}, "enableGlobalHotkey": {type: "boolean", default: false}, "globalHotkey": {type: "string", default: "CmdOrCtrl+Shift+H"}, @@ -49,6 +50,7 @@ const defaults = { emacsMetaKey: "meta", showLineNumberGutter: true, showFoldGutter: true, + autoUpdate: true, allowBetaVersions: false, enableGlobalHotkey: false, globalHotkey: "CmdOrCtrl+Shift+H", diff --git a/src/components/App.vue b/src/components/App.vue index bb0036ba..d689648f 100644 --- a/src/components/App.vue +++ b/src/components/App.vue @@ -21,7 +21,7 @@ languageAuto: true, theme: window.heynote.themeMode.initial, initialTheme: window.heynote.themeMode.initial, - systemTheme: 'system', + themeSetting: 'system', development: window.location.href.indexOf("dev=1") !== -1, showLanguageSelector: false, showSettings: false, @@ -32,7 +32,7 @@ mounted() { window.heynote.themeMode.get().then((mode) => { this.theme = mode.computed - this.systemTheme = mode.theme + this.themeSetting = mode.theme }) const onThemeChange = (theme) => { this.theme = theme @@ -69,12 +69,12 @@ let newTheme // when the "system" theme is used, make sure that the first click always results in amn actual theme change if (this.initialTheme === "light") { - newTheme = this.systemTheme === "system" ? "dark" : (this.systemTheme === "dark" ? "light" : "system") + newTheme = this.themeSetting === "system" ? "dark" : (this.themeSetting === "dark" ? "light" : "system") } else { - newTheme = this.systemTheme === "system" ? "light" : (this.systemTheme === "light" ? "dark" : "system") + newTheme = this.themeSetting === "system" ? "light" : (this.themeSetting === "light" ? "dark" : "system") } window.heynote.themeMode.set(newTheme) - this.systemTheme = newTheme + this.themeSetting = newTheme this.$refs.editor.focus() }, @@ -129,7 +129,8 @@ :language="language" :languageAuto="languageAuto" :theme="theme" - :systemTheme="systemTheme" + :themeSetting="themeSetting" + :autoUpdate="settings.autoUpdate" :allowBetaVersions="settings.allowBetaVersions" @toggleTheme="toggleTheme" @openLanguageSelector="openLanguageSelector" diff --git a/src/components/StatusBar.vue b/src/components/StatusBar.vue index 04b53c24..b671a786 100644 --- a/src/components/StatusBar.vue +++ b/src/components/StatusBar.vue @@ -13,7 +13,8 @@ "language", "languageAuto", "theme", - "systemTheme", + "themeSetting", + "autoUpdate", "allowBetaVersions", ], @@ -84,9 +85,13 @@ > - +
- +
diff --git a/src/components/UpdateStatusItem.vue b/src/components/UpdateStatusItem.vue index 5b70edca..0f8af7b2 100644 --- a/src/components/UpdateStatusItem.vue +++ b/src/components/UpdateStatusItem.vue @@ -1,6 +1,7 @@ @@ -61,77 +69,122 @@
-

Settings

-
-
-

Keymap

- -
-
-

Meta Key

- -
-
-
-
-

Gutters

- - - -
-
-
-
-

Global Keyboard Shortcut

- - - +

Settings

+
    + -
-
-
-
-

Beta Versions

- -
+ + + + +
+ +
+
+

Keymap

+ +
+
+

Meta Key

+ +
+
+
+
+

Global Keyboard Shortcut

+ + + +
+
+
+ + +
+
+

Gutters

+ + + +
+
+
+ + +
+
+

Auto Update

+ +
+
+
+
+

Beta Versions

+ +
+
+
@@ -190,34 +243,46 @@ box-shadow: 0 0 25px rgba(0, 0, 0, 0.3) .dialog-content flex-grow: 1 - padding: 40px - h1 - font-size: 20px - font-weight: 600 - margin-bottom: 20px - - .row - display: flex - .entry - margin-bottom: 24px - margin-right: 20px - h2 - font-weight: 600 - margin-bottom: 10px - font-size: 14px - select - width: 200px - &:focus - outline: none - label - display: block - user-select: none - &.keyboard-shortcut-label - margin-bottom: 14px - > input[type=checkbox] - position: relative - top: 2px - left: -3px + display: flex + .sidebar + box-sizing: border-box + width: 140px + border-right: 1px solid #eee + padding-top: 20px + +dark-mode + border-right: 1px solid #222 + h1 + font-size: 16px + font-weight: 700 + margin-bottom: 20px + padding: 0 20px + margin-bottom: 20px + .settings-content + flex-grow: 1 + padding: 40px + overflow-y: auto + .row + display: flex + .entry + margin-bottom: 24px + margin-right: 20px + h2 + font-weight: 600 + margin-bottom: 10px + font-size: 14px + select + width: 200px + &:focus + outline: none + label + display: block + user-select: none + &.keyboard-shortcut-label + margin-bottom: 14px + > input[type=checkbox] + position: relative + top: 2px + left: -3px .bottom-bar border-radius: 0 0 5px 5px background: #eee diff --git a/src/components/settings/TabContent.vue b/src/components/settings/TabContent.vue new file mode 100644 index 00000000..917d3dff --- /dev/null +++ b/src/components/settings/TabContent.vue @@ -0,0 +1,24 @@ + + + + + diff --git a/src/components/settings/TabListItem.vue b/src/components/settings/TabListItem.vue new file mode 100644 index 00000000..68c49a11 --- /dev/null +++ b/src/components/settings/TabListItem.vue @@ -0,0 +1,34 @@ + + + + + \ No newline at end of file diff --git a/src/css/include.sass b/src/css/include.sass index e8f61eae..1a5f1677 100644 --- a/src/css/include.sass +++ b/src/css/include.sass @@ -1,5 +1,3 @@ =dark-mode() - @media (prefers-color-scheme: dark) - @content body[theme=dark] & @content diff --git a/webapp/bridge.js b/webapp/bridge.js index 77f017a9..d691718d 100644 --- a/webapp/bridge.js +++ b/webapp/bridge.js @@ -1,11 +1,15 @@ const mediaMatch = window.matchMedia('(prefers-color-scheme: dark)') -let themeModeChangeListener = null -let autoUpdateCallbacks = null let themeCallback = null +mediaMatch.addEventListener("change", async (event) => { + if (themeCallback) { + themeCallback((await Heynote.themeMode.get()).computed) + } +}) +let autoUpdateCallbacks = null let currencyData = null -export default { +const Heynote = { platform: { isMac: true, isWindows: false, @@ -41,27 +45,25 @@ export default { themeMode: { set: (mode) => { + localStorage.setItem("theme", mode) themeCallback(mode) - document.body.setAttribute("theme", mode === "dark" ? "dark" : "light") + console.log("set theme to", mode) }, get: async () => { + const theme = localStorage.getItem("theme") || "system" + const systemTheme = mediaMatch.matches ? "dark" : "light" return { - theme: "light", - computed: "light", + theme: theme, + computed: theme === "system" ? systemTheme : theme, } }, onChange: (callback) => { themeCallback = callback - themeModeChangeListener = (event) => { - callback(event.matches ? "dark" : "light") - } - mediaMatch.addEventListener('change', themeModeChangeListener) - return mediaMatch }, removeListener() { - mediaMatch.removeEventListener('change', themeModeChangeListener) + themeCallback = null }, - initial: "light", + initial: localStorage.getItem("theme") || "system", }, settings: { @@ -77,3 +79,5 @@ export default { return currencyData }, } + +export default Heynote