From 2387a18ddbb7594912ac130db29ce938fc7906f8 Mon Sep 17 00:00:00 2001 From: Nolan Lawson Date: Sun, 23 Sep 2018 11:18:02 -0700 Subject: [PATCH] add a theme preview (#573) --- inline-script.js | 1 + .../settings/instances/[instanceName].html | 70 ++++++++++++++++--- routes/_static/themes.js | 52 ++++++++++---- 3 files changed, 101 insertions(+), 22 deletions(-) diff --git a/inline-script.js b/inline-script.js index 0229c744..68bb3a60 100644 --- a/inline-script.js +++ b/inline-script.js @@ -1,6 +1,7 @@ // For perf reasons, this script is run inline to quickly set certain styles. // To allow CSP to work correctly, we also calculate a sha256 hash during // the build process and write it to inline-script-checksum.json. +// TODO: these should not have to be defined twice, once here and again in themes.js window.__themeColors = { 'default': 'royalblue', scarlet: '#e04e41', diff --git a/routes/_pages/settings/instances/[instanceName].html b/routes/_pages/settings/instances/[instanceName].html index 353cb167..61b3a1f6 100644 --- a/routes/_pages/settings/instances/[instanceName].html +++ b/routes/_pages/settings/instances/[instanceName].html @@ -17,14 +17,25 @@

Theme:

- {#each themes as theme} -
- - +
+ {#each themeGroups as themeGroup} +
+ {#each themeGroup.themes as theme} +
+ +
+
+ +
+ {/each} +
+ {/each}
- {/each}
@@ -71,13 +82,37 @@ padding: 20px; line-height: 2em; } + .theme-groups { + display: grid; + grid-template-columns: 1fr 1fr; + } .theme-group { display: flex; + flex-direction: column; + align-items: flex-start; + flex: 1; + } + .theme-picker { + display: flex; + flex-direction: row; align-items: center; } - .theme-chooser label { + .theme-picker-label { margin: 2px 10px 0; } + .theme-preview { + width: 1.5em; + height: 1.5em; + box-sizing: border-box; + border-radius: 2px; + margin: 0 2px 0 10px; + } + .theme-preview-dark { + border: 2px solid #000; + } + .theme-preview-light { + border: 2px solid #dadada; + } .instance-actions { width: 100%; display: flex; @@ -93,6 +128,13 @@ overflow: hidden; text-overflow: ellipsis; } + + @media (max-width: 479px) { + .theme-groups { + grid-template-columns: 1fr; + } + } +