feat(theme): add custom UI color palettes
This commit is contained in:
1 parent
c81466d0db
commit
8996da7d9a
15 files changed
+618
-37
No files matched your search
@@ -100,7 +100,7 @@ import {
|
||||
type QueryEditorTableReferencePayload,
|
||||
} from "@/lib/editor/queryEditorTableDrop";
|
||||
import type { SqlHighlighter } from "@/lib/sql/sqlHighlighter";
|
||||
import { EDITOR_FONT_FAMILY_CSS_VAR, EDITOR_FONT_SIZE_CSS_VAR, loadEditorTheme, editorFontTheme, sqlCompletionTheme, sqlSemanticHighlightTheme } from "@/lib/editor/editorThemes";
|
||||
import { EDITOR_FONT_FAMILY_CSS_VAR, EDITOR_FONT_SIZE_CSS_VAR, editorDiagnosticColors, editorThemeAppearanceFor, loadEditorTheme, editorFontTheme, sqlCompletionTheme, sqlSemanticHighlightTheme } from "@/lib/editor/editorThemes";
|
||||
import { createStatementGutterMarkerDom, shouldShowStatementGutter } from "@/lib/editor/codemirrorStatementGutter";
|
||||
import { createQueryEditorSearchKeymap } from "@/lib/editor/queryEditorSearchKeymap";
|
||||
import { searchKeymapWithoutModD } from "@/lib/editor/codemirrorSearchKeymap";
|
||||
@@ -225,7 +225,7 @@ function sqlStatementParameterOptions() {
|
||||
const toggles = resolveSqlVariableSyntaxToggles(settingsStore.editorSettings.sqlVariableSyntaxOverrides, props.databaseType, settingsStore.editorSettings.sqlVariableSubstitutionEnabled);
|
||||
return { databaseType: props.databaseType, enabledSyntaxes: enabledSqlParameterSyntaxes(toggles) };
|
||||
}
|
||||
const { isDark, themePalette } = useTheme();
|
||||
const { isDark, themePalette, activeCustomUiColors } = useTheme();
|
||||
const { t } = useI18n();
|
||||
const { toast } = useToast();
|
||||
const snippetDatabaseType = computed(() => {
|
||||
@@ -595,7 +595,7 @@ const tableNavigationHoverClass = "query-editor--table-navigation-hover";
|
||||
const DBX_VIM_SAVE_EVENT = "dbx-vim-save";
|
||||
|
||||
function editorThemeAppearance() {
|
||||
return isDark.value ? "dark" : "light";
|
||||
return editorThemeAppearanceFor(isDark.value ? "dark" : "light", themePalette.value, themePalette.value === "custom" ? activeCustomUiColors.value : undefined);
|
||||
}
|
||||
|
||||
// Completion cache
|
||||
@@ -681,6 +681,16 @@ function syncEditorFontCssVars(fontSize = liveFontSize.value, fontFamily = setti
|
||||
editorRef.value.style.setProperty(EDITOR_FONT_FAMILY_CSS_VAR, fontFamily);
|
||||
}
|
||||
|
||||
// Diagnostics render on the editor surface, so their marker colors follow the
|
||||
// resolved editor appearance (which already adapts to custom backgrounds) via
|
||||
// editor-scoped variables instead of the app-level warning/destructive tokens.
|
||||
function syncEditorDiagnosticCssVars() {
|
||||
if (!editorRef.value) return;
|
||||
const colors = editorDiagnosticColors(editorThemeAppearance());
|
||||
editorRef.value.style.setProperty("--dbx-editor-diagnostic-error", colors.error);
|
||||
editorRef.value.style.setProperty("--dbx-editor-diagnostic-warning", colors.warning);
|
||||
}
|
||||
|
||||
let pendingFontReconfig: { size: number; family: string } | null = null;
|
||||
let fontReconfigScheduled = false;
|
||||
|
||||
@@ -4488,11 +4498,11 @@ onMounted(async () => {
|
||||
|
||||
const diagnosticTheme = EditorView.baseTheme({
|
||||
".cm-sql-error": {
|
||||
textDecoration: "underline wavy var(--destructive)",
|
||||
textDecoration: "underline wavy var(--dbx-editor-diagnostic-error, var(--destructive))",
|
||||
textUnderlineOffset: "3px",
|
||||
},
|
||||
".cm-sql-semantic-warning": {
|
||||
textDecoration: "underline wavy var(--warning)",
|
||||
textDecoration: "underline wavy var(--dbx-editor-diagnostic-warning, var(--warning))",
|
||||
textUnderlineOffset: "3px",
|
||||
},
|
||||
});
|
||||
@@ -5309,6 +5319,7 @@ onMounted(async () => {
|
||||
restoreEditorViewport();
|
||||
syncContextMenuState(view.value);
|
||||
syncEditorFontCssVars(liveFontSize.value, initialSettings.fontFamily);
|
||||
syncEditorDiagnosticCssVars();
|
||||
registerTableReferenceDropListener();
|
||||
|
||||
cachedTables = [];
|
||||
@@ -5476,7 +5487,7 @@ function getCurrentCustomThemeColors() {
|
||||
|
||||
// Reactively apply editor settings changes
|
||||
watch(
|
||||
[queryEditorAppearanceSettings, () => isDark.value, () => themePalette.value],
|
||||
[queryEditorAppearanceSettings, () => isDark.value, () => themePalette.value, editorThemeAppearance],
|
||||
async ([ss]) => {
|
||||
if (!view.value || !codeMirrorTheme || !fontThemeComp || !wordWrapComp || !vimModeComp || !closeBracketsComp || !runGutterComp || !runKeymapComp || !editorViewModule) {
|
||||
return;
|
||||
@@ -5485,6 +5496,7 @@ watch(
|
||||
liveFontSize.value = ss.fontSize;
|
||||
}
|
||||
syncEditorFontCssVars(liveFontSize.value, ss.fontFamily);
|
||||
syncEditorDiagnosticCssVars();
|
||||
const themeColors = getCurrentCustomThemeColors();
|
||||
const [themeExt] = await Promise.all([loadEditorTheme(ss.theme, editorThemeAppearance(), themeColors, themePalette.value), ss.vimModeEnabled ? ensureCodeMirrorVim() : Promise.resolve(false)]);
|
||||
if (!view.value || !codeMirrorTheme || !wordWrapComp || !vimModeComp || !closeBracketsComp || !runGutterComp || !runKeymapComp || !editorViewModule) {
|
||||
|
||||
Reference in new issue
Block a user