From aac1b648985bb65442dbf9f07e445b7990c3f984 Mon Sep 17 00:00:00 2001 From: Kyle <41976328+ImKyle4815@users.noreply.github.com> Date: Thu, 24 Dec 2020 17:31:50 -0800 Subject: [PATCH] theme editor --- css/{style-1.css => style-2.css} | 48 ++++++++++++++++++-------------- globalHTML/footer.php | 2 ++ globalHTML/header.php | 9 ++++-- img/gradientBackground.svg | 10 +++++++ js/themeEditor.js | 20 +++++++++++++ js/themes.js | 44 +++++++++++++++++++++++++++++ theme/index.php | 30 ++++++++++++++++++++ 7 files changed, 140 insertions(+), 23 deletions(-) rename css/{style-1.css => style-2.css} (93%) create mode 100644 img/gradientBackground.svg create mode 100644 js/themeEditor.js create mode 100644 js/themes.js create mode 100644 theme/index.php diff --git a/css/style-1.css b/css/style-2.css similarity index 93% rename from css/style-1.css rename to css/style-2.css index e43a17e9..200cb056 100644 --- a/css/style-1.css +++ b/css/style-2.css @@ -49,6 +49,14 @@ } /*Variables*/ :root { + --site-background: url('/img/lowpolyBackground.svg'); + --color-primary: #35603E; + --color-selected: #ae9; + --color-highlight: #8f8; + --font-color: #fff; + --font-color-2: #bbb; + --input-background: #333; + --input-background-selected: #555; --darkened-backdrop-filter: grayscale(1) brightness(0.3); --regular-backdrop-filter: none; --window-diagonal-size: 400px; @@ -59,7 +67,7 @@ z-index: -1; width: 100vw; height: 100vh; - background: url('/img/lowpolyBackground.svg'); + background: var(--site-background); background-repeat: no-repeat; background-attachment: fixed; background-size: cover; @@ -69,8 +77,8 @@ html { font-size: 12pt; overflow-x: hidden; - background: #222; - color: white; + background: #151515; + color: var(--font-color); } body { width: 100vw; @@ -91,7 +99,6 @@ header { } footer { padding: 2rem; - /*background: #427A36;*/ display: grid; grid-template-columns: calc(1fr - 4rem); grid-gap: 1rem; @@ -117,7 +124,6 @@ img { ::-webkit-scrollbar-thumb { background: #888; border-radius: 0.25rem; - margin: 1px; } /*Fonts*/ .title { @@ -168,12 +174,12 @@ a:hover { text-decoration: underline; } ::selection { - color: white; - background: #8f8; + color: var(--font-color); + background: var(--color-highlight); } ::moz-selection { - color: white; - background: #8f8; + color: var(--font-color); + background: var(--color-highlight);; } /*General styles*/ .hidden { @@ -230,7 +236,7 @@ a:hover { stroke-miterlimit: 1.5; cursor: pointer; z-index: 100; - background: #35603E; + background: var(--color-primary); border-radius: 0 0 0 0.5rem; } .hamburger > path { @@ -261,7 +267,7 @@ a:hover { right: 2rem; top: 2rem; padding: 0; - background: #35603E; + background: var(--color-primary); border-radius: 100%; transition: 0.333s ease; } @@ -309,7 +315,7 @@ a:hover { .input { box-sizing: border-box; width: 100%; - background: #333; + background: var(--input-background); color: inherit; font-size: 1.25rem; font-family: Montserrat-Medium, Helvetica, Tahoma, Verdana, Geneva, sans-serif; @@ -328,7 +334,7 @@ a:hover { outline: none; } .input:active { - border-color: #ae9; + border-color: var(--color-selected); } .input:disabled { opacity: 0.5; @@ -342,7 +348,7 @@ a:hover { grid-gap: 0.5rem; } .input-description { - color: #bbb; + color: var(--font-color-2); font-style: italic; } input[type=checkbox].input { @@ -502,7 +508,7 @@ textarea.input { padding-top: 0.5rem; border-top: 0.5rem; border-style: solid; - border-color: #ae9; + border-color: var(--color-selected); transition: 0.5s !important; } .selectable:hover { @@ -511,12 +517,12 @@ textarea.input { } /*Draggables*/ .draggable { - background: #333; + background: var(--input-background); touch-action: none; } .dragging { box-shadow: 0 0px 16px black; - background: #555; + background: var(--input-background-selected); cursor: move; } .frame-list{ @@ -544,7 +550,7 @@ textarea.input { } .frame-option, .mask-option { cursor: pointer; - background: #333; + background: var(--input-background); width: 100%; height: 6rem; padding: 0.25rem 0; @@ -557,7 +563,7 @@ textarea.input { transition: 0.25s; } .frame-option.selected, .mask-option.selected { - background: #555; + background: var(--input-background-selected); } .frame-option > img, .mask-option > img { width: 100%; @@ -620,7 +626,7 @@ textarea.input { transform: translateX(-50%) translateY(-50%); top: 50%; left: 50%; - background: #35603E; + background: var(--color-primary); border: 0.5rem solid #333; border-radius: 1rem; box-shadow: 0.5rem 0.5rem 1rem 0.5rem black; @@ -645,7 +651,7 @@ textarea.input { } /*Text tab*/ .text-option { - background: #333; + background: var(--input-background); } .text-codes { max-width: calc(100vw - 3rem); diff --git a/globalHTML/footer.php b/globalHTML/footer.php index b1cb9037..d9836b7f 100644 --- a/globalHTML/footer.php +++ b/globalHTML/footer.php @@ -9,8 +9,10 @@

Navigation

Home
Creator
+
Old Creator
Ask Urza
About
+
Theme Editor

Legal

diff --git a/globalHTML/header.php b/globalHTML/header.php index 24205a72..a9cdcc51 100644 --- a/globalHTML/header.php +++ b/globalHTML/header.php @@ -9,13 +9,14 @@ - + - + + @@ -35,13 +36,17 @@

Navigation

Home

Card Creator

+

Old Card Creator

Ask Urza 2.0

About Me

+

Theme Editor

Legal

External Links

Twitter

Patreon

+

Contact

+

Email

\ No newline at end of file diff --git a/img/gradientBackground.svg b/img/gradientBackground.svg new file mode 100644 index 00000000..8572b885 --- /dev/null +++ b/img/gradientBackground.svg @@ -0,0 +1,10 @@ + + + + + + + + + + diff --git a/js/themeEditor.js b/js/themeEditor.js new file mode 100644 index 00000000..b62d484e --- /dev/null +++ b/js/themeEditor.js @@ -0,0 +1,20 @@ +document.querySelector('#hue-rotate').value = theme.huerotate; +document.querySelector('#hue-rotate-auto').value = theme.rainbow; +document.querySelector('#readable-brightness').value = theme.readablebrightness; + +var updateCSSTimer; +var canUpdateCSS = true; + +function changeThemeVar(input, destination) { + theme[destination] = input; + localStorage.setItem('theme', JSON.stringify(theme)); + // if (canUpdateCSS) { + updateCSS(); + // canUpdateCSS = false; + // updateCSSTimer = setTimeout(resetCSSTimer, 50); + // } +} + +function resetCSSTimer() { + canUpdateCSS = true; +} \ No newline at end of file diff --git a/js/themes.js b/js/themes.js new file mode 100644 index 00000000..fe648d65 --- /dev/null +++ b/js/themes.js @@ -0,0 +1,44 @@ +var theme, rainbowTimer; +const root = document.documentElement.style; + +if (localStorage.getItem('theme')) { + theme = JSON.parse(localStorage.getItem('theme')); + updateCSS(); +} else { + resetTheme(); +} + +function updateCSS() { + if (!root.getPropertyValue('--site-background').includes(theme.background)) { + root.setProperty('--site-background', 'url("' + (theme.background || '/img/lowpolyBackground.svg') + '")'); + } + // root.setProperty("--color-primary", theme.SOMETHING); + // root.setProperty("--color-selected", theme.SOMETHING); + // root.setProperty("--color-highlighted", theme.SOMETHING); + // root.setProperty("--font-color", theme.SOMETHING); + // root.setProperty("--font-color-2", theme.SOMETHING); + // root.setProperty("--input-background", theme.SOMETHING); + // root.setProperty("--input-background-selected", theme.SOMETHING); + if (theme.rainbow > 0) { + clearInterval(rainbowTimer); + rainbowTimer = setInterval(rainbowMode, (theme.rainbow)); + } else { + clearInterval(rainbowTimer); + root.setProperty('--regular-backdrop-filter', 'hue-rotate(' + (theme.huerotate || 0) + 'deg)'); + } + root.setProperty('--darkened-backdrop-filter', 'grayscale(1) brightness(' + (theme.readablebrightness || 0) + ')'); +} + +function rainbowMode() { + theme.huerotate += 1; + if (theme.huerotate >= 360) { + theme.huerotate = 0 + } + root.setProperty('--regular-backdrop-filter', 'hue-rotate(' + theme.huerotate + 'deg)'); +} + +function resetTheme() { + theme = {huerotate:0, background:'/img/lowpolyBackground.svg', readablebrightness:0.3, rainbow:0}; + localStorage.setItem('theme', JSON.stringify(theme)); + updateCSS(); +} \ No newline at end of file diff --git a/theme/index.php b/theme/index.php new file mode 100644 index 00000000..314c718c --- /dev/null +++ b/theme/index.php @@ -0,0 +1,30 @@ + + Card Conjurer - Theme Editor +

Theme Editor

+
+
+

Welcome to the theme editor!

+
This feature is a bit of a work-in-progress
+
+
+
+

Background

+

Choose a background

+ +

Enter a background image (URL ONLY)

+ +

Shift the Background's Hue

+ +

Enable Rainbow-Mode

+ +

Readable Areas

+

Adjust the Brightness

+ + +
+
+ + \ No newline at end of file