Skip to content

Commit

Permalink
Merge 010a6d7 into a367bf6
Browse files Browse the repository at this point in the history
  • Loading branch information
Yash-Singh1 committed Jun 16, 2022
2 parents a367bf6 + 010a6d7 commit a1ebb7b
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
6 changes: 3 additions & 3 deletions src/lib/util/state.ts
Original file line number Diff line number Diff line change
Expand Up @@ -103,11 +103,11 @@ export const updateConfig = (config: string, updateEditor: boolean): void => {
});
};

export const toggleDarkTheme = (dark: boolean): void => {
export const setDiagramTheme = (theme: 'dark' | 'default' | 'forest'): void => {
codeStore.update((state) => {
const config = JSON.parse(state.mermaid);
if (!config.theme || ['dark', 'default'].includes(config.theme)) {
config.theme = dark ? 'dark' : 'default';
if (!config.theme || ['dark', 'default', 'forest'].includes(config.theme)) {
config.theme = theme;
}

return { ...state, mermaid: JSON.stringify(config, null, 2), updateEditor: true };
Expand Down
4 changes: 2 additions & 2 deletions src/routes/__layout.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import { onMount } from 'svelte';
import { loadingStateStore } from '$lib/util/loading';
import { setTheme, themeStore } from '$lib/util/theme';
import { toggleDarkTheme } from '$lib/util/state';
import { setDiagramTheme } from '$lib/util/state';
// This can be removed once https://github.com/sveltejs/kit/issues/1612 is fixed.
// Then move it into src and vite will bundle it automatically.
Expand All @@ -31,7 +31,7 @@
themeStore.subscribe(({ theme, isDark }) => {
if (theme) {
document.getElementsByTagName('html')[0].setAttribute('data-theme', theme);
toggleDarkTheme(isDark);
setDiagramTheme(isDark ? (theme === 'forest' ? 'forest' : 'dark') : 'default');
}
});
});
Expand Down

0 comments on commit a1ebb7b

Please sign in to comment.