Modern Docker Management, Designed for Everyone
Go composecontainer-managementcontainersdockerdocker-composedocker-managementgoself-hostedsveltekittypescriptweb-ui
fix: respect light/dark theme in code editor (#2145)
Giulio Savini0daf31de2a39
diff --git a/frontend/src/lib/components/code-editor/editor.svelte b/frontend/src/lib/components/code-editor/editor.svelteindex 7e7dfc96c..0294a713b 100644--- a/frontend/src/lib/components/code-editor/editor.svelte+++ b/frontend/src/lib/components/code-editor/editor.svelte@@ -20,7 +20,8 @@import { browser } from '$app/environment';import { m } from '$lib/paraglide/messages';import configStore from '$lib/stores/config-store';- import { arcaneDarkInit } from './theme';+ import { mode } from 'mode-watcher';+ import { arcaneDarkInit, arcaneLightInit } from './theme';import { createDefaultSummary, ENV_SNIPPETS, YAML_SNIPPETS } from './editor-constants';import { createEnterIndentKeymap } from './enter-indentation';import { createMergeHostAction, type MergeActionParams } from './merge-editor';@@ -566,7 +567,7 @@const theme = $derived.by(() => {$configStore;- return arcaneDarkInit();+ return mode.current === 'dark' ? arcaneDarkInit() : arcaneLightInit();});const mergeHostAction = createMergeHostAction({@@ -720,14 +721,22 @@:global(.arcane-code-editor .cm-editor .cm-scroller) {overflow-x: auto;}- :global(.arcane-code-editor .cm-editor .cm-gutters) {+ :global(.dark .arcane-code-editor .cm-editor .cm-gutters) {background-color: #18181b;border-right: none;}- :global(.arcane-code-editor .cm-editor .cm-activeLineGutter) {+ :global(.dark .arcane-code-editor .cm-editor .cm-activeLineGutter) {background-color: #2c313a;color: #e5e7eb;}+ :global(:root:not(.dark) .arcane-code-editor .cm-editor .cm-gutters) {+ background-color: #ffffff;+ border-right: none;+ }+ :global(:root:not(.dark) .arcane-code-editor .cm-editor .cm-activeLineGutter) {+ background-color: #f0f1f3;+ color: #24292f;+ }:global(.arcane-code-editor .cm-mergeView) {height: 100%;}diff --git a/frontend/src/lib/components/code-editor/theme.ts b/frontend/src/lib/components/code-editor/theme.tsindex 534f3b109..ac9d768f0 100644--- a/frontend/src/lib/components/code-editor/theme.ts+++ b/frontend/src/lib/components/code-editor/theme.ts@@ -85,3 +85,60 @@ export const arcaneDarkInit = (options?: Partial<CreateThemeOptions>) => {};export const arcaneDark = arcaneDarkInit();++export const arcaneLightInit = (options?: Partial<CreateThemeOptions>) => {+ const { theme = 'light', settings = {}, styles = [] } = options || {};++ const accentColor = getAccentColor();+ const accentWithAlpha35 = getAccentColorWithAlpha(0.35);+ const accentWithAlpha15 = getAccentColorWithAlpha(0.15);+ const accentWithAlpha05 = getAccentColorWithAlpha(0.05);++ const dynamicSettings: CreateThemeOptions['settings'] = {+ background: '#ffffff',+ foreground: '#24292f',+ caret: accentColor,+ selection: accentWithAlpha35,+ selectionMatch: accentWithAlpha15,+ lineHighlight: accentWithAlpha05,+ gutterBackground: '#ffffff',+ gutterForeground: '#8c959f',+ gutterActiveForeground: '#24292f',+ gutterBorder: 'transparent',++ fontFamily: '"Geist Mono", ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", "Courier New", monospace',+ fontSize: '13px'+ };++ const dynamicStyles: CreateThemeOptions['styles'] = [+ { tag: [t.comment, t.meta], color: '#6e7781' },+ { tag: [t.keyword, t.modifier, t.operatorKeyword], color: '#cf222e' },++ { tag: [t.typeName, t.namespace, t.number, t.atom, t.bool], color: '#953800' },+ { tag: [t.function(t.variableName), t.labelName], color: accentColor },+ {+ tag: [t.className, t.definition(t.variableName), t.propertyName, t.attributeName],+ color: '#8250df'+ },++ { tag: [t.variableName, t.name], color: '#24292f' },+ { tag: [t.string, t.inserted, t.regexp, t.special(t.string)], color: '#0a3069' },+ { tag: [t.operator, t.url, t.link, t.escape], color: '#0550ae' },++ { tag: [t.separator, t.punctuation], color: '#6e7781' },++ { tag: t.heading, color: '#24292f', fontWeight: 'bold' },+ { tag: t.strong, fontWeight: 'bold' },+ { tag: t.emphasis, fontStyle: 'italic' },+ { tag: t.strikethrough, textDecoration: 'line-through' },+ { tag: t.invalid, color: '#cf222e' },+ { tag: t.link, textDecoration: 'underline' }+ ];++ return createTheme({+ theme,+ settings: { ...dynamicSettings, ...settings },+ styles: [...dynamicStyles, ...styles]+ });+};+