feat: adds theme accents config.
This commit is contained in:
parent
4329d419a8
commit
c648ab878a
8 changed files with 116 additions and 20 deletions
|
@ -10,7 +10,7 @@ import { CHARSET } from '../consts/files';
|
|||
import { IThemeVariant } from './../interfaces/itheme-variant';
|
||||
import paths from '../consts/paths';
|
||||
|
||||
let commons = require('../../src/themes/settings/commons.json');
|
||||
let commons = require('../../extensions/accents-setter/commons.json');
|
||||
|
||||
let themeTemplateFileContent: string = fs.readFileSync(path.join(paths.SRC, `/themes/theme-template-color-theme.json`), CHARSET);
|
||||
let themeVariants: IThemeVariant[] = [];
|
||||
|
|
20
extensions/accents-setter/commons.json
Normal file
20
extensions/accents-setter/commons.json
Normal file
|
@ -0,0 +1,20 @@
|
|||
{
|
||||
"accents": {
|
||||
"Acid Lime": "#C6FF00",
|
||||
"Blue": "#2979FF",
|
||||
"Breaking Bad": "#388E3C",
|
||||
"Bright Teal": "#64FFDA",
|
||||
"Cyan": "#00BCD4",
|
||||
"Graphite": "#616161",
|
||||
"Indigo": "#5C6BC0",
|
||||
"Lime": "#7CB342",
|
||||
"Orange": "#FF7042",
|
||||
"Pink": "#FF4081",
|
||||
"Purple": "#AB47BC",
|
||||
"Red": "#E57373",
|
||||
"Sky": "#84FFFF",
|
||||
"Tomato": "#F44336",
|
||||
"Teal": "#80CBC4",
|
||||
"Yellow": "#FFA000"
|
||||
}
|
||||
}
|
76
extensions/accents-setter/index.ts
Normal file
76
extensions/accents-setter/index.ts
Normal file
|
@ -0,0 +1,76 @@
|
|||
import * as vscode from 'vscode';
|
||||
|
||||
import { IGenericObject } from "../interfaces/igeneric-object";
|
||||
import { IThemeConfigCommons } from "../interfaces/icommons";
|
||||
|
||||
let themeConfigCommon: IThemeConfigCommons = require('./commons.json');
|
||||
let accentsProperties: IGenericObject<string> = {
|
||||
"activityBarBadge.background": undefined,
|
||||
"list.activeSelectionForeground": undefined,
|
||||
"list.inactiveSelectionForeground": undefined,
|
||||
"list.highlightForeground": undefined,
|
||||
"scrollbarSlider.activeBackground": undefined,
|
||||
"editorSuggestWidget.highlightForeground": undefined,
|
||||
}
|
||||
|
||||
/**
|
||||
* Assigns colours
|
||||
* @param {string} colour
|
||||
* @param {*} config
|
||||
*/
|
||||
function assignColorCustomizations(colour: string, config: any): void {
|
||||
Object.keys(accentsProperties).forEach(propertyName => {
|
||||
config[propertyName] = colour;
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets workbench options
|
||||
* @param {string} accentSelected
|
||||
* @param {*} config
|
||||
*/
|
||||
function setWorkbenchOptions(accentSelected: string, config: any): void {
|
||||
vscode.workspace.getConfiguration().update('workbench.colorCustomizations', config, true).then(() => {
|
||||
vscode.window.showInformationMessage(`${ accentSelected } set`);
|
||||
}, reason => {
|
||||
vscode.window.showErrorMessage(reason);
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* VSCode command
|
||||
*/
|
||||
export const THEME_ACCENTS_SETTER = () => {
|
||||
// shows the quick pick dropdown
|
||||
let options: string[] = Object.keys(themeConfigCommon.accents);
|
||||
let customColourKey: string = 'Custom colour';
|
||||
let purgeColourKey: string = 'Remove accents';
|
||||
|
||||
options.push(customColourKey);
|
||||
options.push(purgeColourKey);
|
||||
|
||||
vscode.window.showQuickPick(options).then(accentSelected => {
|
||||
if (accentSelected === null || accentSelected === undefined) return;
|
||||
|
||||
let config: any = vscode.workspace.getConfiguration().get('workbench.colorCustomizations');
|
||||
|
||||
switch(accentSelected) {
|
||||
case customColourKey:
|
||||
vscode.window.showInputBox().then(colourCode => {
|
||||
if (colourCode === null || colourCode === undefined) return;
|
||||
|
||||
assignColorCustomizations(colourCode, config);
|
||||
setWorkbenchOptions(accentSelected, config);
|
||||
});
|
||||
break;
|
||||
case purgeColourKey:
|
||||
assignColorCustomizations(undefined, config);
|
||||
setWorkbenchOptions(accentSelected, config);
|
||||
break;
|
||||
default:
|
||||
assignColorCustomizations(themeConfigCommon.accents[accentSelected], config);
|
||||
setWorkbenchOptions(accentSelected, config);
|
||||
break;
|
||||
}
|
||||
});
|
||||
}
|
4
extensions/interfaces/iaccents.ts
Normal file
4
extensions/interfaces/iaccents.ts
Normal file
|
@ -0,0 +1,4 @@
|
|||
export interface IAccents {
|
||||
teal: string;
|
||||
[index: string]: string;
|
||||
}
|
5
extensions/interfaces/icommons.ts
Normal file
5
extensions/interfaces/icommons.ts
Normal file
|
@ -0,0 +1,5 @@
|
|||
import { IAccents } from "./iaccents";
|
||||
|
||||
export interface IThemeConfigCommons {
|
||||
accents: IAccents;
|
||||
}
|
|
@ -1,7 +1,7 @@
|
|||
import * as vscode from 'vscode';
|
||||
|
||||
import { COMMAND_THEME_SETTER } from "./theme-setter/index";
|
||||
import { IGenericObject } from "./interfaces/igeneric-object";
|
||||
import { THEME_ACCENTS_SETTER } from "./accents-setter/index";
|
||||
|
||||
enum Commands {
|
||||
ACCENTS,
|
||||
|
@ -9,8 +9,7 @@ enum Commands {
|
|||
}
|
||||
|
||||
const OPTIONS: IGenericObject<number> = {
|
||||
'Change accents': Commands.ACCENTS,
|
||||
'Change color scheme': Commands.COLOR_THEME
|
||||
'Change accents': Commands.ACCENTS
|
||||
}
|
||||
|
||||
export function activate(context: vscode.ExtensionContext) {
|
||||
|
@ -20,11 +19,8 @@ export function activate(context: vscode.ExtensionContext) {
|
|||
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();
|
||||
case Commands.ACCENTS:
|
||||
THEME_ACCENTS_SETTER();
|
||||
break;
|
||||
}
|
||||
});
|
||||
|
|
|
@ -1,5 +0,0 @@
|
|||
{
|
||||
"accents": {
|
||||
"teal": "#80CBC4"
|
||||
}
|
||||
}
|
|
@ -704,7 +704,7 @@
|
|||
"statusBar.foreground": "{{variant.scheme.statusbarForeground}}",
|
||||
"activityBar.background": "{{variant.scheme.background}}",
|
||||
"activityBar.foreground": "{{variant.scheme.foreground}}",
|
||||
"activityBarBadge.background": "{{commons.accents.teal}}",
|
||||
"activityBarBadge.background": "{{commons.accents.Teal}}",
|
||||
"activityBarBadge.foreground": "{{variant.scheme.base.black}}",
|
||||
"titleBar.activeBackground": "{{variant.scheme.background}}",
|
||||
"titleBar.activeForeground": "{{variant.scheme.comments}}",
|
||||
|
@ -726,12 +726,12 @@
|
|||
"list.hoverForeground": "{{variant.scheme.listHoverForeground}}",
|
||||
"list.hoverBackground": "{{variant.scheme.background}}",
|
||||
"list.activeSelectionBackground": "{{variant.scheme.background}}",
|
||||
"list.activeSelectionForeground": "{{commons.accents.teal}}",
|
||||
"list.inactiveSelectionForeground": "{{commons.accents.teal}}",
|
||||
"list.activeSelectionForeground": "{{commons.accents.Teal}}",
|
||||
"list.inactiveSelectionForeground": "{{commons.accents.Teal}}",
|
||||
"list.inactiveSelectionBackground": "{{variant.scheme.background}}",
|
||||
"list.focusBackground": "{{variant.scheme.foreground}}10",
|
||||
"list.focusForeground": "{{variant.scheme.foreground}}",
|
||||
"list.highlightForeground": "{{commons.accents.teal}}",
|
||||
"list.highlightForeground": "{{commons.accents.Teal}}",
|
||||
"terminal.ansiWhite": "{{variant.scheme.base.white}}",
|
||||
"terminal.ansiBlack": "{{variant.scheme.comments}}",
|
||||
"terminal.ansiBlue": "{{variant.scheme.base.blue}}",
|
||||
|
@ -750,10 +750,10 @@
|
|||
"terminal.ansiBrightYellow": "{{variant.scheme.base.yellow}}",
|
||||
"scrollbarSlider.background": "{{variant.scheme.scrollbars}}",
|
||||
"scrollbarSlider.hoverBackground": "{{variant.scheme.scrollbarsHover}}",
|
||||
"scrollbarSlider.activeBackground": "{{commons.accents.teal}}50",
|
||||
"scrollbarSlider.activeBackground": "{{commons.accents.Teal}}50",
|
||||
"editorSuggestWidget.background": "{{variant.scheme.background}}",
|
||||
"editorSuggestWidget.foreground": "{{variant.scheme.foreground}}",
|
||||
"editorSuggestWidget.highlightForeground": "{{commons.accents.teal}}",
|
||||
"editorSuggestWidget.highlightForeground": "{{commons.accents.Teal}}",
|
||||
"editorSuggestWidget.selectedBackground": "{{variant.scheme.lineHighlight}}50",
|
||||
"editorSuggestWidget.border": "{{variant.scheme.inputBorder}}",
|
||||
|
||||
|
|
Loading…
Reference in a new issue