From 2dc58df8f7cd48e03d27ab571570c44a3c297a43 Mon Sep 17 00:00:00 2001 From: quenousimporte Date: Mon, 23 Jan 2023 12:29:53 +0100 Subject: [PATCH] added: select theme changed: css details --- main.js | 65 ++++++++++++++++++++++++++++++++++++++++++++++++++----- style.css | 5 +++-- 2 files changed, 62 insertions(+), 8 deletions(-) diff --git a/main.js b/main.js index e5b6635..14222b0 100644 --- a/main.js +++ b/main.js @@ -1,11 +1,12 @@ var defaultsettings = { - savedelay: 5000, bgcolor: "white", fontfamily: "'Inconsolata', 'Consolas', monospace", fontsize: "90%", fontcolor: "black", lineheight: "130%", + + savedelay: 5000, foldmarkstart: 22232, defaultpreviewinsplit: false, enablefolding: false, @@ -31,6 +32,34 @@ var tags = null; var currentvault = ""; var currenttag = ""; +var themes = +{ + Default: + { + bgcolor: "white", + fontfamily: "'Inconsolata', 'Consolas', monospace", + fontsize: "90%", + fontcolor: "black", + lineheight: "130%" + }, + Notion: + { + bgcolor: "white", + fontfamily: "ui-sans-serif, -apple-system, BlinkMacSystemFont, 'Segoe UI', Helvetica, 'Apple Color Emoji', Arial, sans-serif, 'Segoe UI Emoji', 'Segoe UI Symbol'", + fontsize: "16px", + fontcolor: "rgb(55,53,47)", + lineheight: "24px" + }, + Monkey: + { + bgcolor: "rgb(227,227,227)", + fontfamily: "'Hack', 'Consolas', monospace", + fontsize: "14px", + fontcolor: "rgb(55,55,55)", + lineheight: "26px" + } +}; + var commands = [ { hint: "Close menu" @@ -218,6 +247,11 @@ var commands = [ action: addtagfilter, shortcut: "ctrl+shift+F", savedonly: true +}, +{ + hint: "Select theme", + savedonly: true, + action: selecttheme }]; var snippets = [ @@ -252,6 +286,20 @@ var snippets = [ cursor: 0 }]; +function selecttheme() +{ + searchinlist(Object.keys(themes)) + .then(theme => { + for (var i in themes[theme]) + { + settings[i] = themes[theme][i]; + } + applystyle(); + resize(); + window.localStorage.setItem("settings", JSON.stringify(settings)); + }); +} + function addtagfilter() { var command = commands.find(c => c.action == addtagfilter); @@ -612,6 +660,15 @@ function loadstorage() } } +function applystyle() +{ + document.body.style.background = settings.bgcolor; + document.body.style.fontFamily = settings.fontfamily; + document.body.style.fontSize = settings.fontsize; + document.body.style.lineHeight = settings.lineheight; + document.body.style.color = settings.fontcolor; +} + function loadsettings() { settings = {...defaultsettings}; @@ -628,11 +685,7 @@ function loadsettings() } } - document.body.style.background = settings.bgcolor; - document.body.style.fontFamily = settings.fontfamily; - document.body.style.fontSize = settings.fontsize; - document.body.style.lineHeight = settings.lineheight; - document.body.style.color = settings.fontcolor; + applystyle(); if (!settings.enablefolding) { diff --git a/style.css b/style.css index 7fbb018..b12e5a7 100644 --- a/style.css +++ b/style.css @@ -1,8 +1,8 @@ /* globals */ body { - margin-left: 5%; - margin-right: 5%; + margin-left: 7%; + margin-right: 7%; caret-color: #5AA7CE; } @@ -13,6 +13,7 @@ input { font-family: inherit; font-size: inherit; line-height: inherit; + color: inherit; } /* scrollbars */