Modern Docker Management, Designed for Everyone
Go composecontainer-managementcontainersdockerdocker-composedocker-managementgoself-hostedsveltekittypescriptweb-ui
fix: use accent color for code editor highlighter
Kyle Mendellee6a0adb68fb
diff --git a/frontend/src/lib/components/code-editor/editor.svelte b/frontend/src/lib/components/code-editor/editor.svelteindex bedc34218..1944d529f 100644--- a/frontend/src/lib/components/code-editor/editor.svelte+++ b/frontend/src/lib/components/code-editor/editor.svelte@@ -5,11 +5,12 @@import { properties } from '@codemirror/legacy-modes/mode/properties';import { linter, lintGutter } from '@codemirror/lint';import jsyaml from 'js-yaml';- import { arcaneDark } from './theme';+ import { arcaneDarkInit } from './theme';import type { EditorView } from '@codemirror/view';import type { Extension } from '@codemirror/state';import type { Diagnostic, LintSource } from '@codemirror/lint';import { m } from '$lib/paraglide/messages';+ import configStore from '$lib/stores/config-store';type CodeLanguage = 'yaml' | 'env';@@ -68,7 +69,12 @@return diagnostics;};- const extensions = $derived([...getLanguageExtension(language), arcaneDark]);+ const theme = $derived.by(() => {+ $configStore;+ return arcaneDarkInit();+ });++ const extensions = $derived([...getLanguageExtension(language), theme]);const styles = $derived({'&': {diff --git a/frontend/src/lib/components/code-editor/theme.ts b/frontend/src/lib/components/code-editor/theme.tsindex d2bbe4e9d..2df6680fd 100644--- a/frontend/src/lib/components/code-editor/theme.ts+++ b/frontend/src/lib/components/code-editor/theme.ts@@ -1,50 +1,87 @@import { tags as t } from '@lezer/highlight';import { createTheme, type CreateThemeOptions } from '@uiw/codemirror-themes';-export const arcaneDarkSettings: CreateThemeOptions['settings'] = {- background: '#0d1117',- foreground: '#c9d1d9',- caret: '#a78bfa',- selection: 'rgba(167,139,250,0.35)',- selectionMatch: 'rgba(167,139,250,0.20)',- lineHighlight: '#161b22',- gutterBackground: '#0d1117',- gutterForeground: '#8b949e',- gutterActiveForeground: '#c9d1d9',- gutterBorder: 'transparent',-- fontFamily: '"Geist Mono", ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace',- fontSize: '13px'-};+function getAccentColor(): string {+ const primaryColor = getComputedStyle(document.documentElement).getPropertyValue('--primary').trim();-export const arcaneDarkStyles: CreateThemeOptions['styles'] = [- { tag: [t.comment, t.meta], color: '#8b949e' },- { tag: [t.keyword, t.modifier, t.operatorKeyword], color: '#ff7b72' },+ return primaryColor || 'oklch(0.606 0.25 292.717)';+}- { tag: [t.typeName, t.namespace, t.number, t.atom, t.bool], color: '#ffa657' },- { tag: [t.function(t.variableName), t.labelName], color: '#79c0ff' },- { tag: [t.className, t.definition(t.variableName), t.propertyName, t.attributeName], color: '#d2a8ff' },+function getAccentColorWithAlpha(alpha: number): string {+ const accentColor = getAccentColor();- { tag: [t.variableName, t.name], color: '#e6edf3' },- { tag: [t.string, t.inserted, t.regexp, t.special(t.string)], color: '#7ee787' },- { tag: [t.operator, t.url, t.link, t.escape], color: '#a5d6ff' },+ if (accentColor.startsWith('oklch')) {+ const hasAlpha = accentColor.includes('/');+ if (hasAlpha) {+ return accentColor.replace(/\/\s*[\d.]+\s*\)/, ` / ${alpha})`);+ }+ return accentColor.replace(')', ` / ${alpha})`);+ }- { tag: [t.separator, t.punctuation], color: '#6e7681' },+ if (accentColor.startsWith('#')) {+ const r = parseInt(accentColor.slice(1, 3), 16);+ const g = parseInt(accentColor.slice(3, 5), 16);+ const b = parseInt(accentColor.slice(5, 7), 16);+ return `rgba(${r}, ${g}, ${b}, ${alpha})`;+ }- { tag: t.heading, color: '#e6edf3', fontWeight: 'bold' },- { tag: t.strong, fontWeight: 'bold' },- { tag: t.emphasis, fontStyle: 'italic' },- { tag: t.strikethrough, textDecoration: 'line-through' },- { tag: t.invalid, color: '#f85149' },- { tag: t.link, textDecoration: 'underline' }-];+ return accentColor;+}export const arcaneDarkInit = (options?: Partial<CreateThemeOptions>) => {const { theme = 'dark', 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: '#0d1117',+ foreground: '#c9d1d9',+ caret: accentColor,+ selection: accentWithAlpha35,+ selectionMatch: accentWithAlpha15,+ lineHighlight: accentWithAlpha05,+ gutterBackground: '#0d1117',+ gutterForeground: '#8b949e',+ gutterActiveForeground: '#c9d1d9',+ gutterBorder: 'transparent',++ fontFamily:+ '"Geist Mono", ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace',+ fontSize: '13px'+ };++ const dynamicStyles: CreateThemeOptions['styles'] = [+ { tag: [t.comment, t.meta], color: '#8b949e' },+ { tag: [t.keyword, t.modifier, t.operatorKeyword], color: '#ff7b72' },++ { tag: [t.typeName, t.namespace, t.number, t.atom, t.bool], color: '#ffa657' },+ { tag: [t.function(t.variableName), t.labelName], color: accentColor },+ {+ tag: [t.className, t.definition(t.variableName), t.propertyName, t.attributeName],+ color: '#d2a8ff'+ },++ { tag: [t.variableName, t.name], color: '#e6edf3' },+ { tag: [t.string, t.inserted, t.regexp, t.special(t.string)], color: '#7ee787' },+ { tag: [t.operator, t.url, t.link, t.escape], color: '#a5d6ff' },++ { tag: [t.separator, t.punctuation], color: '#6e7681' },++ { tag: t.heading, color: '#e6edf3', fontWeight: 'bold' },+ { tag: t.strong, fontWeight: 'bold' },+ { tag: t.emphasis, fontStyle: 'italic' },+ { tag: t.strikethrough, textDecoration: 'line-through' },+ { tag: t.invalid, color: '#f85149' },+ { tag: t.link, textDecoration: 'underline' }+ ];+return createTheme({theme,- settings: { ...arcaneDarkSettings, ...settings },- styles: [...arcaneDarkStyles, ...styles]+ settings: { ...dynamicSettings, ...settings },+ styles: [...dynamicStyles, ...styles]});};diff --git a/frontend/src/lib/utils/form.utils.ts b/frontend/src/lib/utils/form.utils.tsindex 942212596..6c44750c0 100644--- a/frontend/src/lib/utils/form.utils.ts+++ b/frontend/src/lib/utils/form.utils.ts@@ -24,7 +24,12 @@ export function createForm<T extends z.ZodType<any, any>>(schema: T, initialValufunction initializeInputs(initialValues: z.infer<T>): FormInputs<z.infer<T>> {const inputs: FormInputs<z.infer<T>> = {} as FormInputs<z.infer<T>>;- for (const key in initialValues) {++ // Get the shape keys from the schema to only include defined fields+ const schemaShape = schema instanceof z.ZodObject ? schema.shape : {};+ const schemaKeys = Object.keys(schemaShape);++ for (const key of schemaKeys) {if (Object.prototype.hasOwnProperty.call(initialValues, key)) {inputs[key as keyof z.infer<T>] = {value: initialValues[key as keyof z.infer<T>],diff --git a/frontend/src/routes/settings/docker/+page.ts b/frontend/src/routes/settings/docker/+page.tsdeleted file mode 100644index 05b28acb1..000000000--- a/frontend/src/routes/settings/docker/+page.ts+++ /dev/null@@ -1,7 +0,0 @@-export const load = async ({ parent }) => {- const { settings } = await parent();-- return {- settings- };-};diff --git a/frontend/src/routes/settings/general/+page.svelte b/frontend/src/routes/settings/general/+page.svelteindex 5e191c2c4..23085f6d8 100644--- a/frontend/src/routes/settings/general/+page.svelte+++ b/frontend/src/routes/settings/general/+page.svelte@@ -22,8 +22,7 @@let hasChanges = $state(false);let isLoading = $state(false);- const settings = $state(data.settings!);-+ let currentSettings = $state(data.settings!);const isReadOnly = $derived.by(() => $settingsStore.uiConfigDisabled);const formState = getContext('settingsFormState') as any;const formSchema = z.object({@@ -33,15 +32,14 @@accentColor: z.string()});- // Create form once with initial data- const { inputs: formInputs, ...form } = createForm<typeof formSchema>(formSchema, settings);+ let { inputs: formInputs, ...form } = $derived(createForm<typeof formSchema>(formSchema, currentSettings));const formHasChanges = $derived.by(() =>- $formInputs.projectsDirectory.value !== settings.projectsDirectory ||- $formInputs.baseServerUrl.value !== settings.baseServerUrl ||- $formInputs.enableGravatar.value !== settings.enableGravatar ||- $formInputs.accentColor.value !== settings.accentColor+ $formInputs.projectsDirectory.value !== currentSettings.projectsDirectory ||+ $formInputs.baseServerUrl.value !== currentSettings.baseServerUrl ||+ $formInputs.enableGravatar.value !== currentSettings.enableGravatar ||+ $formInputs.accentColor.value !== currentSettings.accentColor);$effect(() => {@@ -55,7 +53,9 @@async function updateSettingsConfig(updatedSettings: Partial<Settings>) {try {await settingsService.updateSettings(updatedSettings as any);- settingsStore.set({ ...settings, ...updatedSettings } as Settings);+ currentSettings = { ...currentSettings, ...updatedSettings };+ settingsStore.set(currentSettings);+ settingsStore.reload();} catch (error) {console.error('Error updating settings:', error);throw error;@@ -80,11 +80,11 @@}function resetForm() {- $formInputs.projectsDirectory.value = settings.projectsDirectory;- $formInputs.baseServerUrl.value = settings.baseServerUrl;- $formInputs.enableGravatar.value = settings.enableGravatar;- $formInputs.accentColor.value = settings.accentColor;- applyAccentColor(settings.accentColor);+ $formInputs.projectsDirectory.value = data.settings!.projectsDirectory;+ $formInputs.baseServerUrl.value = data.settings!.baseServerUrl;+ $formInputs.enableGravatar.value = data.settings!.enableGravatar;+ $formInputs.accentColor.value = data.settings!.accentColor;+ applyAccentColor(data.settings!.accentColor);}onMount(() => {@@ -160,7 +160,7 @@<Card.Content class="px-3 py-4 sm:px-6"><div class="space-y-5"><AccentColorPicker- previousColor={settings.accentColor}+ previousColor={currentSettings.accentColor}bind:selectedColor={$formInputs.accentColor.value}disabled={isReadOnly}/>