From 4e76f101757ce96aaaeb23aee250dfe181a1d3c1 Mon Sep 17 00:00:00 2001 From: Jan Prochazka Date: Thu, 25 Mar 2021 12:39:38 +0100 Subject: [PATCH] themes --- packages/types/extensions.d.ts | 1 + packages/web/src/Screen.svelte | 6 +- packages/web/src/celldata/JsonCellView.svelte | 13 ++++ packages/web/src/charts/DataChart.svelte | 11 +-- packages/web/src/forms/SelectField.svelte | 70 +++++++++++++------ packages/web/src/forms/TextField.svelte | 2 +- packages/web/src/plugins/ThemeDark.svelte | 3 +- packages/web/src/plugins/ThemeLight.svelte | 1 + packages/web/src/query/AceEditor.svelte | 6 +- packages/web/src/stores.ts | 4 ++ .../web/src/widgets/CellDataWidget.svelte | 8 ++- 11 files changed, 91 insertions(+), 34 deletions(-) diff --git a/packages/types/extensions.d.ts b/packages/types/extensions.d.ts index fbd77cc6..142b6658 100644 --- a/packages/types/extensions.d.ts +++ b/packages/types/extensions.d.ts @@ -24,6 +24,7 @@ export interface FileFormatDefinition { export interface ThemeDefinition { className: string; themeName: string; + themeType: 'light' | 'dark'; } export interface PluginDefinition { diff --git a/packages/web/src/Screen.svelte b/packages/web/src/Screen.svelte index 85ab285f..3ed5360d 100644 --- a/packages/web/src/Screen.svelte +++ b/packages/web/src/Screen.svelte @@ -3,6 +3,7 @@ import WidgetIconPanel from './widgets/WidgetIconPanel.svelte'; import { currentTheme, + currentThemeDefinition, isFileDragActive, leftPanelWidth, selectedWidget, @@ -19,9 +20,11 @@ import ModalLayer from './modals/ModalLayer.svelte'; import DragAndDropFileTarget from './DragAndDropFileTarget.svelte'; import dragDropFileTarget from './utility/dragDropFileTarget'; + + $: currentThemeType = $currentThemeDefinition?.themeType == 'dark' ? 'theme-type-dark' : 'theme-type-light'; -
+
@@ -126,6 +129,7 @@ height: var(--dim-toolbar-height); left: 0; right: 0; + background: var(--theme-bg-1); } .splitter { diff --git a/packages/web/src/celldata/JsonCellView.svelte b/packages/web/src/celldata/JsonCellView.svelte index b949b7a5..639f951d 100644 --- a/packages/web/src/celldata/JsonCellView.svelte +++ b/packages/web/src/celldata/JsonCellView.svelte @@ -38,4 +38,17 @@ right: 0; bottom: 0; } + + :global(.theme-type-dark) .inner { + --json-tree-string-color: #efc5c5; + --json-tree-symbol-color: #efc5c5; + --json-tree-boolean-color: #a6b3f5; + --json-tree-function-color: #a6b3f5; + --json-tree-number-color: #bfbdf2; + --json-tree-label-color: #e9aaed; + --json-tree-arrow-color: #d4d4d4; + --json-tree-null-color: #dcdcdc; + --json-tree-undefined-color: #dcdcdc; + --json-tree-date-color: #dcdcdc; + } diff --git a/packages/web/src/charts/DataChart.svelte b/packages/web/src/charts/DataChart.svelte index 4032c285..b503d6fa 100644 --- a/packages/web/src/charts/DataChart.svelte +++ b/packages/web/src/charts/DataChart.svelte @@ -48,8 +48,9 @@ return {}; } - function createChartData(freeData, labelColumn, dataColumns, colorSeed, chartType, dataColumnColors) { + function createChartData(freeData, labelColumn, dataColumns, colorSeed, chartType, dataColumnColors, themeDef) { if (!freeData || !labelColumn || !dataColumns || !freeData.rows || dataColumns.length == 0) return null; + const palettes = themeDef?.themeType == 'dark' ? presetDarkPalettes : presetPalettes; const colors = randomcolor({ count: _.max([freeData.rows.length, dataColumns.length, 1]), seed: colorSeed, @@ -65,8 +66,8 @@ if (chartType == 'line' || chartType == 'bar') { const color = dataColumnColors[dataColumn]; if (color) { - backgroundColor = presetPalettes[color][4] + '80'; - borderColor = presetPalettes[color][7]; + backgroundColor = palettes[color][4] + '80'; + borderColor = palettes[color][7]; } else { backgroundColor = colors[columnIndex] + '80'; borderColor = colors[columnIndex]; @@ -98,6 +99,7 @@ import { getFormContext } from '../forms/FormProviderCore.svelte'; import { generate, presetPalettes, presetDarkPalettes, presetPrimaryColors } from '@ant-design/colors'; import { extractDataColumnColors, extractDataColumns } from './chartDataLoader'; + import { currentThemeDefinition } from '../stores'; export let data; export let menu; @@ -116,7 +118,8 @@ dataColumns, $values.colorSeed || '5', $values.chartType, - dataColumnColors + dataColumnColors, + $currentThemeDefinition ); diff --git a/packages/web/src/forms/SelectField.svelte b/packages/web/src/forms/SelectField.svelte index f09a0778..012f97d8 100644 --- a/packages/web/src/forms/SelectField.svelte +++ b/packages/web/src/forms/SelectField.svelte @@ -32,26 +32,52 @@ {/each} {:else} - options.find(x => x.value == item)) - : options.find(x => x.value == value)} - on:select={e => { - if (isMulti) { - dispatch( - 'change', - e.detail?.map(x => x.value) - ); - } else { - dispatch('change', e.detail.value); - } - }} - showIndicator={!isMulti} - isClearable={isMulti} - {isMulti} - bind:listOpen - bind:isFocused - /> +
+ options.find(x => x.value == item)) + : options.find(x => x.value == value)} + on:select={e => { + if (isMulti) { + dispatch( + 'change', + e.detail?.map(x => x.value) + ); + } else { + dispatch('change', e.detail.value); + } + }} + showIndicator={!isMulti} + isClearable={isMulti} + {isMulti} + bind:listOpen + bind:isFocused + /> +
{/if} + + diff --git a/packages/web/src/forms/TextField.svelte b/packages/web/src/forms/TextField.svelte index ac6e51e2..59a0b0ed 100644 --- a/packages/web/src/forms/TextField.svelte +++ b/packages/web/src/forms/TextField.svelte @@ -8,4 +8,4 @@ if (focused) onMount(() => domEditor.focus()); - + diff --git a/packages/web/src/plugins/ThemeDark.svelte b/packages/web/src/plugins/ThemeDark.svelte index 08404467..89411b6b 100644 --- a/packages/web/src/plugins/ThemeDark.svelte +++ b/packages/web/src/plugins/ThemeDark.svelte @@ -1,11 +1,12 @@