change theme from command palette

This commit is contained in:
Jan Prochazka
2021-02-25 19:30:20 +01:00
parent f0802dc471
commit fe1fc7923f
5 changed files with 73 additions and 15 deletions

View File

@@ -1,17 +1,23 @@
import { currentTheme } from '../stores';
import registerCommand from './registerCommand';
import { get } from 'svelte/store';
function themeCommand(text, css) {
return {
text: text,
onClick: () => currentTheme.set(css),
// onPreview: () => {
// const old = get(currentTheme);
// currentTheme.set(css);
// return ok => {
// if (!ok) currentTheme.set(old);
// };
// },
};
}
registerCommand({
id: 'theme.changeTheme',
text: 'Theme: Change',
getSubCommands: () => [
{
text: 'Light',
onClick: () => currentTheme.set('theme-light'),
},
{
text: 'Dark',
onClick: () => currentTheme.set('theme-dark'),
},
],
getSubCommands: () => [themeCommand('Light', 'theme-light'), themeCommand('Dark', 'theme-dark')],
});