From 820ee2a61c2df33984b60dce496f47b03b7bd92a Mon Sep 17 00:00:00 2001 From: Jack Date: Wed, 5 Aug 2020 15:29:57 +0100 Subject: [PATCH] added themes section to the settings page --- public/css/style.scss | 53 ++++++++++++++++++++----------------------- public/index.html | 22 ++++++++++++++---- public/js/settings.js | 24 ++++++++++++-------- 3 files changed, 56 insertions(+), 43 deletions(-) diff --git a/public/css/style.scss b/public/css/style.scss index 36d143b46..14f6084c2 100644 --- a/public/css/style.scss +++ b/public/css/style.scss @@ -1845,23 +1845,40 @@ key { grid-template-columns: 1fr 1fr 1fr 1fr; } + &.themes { + .tabContainer { + position: relative; + grid-area: buttons; + + .tabContent { + overflow: revert; + height: auto; + + .text { + align-self: center; + } + } + } + } + &.themes, &.language, &.layout, &.keymapLayout, &.fontFamily, &.funbox { - grid-template-columns: 1fr; + grid-template-columns: 2fr 1fr; grid-template-areas: - "title" - "tabs" - "buttons"; - gap: 0.5rem; + "title tabs" + "buttons buttons"; + column-gap: 2rem; + row-gap: .5rem; .tabs { - grid-area: tabs; - display: flex; - grid-template-columns: 1fr 1fr 9fr; + display: grid; + grid-auto-flow: column; + grid-auto-columns: 1fr; + gap: 0.5rem; grid-area: tabs; .tab { @@ -1899,26 +1916,6 @@ key { } } -.tabContainer { - position: relative; - - .tabContent { - overflow: revert; - height: auto; - // max-height: 0px; - // max-height: 100vh; - - // transition: max-height .5s ease-in-out; - // &.reveal { - // max-height: 100vh; - // } - - .text { - align-self: center; - } - } -} - .buttons div.theme:hover { transform: scale(1.1); } diff --git a/public/index.html b/public/index.html index 36bf9d8f5..012b936ef 100644 --- a/public/index.html +++ b/public/index.html @@ -1254,6 +1254,15 @@ +
+ + + +
+ theme + +
+

flip test colors

By default, typed text is brighter than the future text. When enabled, the colors will be @@ -1289,10 +1298,14 @@

theme

-
+
+
preset
+
custom
+
+
- -
hide elements -
+ +

live wpm

diff --git a/public/js/settings.js b/public/js/settings.js index 45e0b678f..c04e222f6 100644 --- a/public/js/settings.js +++ b/public/js/settings.js @@ -389,12 +389,14 @@ function setActiveThemeButton() { function setActiveThemeTab() { config.customTheme === true - ? $("[tab='custom']").click() - : $("[tab='preset']").click(); + ? $(".pageSettings .section.themes .tabs .button[tab='custom']").click() + : $(".pageSettings .section.themes .tabs .button[tab='preset']").click(); } function setCustomThemeInputs() { - $("[type=color]").each((n, index) => { + $( + ".pageSettings .section.themes .tabContainer .customTheme input[type=color]" + ).each((n, index) => { let currentColor = config.customThemeColors[colorVars.indexOf($(index).attr("id"))]; $(index).val(currentColor); @@ -570,8 +572,8 @@ const colorVars = [ "--colorful-error-extra-color", ]; -$(".tab").click((e) => { - $(".tab").removeClass("active"); +$(".pageSettings .section.themes .tabs .button").click((e) => { + $(".pageSettings .section.themes .tabs .button").removeClass("active"); var $target = $(e.currentTarget); $target.addClass("active"); setCustomThemeInputs(); @@ -579,22 +581,24 @@ $(".tab").click((e) => { setCustomTheme(false); applyCustomThemeColors(); swapElements( - $('.pageSettings [tabContent="custom"]'), - $('.pageSettings [tabContent="preset"]'), + $('.pageSettings .section.themes .tabContainer [tabContent="custom"]'), + $('.pageSettings .section.themes .tabContainer [tabContent="preset"]'), 250 ); } else { setCustomTheme(true); applyCustomThemeColors(); swapElements( - $('.pageSettings [tabContent="preset"]'), - $('.pageSettings [tabContent="custom"]'), + $('.pageSettings .section.themes .tabContainer [tabContent="preset"]'), + $('.pageSettings .section.themes .tabContainer [tabContent="custom"]'), 250 ); } }); -$("[type='color']").on("input", (e) => { +$( + ".pageSettings .section.themes .tabContainer .customTheme input[type=color]" +).on("input", (e) => { setCustomTheme(true, true); let $colorVar = $(e.currentTarget).attr("id"); let $pickedColor = $(e.currentTarget).val();