From 5ea6c567526e05380fea9095a459692d2ae0fe4a Mon Sep 17 00:00:00 2001 From: Jan Prochazka Date: Sun, 3 Apr 2022 11:21:38 +0200 Subject: [PATCH] fixed theme selector --- .../web/src/settings/ThemeSkeleton.svelte | 31 +++++++++++-------- 1 file changed, 18 insertions(+), 13 deletions(-) diff --git a/packages/web/src/settings/ThemeSkeleton.svelte b/packages/web/src/settings/ThemeSkeleton.svelte index 298b6eb6..43008dc8 100644 --- a/packages/web/src/settings/ThemeSkeleton.svelte +++ b/packages/web/src/settings/ThemeSkeleton.svelte @@ -2,27 +2,32 @@ import { ThemeDefinition } from 'dbgate-types'; import FontIcon from '../icons/FontIcon.svelte'; import { currentTheme } from '../stores'; + import _ from 'lodash'; + + function extractThemeColors(theme: ThemeDefinition) { + if (!theme.themeCss) return {}; + + return _.fromPairs( + [...theme.themeCss.matchAll(/(--theme-[a-z0-9\-]+)\s*\:\s*(\#[0-9a-fA-F]{6})/g)].map(x => [x[1], x[2]]) + ); + } export let theme: ThemeDefinition; - // export let theme; - function getThemeStyle(val: ThemeDefinition) { - return ``; - } + $: colors = extractThemeColors(theme); + $: cssVarColors = Object.entries(colors) + .map(([key, value]) => `${key}:${value}`) + .join(';'); -{#if theme.themeCss} - {@html getThemeStyle(theme)} -{/if} -
{ $currentTheme = theme.themeClassName; }} > -
+
@@ -32,7 +37,7 @@
-
+
@@ -51,7 +56,7 @@ margin: 10px; cursor: pointer; } - .iconbar { + .iconbar-settings-modal { position: absolute; display: flex; flex-direction: column; @@ -63,7 +68,7 @@ background: var(--theme-bg-inv-1); color: var(--theme-font-inv-2); } - .titlebar { + .titlebar-settings-modal { left: 0; top: 0; right: 0;