From 23fc105754e3024715e602a9b893f9bf1b4140fb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ond=C5=99ej=20Hru=C5=A1ka?= Date: Sat, 30 Sep 2017 13:14:10 +0200 Subject: [PATCH] implement #208 preview foreground palette on configured default bg + other improvements --- js/term/themes.js | 26 +++---- pages/cfg_term.php | 164 ++++++++++++++++++++++++------------------ sass/pages/_term.scss | 20 ++++++ 3 files changed, 127 insertions(+), 83 deletions(-) diff --git a/js/term/themes.js b/js/term/themes.js index f2bff54..5cab5ca 100644 --- a/js/term/themes.js +++ b/js/term/themes.js @@ -98,24 +98,26 @@ exports.buildColorTable = function () { exports.SELECTION_FG = '#333' exports.SELECTION_BG = '#b2d7fe' -function resolveColor (themeN, shade) { - shade = +shade - if (shade < 16) shade = themes[themeN][shade] - else { - shade = exports.buildColorTable()[shade] - } - return shade -} - -exports.themePreview = function (n) { +exports.themePreview = function (themeN) { document.querySelectorAll('[data-fg]').forEach((elem) => { let shade = elem.dataset.fg - if (/^\d+$/.test(shade)) shade = resolveColor(n, shade) + if (/^\d+$/.test(shade)) shade = exports.toCss(shade, themeN) elem.style.color = shade }) document.querySelectorAll('[data-bg]').forEach((elem) => { let shade = elem.dataset.bg - if (/^\d+$/.test(shade)) shade = resolveColor(n, shade) + if (/^\d+$/.test(shade)) shade = exports.toCss(shade, themeN) elem.style.backgroundColor = shade }) } + +exports.toCss = function (shade, themeN) { + if (/^\d+$/.test(shade)) { + shade = +shade + if (shade < 16) shade = themes[themeN][shade] + else { + shade = exports.buildColorTable()[shade] + } + } + return shade +} diff --git a/pages/cfg_term.php b/pages/cfg_term.php index 13560ee..5993342 100644 --- a/pages/cfg_term.php +++ b/pages/cfg_term.php @@ -12,7 +12,7 @@
- @@ -26,6 +26,8 @@ + +
@@ -59,25 +61,25 @@
- 01234567 + 01234567
- 89101112131415 + 89101112131415
@@ -292,69 +294,89 @@ diff --git a/sass/pages/_term.scss b/sass/pages/_term.scss index ae23265..56f2de6 100644 --- a/sass/pages/_term.scss +++ b/sass/pages/_term.scss @@ -381,3 +381,23 @@ body.pseudo-fullscreen { display: inline-block; padding: 5px; } + +.theme-nav-btn { + width: 2em; + height: 2em; + display: flex; + align-items: center; + justify-content: space-around; + background: #4c4c4c; + color: #eaeaea; + margin: 5px; + border-radius: 5px; + + @include noselect(); + + cursor: pointer; + position: relative; + &:active { + top: 1px; + } +}