style: Update default theme
This commit is contained in:
@@ -15,6 +15,7 @@ import {
|
||||
ThemeElementStyles
|
||||
} from '../../domain/models/theme.model';
|
||||
import {
|
||||
BUILT_IN_THEME_PRESETS,
|
||||
DEFAULT_THEME_JSON,
|
||||
createDefaultThemeDocument,
|
||||
createDefaultThemeLayout,
|
||||
@@ -137,6 +138,7 @@ export class ThemeService {
|
||||
readonly activeThemeName: Signal<string>;
|
||||
readonly knownAnimationClasses: Signal<string[]>;
|
||||
readonly isDraftDirty: Signal<boolean>;
|
||||
readonly builtInPresets = BUILT_IN_THEME_PRESETS;
|
||||
|
||||
private readonly documentRef = inject(DOCUMENT);
|
||||
|
||||
@@ -325,6 +327,26 @@ export class ThemeService {
|
||||
this.setStatusMessage(reason === 'shortcut' ? 'Theme reset to the default preset by shortcut.' : 'Theme reset to the default preset.');
|
||||
}
|
||||
|
||||
applyBuiltInPreset(name: string): boolean {
|
||||
const preset = this.builtInPresets.find((builtInPreset) => builtInPreset.theme.meta.name === name || builtInPreset.key === name);
|
||||
|
||||
if (!preset) {
|
||||
this.setStatusMessage('Built-in theme preset not found.');
|
||||
return false;
|
||||
}
|
||||
|
||||
const theme = structuredClone(preset.theme);
|
||||
const result = validateThemeDocument(theme);
|
||||
|
||||
if (!result.valid || !result.value) {
|
||||
this.setStatusMessage(result.errors[0] ?? 'Built-in theme preset could not be applied.');
|
||||
return false;
|
||||
}
|
||||
|
||||
this.commitTheme(result.value, stringifyTheme(result.value), `${result.value.meta.name} preset applied.`);
|
||||
return true;
|
||||
}
|
||||
|
||||
handleGlobalShortcut(event: KeyboardEvent): boolean {
|
||||
const usesModifier = event.ctrlKey || event.metaKey;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user