feat: Adds theme changer command
This commit is contained in:
parent
6ba22488b5
commit
cb68fdc5e3
5 changed files with 75 additions and 0 deletions
3
extensions/interfaces/igeneric-object.ts
Normal file
3
extensions/interfaces/igeneric-object.ts
Normal file
|
@ -0,0 +1,3 @@
|
|||
export interface IGenericObject<TValue> {
|
||||
[index: string]: TValue;
|
||||
}
|
33
extensions/material.theme.config.ts
Normal file
33
extensions/material.theme.config.ts
Normal file
|
@ -0,0 +1,33 @@
|
|||
import * as vscode from 'vscode';
|
||||
|
||||
import { COMMAND_THEME_SETTER } from "./theme-setter/index";
|
||||
import { IGenericObject } from "./interfaces/igeneric-object";
|
||||
|
||||
enum Commands {
|
||||
ACCENTS,
|
||||
COLOR_THEME
|
||||
}
|
||||
|
||||
const OPTIONS: IGenericObject<number> = {
|
||||
'Change accents': Commands.ACCENTS,
|
||||
'Change color scheme': Commands.COLOR_THEME
|
||||
}
|
||||
|
||||
export function activate(context: vscode.ExtensionContext) {
|
||||
// registering the command
|
||||
let command = vscode.commands.registerCommand('material.theme.config', () => {
|
||||
// the user is going to choose what aspect of theme to config
|
||||
vscode.window.showQuickPick(Object.keys(OPTIONS)).then(response => {
|
||||
// switching selected option
|
||||
switch(OPTIONS[response]) {
|
||||
// case Commands.ACCENTS:
|
||||
|
||||
// break;
|
||||
case Commands.COLOR_THEME:
|
||||
COMMAND_THEME_SETTER();
|
||||
break;
|
||||
}
|
||||
});
|
||||
});
|
||||
context.subscriptions.push(command);
|
||||
}
|
18
extensions/theme-setter/index.ts
Normal file
18
extensions/theme-setter/index.ts
Normal file
|
@ -0,0 +1,18 @@
|
|||
import * as vscode from 'vscode';
|
||||
|
||||
import { THEMES } from './themes';
|
||||
|
||||
export const COMMAND_THEME_SETTER = () => {
|
||||
vscode.window.showQuickPick(Object.keys(THEMES)).then(themeSelected => {
|
||||
|
||||
vscode.workspace.getConfiguration().update('workbench.colorTheme', THEMES[themeSelected], true).then(() => {
|
||||
if (themeSelected === undefined) return;
|
||||
|
||||
vscode.window.showInformationMessage(`${ themeSelected } theme set.`);
|
||||
}, () => {
|
||||
if (themeSelected === undefined) return;
|
||||
|
||||
vscode.window.showErrorMessage(`Cannot set theme ${ themeSelected }, please report this bug to the Material theme devs.`);
|
||||
});
|
||||
});
|
||||
};
|
8
extensions/theme-setter/themes.ts
Normal file
8
extensions/theme-setter/themes.ts
Normal file
|
@ -0,0 +1,8 @@
|
|||
import { IGenericObject } from "../interfaces/igeneric-object";
|
||||
|
||||
export const THEMES: IGenericObject<string> = {
|
||||
Default: 'Material Theme',
|
||||
Darker: 'Material Theme Darker',
|
||||
Lighter: 'Material Theme Lighter',
|
||||
'Pale night': 'Material Theme Palenight'
|
||||
}
|
13
package.json
13
package.json
|
@ -31,6 +31,7 @@
|
|||
"build-icons": "npm run remove-icons && npm run minimize-icons && gulp build:icons && npm run minimize-json",
|
||||
"build-themes": "gulp build:themes",
|
||||
"release": "npm run bump && npm run changelog",
|
||||
"postinstall": "node ./node_modules/vscode/bin/instal",
|
||||
"changelog": "gulp changelog",
|
||||
"bump": "gulp bump"
|
||||
},
|
||||
|
@ -38,7 +39,18 @@
|
|||
"Themes",
|
||||
"Other"
|
||||
],
|
||||
"activationEvents": [
|
||||
"onCommand:material.theme.config"
|
||||
],
|
||||
"main": "./extensions/material.theme.config",
|
||||
"contributes": {
|
||||
"commands": [
|
||||
{
|
||||
"category": "Material theme",
|
||||
"command": "material.theme.config",
|
||||
"title": "Material theme settings"
|
||||
}
|
||||
],
|
||||
"themes": [
|
||||
{
|
||||
"label": "Material Theme",
|
||||
|
@ -104,6 +116,7 @@
|
|||
"run-sequence": "^1.2.2",
|
||||
"svgo": "^0.7.1",
|
||||
"typescript": "2.3.3",
|
||||
"vscode": "^1.1.0",
|
||||
"yamljs": "^0.2.10",
|
||||
"yargs": "^7.1.0"
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue