From c72a65bc5fd6ca4c14fa30f3fc331291a2203c81 Mon Sep 17 00:00:00 2001 From: Andrew Kingston Date: Tue, 27 Apr 2021 13:15:49 +0100 Subject: [PATCH 1/5] Add support for all 4 spectrum themes in builder! --- .../builder/src/builderStore/store/theme.js | 21 ++++++++++++++----- .../components/settings/ThemeEditor.svelte | 11 ++++++---- 2 files changed, 23 insertions(+), 9 deletions(-) diff --git a/packages/builder/src/builderStore/store/theme.js b/packages/builder/src/builderStore/store/theme.js index cb4d0a2774..fd6b05df59 100644 --- a/packages/builder/src/builderStore/store/theme.js +++ b/packages/builder/src/builderStore/store/theme.js @@ -3,14 +3,25 @@ import { localStorageStore } from "./localStorage" export const getThemeStore = () => { const themeElement = document.documentElement const initialValue = { - darkMode: true, + theme: "darkest", + options: ["lightest", "light", "dark", "darkest"], } const store = localStorageStore("bb-theme", initialValue) - // Update theme when store changes - store.subscribe(theme => { - themeElement.classList.toggle("spectrum--darkest", theme.darkMode) - themeElement.classList.toggle("spectrum--lightest", !theme.darkMode) + // Update theme class when store changes + store.subscribe(state => { + // Handle any old local storage values - this can be removed after the update + if (state.darkMode !== undefined) { + store.set(initialValue) + return + } + + state.options.forEach(option => { + themeElement.classList.toggle( + `spectrum--${option}`, + option === state.theme + ) + }) }) return store diff --git a/packages/builder/src/components/settings/ThemeEditor.svelte b/packages/builder/src/components/settings/ThemeEditor.svelte index 9c7235ce62..d971f01764 100644 --- a/packages/builder/src/components/settings/ThemeEditor.svelte +++ b/packages/builder/src/components/settings/ThemeEditor.svelte @@ -1,8 +1,11 @@ - + -
- - -
- - {:else} - - - - - {/if} - - + Edit + Delete + + + + + + - - + title="Confirm Deletion" /> diff --git a/packages/builder/src/components/common/ConfirmDialog.svelte b/packages/builder/src/components/common/ConfirmDialog.svelte index 27a7517fce..33a1d86b88 100644 --- a/packages/builder/src/components/common/ConfirmDialog.svelte +++ b/packages/builder/src/components/common/ConfirmDialog.svelte @@ -1,5 +1,5 @@