Merge branch 'develop'

This commit is contained in:
Mattia Astorino 2018-11-25 15:21:16 +01:00
commit 73f4010054
16 changed files with 128 additions and 64 deletions

View file

@ -20,16 +20,5 @@ A clear and concise description of what you expected to happen.
**Screenshots**
If applicable, add screenshots to help explain your problem.
**Desktop (please complete the following information):**
- OS: [e.g. iOS]
- Browser [e.g. chrome, safari]
- Version [e.g. 22]
**Smartphone (please complete the following information):**
- Device: [e.g. iPhone6]
- OS: [e.g. iOS8.1]
- Browser [e.g. stock browser, safari]
- Version [e.g. 22]
**Additional context**
Add any other context about the problem here.

View file

@ -41,9 +41,11 @@ Launch *Quick Open*
Paste the following command and press `Enter`:
```shell
ext install vsc-material-theme
ext install material theme
```
And pick the one by **Mattia Astorino** (me) as author.
#### Packaged VSIX Extension
[Download the latest .vsix release](https://marketplace.visualstudio.com/_apis/public/gallery/publishers/Equinusocio/vsextensions/vsc-material-theme/latest/vspackage) file from the marketplace and install it from the command line

View file

@ -0,0 +1,3 @@
export default {
PURGE_KEY: 'Remove accents'
};

View file

@ -1,29 +1,27 @@
import * as vscode from 'vscode';
import {updateAccent} from './../../helpers/settings';
import {getDefaultValues, getAccentsProperties} from './../../helpers/fs';
import consts from './consts';
const REGEXP_HEX: RegExp = /^#([0-9A-F]{6}|[0-9A-F]{8})$/i;
/**
* Assigns colours
*/
const assignColorCustomizations = (colour: string, config: any): void => {
const assignColorCustomizations = (colour: string): Object => {
const accentsProperties = getAccentsProperties();
const newColour = isValidColour(colour) ? colour : undefined;
Object.keys(accentsProperties).forEach(propertyName => {
const accent = accentsProperties[propertyName];
return Object.keys(accentsProperties).reduce((acc: any, propName) => {
const accent = accentsProperties[propName];
let colorProp = newColour;
if (colour && accent.alpha < 100) {
colorProp = `${ colour }${ accent.alpha > 10 ? accent.alpha : `0${ accent.alpha }` }`;
}
if (accent) {
config[propertyName] = colorProp;
}
});
acc[propName] = colorProp;
return acc;
}, {});
};
/**
@ -38,43 +36,32 @@ const isValidColour = (colour: string | null | undefined): boolean =>
const setWorkbenchOptions = (config: any): Thenable<boolean> =>
vscode.workspace.getConfiguration().update('workbench.colorCustomizations', config, true)
.then(() => true, reason => vscode.window.showErrorMessage(reason));
/**
* VSCode command
*/
export default async (accent?: string): Promise<boolean> => {
const themeConfigCommon = getDefaultValues();
const purgeColourKey: string = 'Remove accents';
const shouldUpdateAccent = Boolean(!accent);
let accentToSelect = accent;
// If called without accent shows the quick pick dropdown and wait response
if (!accentToSelect) {
const options: string[] = Object.keys(themeConfigCommon.accents).concat(purgeColourKey);
const accentSelected = await vscode.window.showQuickPick(options);
if (accentSelected === null || accentSelected === undefined) {
return Promise.resolve(null);
}
accentToSelect = accentSelected;
}
const config: any = vscode.workspace.getConfiguration().get('workbench.colorCustomizations');
switch (accentToSelect) {
case purgeColourKey:
assignColorCustomizations(undefined, config);
return setWorkbenchOptions(config)
.then(() => updateAccent(undefined))
.then(() => Promise.resolve(true));
default:
assignColorCustomizations(themeConfigCommon.accents[accentToSelect], config);
return setWorkbenchOptions(config)
.then(() =>
shouldUpdateAccent ? updateAccent(accentToSelect) : Promise.resolve(accentToSelect)
)
switch (accent) {
case consts.PURGE_KEY: {
const newConfig = {
...config,
...assignColorCustomizations(undefined)
};
return setWorkbenchOptions(newConfig)
.then(() => Promise.resolve(true));
}
default: {
const newConfig = {
...config,
...assignColorCustomizations(themeConfigCommon.accents[accent])
};
return setWorkbenchOptions(newConfig)
.then(() => Boolean(accent));
}
}
};

View file

@ -0,0 +1,9 @@
import * as vscode from 'vscode';
import {getDefaultValues} from '../../helpers/fs';
import consts from './consts';
export default async () => {
const themeConfigCommon = getDefaultValues();
const options: string[] = Object.keys(themeConfigCommon.accents).concat(consts.PURGE_KEY);
return vscode.window.showQuickPick(options);
};

View file

@ -1,3 +1,4 @@
export {default as accentsSetter} from './accents-setter';
export {default as accentsQuickPick} from './accents-setter/quick-pick';
export {default as fixIcons} from './theme-icons';
export {default as toggleApplyIcons} from './toggle-apply-icons';

View file

@ -116,7 +116,7 @@
}
},
"changelog": {
"lastversion": "2.5.0"
"lastversion": "2.5.1"
},
"icons": {
"theme": {

View file

@ -40,11 +40,11 @@ export function isAccent(accentName: string, defaults: IDefaults): boolean {
}
/**
* Determines if the passing theme label is a material theme
* Determines if the passing theme id is a material theme
*/
export function isMaterialTheme(themeName: string): boolean {
const packageJSON = getPackageJSON();
return Boolean(packageJSON.contributes.themes.find(contrib => contrib.label === themeName));
return Boolean(packageJSON.contributes.themes.find(contrib => contrib.id === themeName));
}
/**

View file

@ -24,6 +24,7 @@ export interface IPackageJSONCommand {
}
export interface IPackageJSONTheme {
id: string;
label: string;
path: string;
uiTheme: string;

View file

@ -5,13 +5,12 @@ import {
} from 'vscode';
import * as ThemeCommands from './commands';
import {setCustomSetting} from './helpers/settings';
import {setCustomSetting, updateAccent} from './helpers/settings';
import {onChangeConfiguration} from './helpers/configuration-change';
import {changelogMessage, installationMessage} from './helpers/messages';
import checkInstallation from './helpers/check-installation';
import writeChangelog from './helpers/write-changelog';
import {ReleaseNotesWebview} from './webviews/ReleaseNotes';
import handleAutoapply from './helpers/handle-autoapply';
export async function activate(context: ExtensionContext) {
const config = Workspace.getConfiguration();
@ -42,8 +41,8 @@ export async function activate(context: ExtensionContext) {
// Registering commands
Commands.registerCommand('materialTheme.setAccent', async () => {
const wasSet = await ThemeCommands.accentsSetter();
handleAutoapply(wasSet);
const accentPicked = await ThemeCommands.accentsQuickPick();
await updateAccent(accentPicked);
});
Commands.registerCommand('materialTheme.fixIcons', () => ThemeCommands.fixIcons());
Commands.registerCommand('materialTheme.toggleApplyIcons', () => ThemeCommands.toggleApplyIcons());

View file

@ -122,51 +122,61 @@
},
"themes": [
{
"id": "eq-material-theme-default",
"label": "Material Theme",
"path": "./themes/Material-Theme-Default.json",
"uiTheme": "vs-dark"
},
{
"id": "eq-material-theme-default-high-contrast",
"label": "Material Theme High Contrast",
"path": "./themes/Material-Theme-Default-High-Contrast.json",
"uiTheme": "vs-dark"
},
{
"id": "eq-material-theme-darker",
"label": "Material Theme Darker",
"path": "./themes/Material-Theme-Darker.json",
"uiTheme": "vs-dark"
},
{
"id": "eq-material-theme-darker-high-contrast",
"label": "Material Theme Darker High Contrast",
"path": "./themes/Material-Theme-Darker-High-Contrast.json",
"uiTheme": "vs-dark"
},
{
"id": "eq-material-theme-palenight",
"label": "Material Theme Palenight",
"path": "./themes/Material-Theme-Palenight.json",
"uiTheme": "vs-dark"
},
{
"id": "eq-material-theme-palenight-high-contrast",
"label": "Material Theme Palenight High Contrast",
"path": "./themes/Material-Theme-Palenight-High-Contrast.json",
"uiTheme": "vs-dark"
},
{
"id": "eq-material-theme-ocean",
"label": "Material Theme Ocean",
"path": "./themes/Material-Theme-Ocean.json",
"uiTheme": "vs-dark"
},
{
"id": "eq-material-theme-ocean-high-contrast",
"label": "Material Theme Ocean High Contrast",
"path": "./themes/Material-Theme-Ocean-High-Contrast.json",
"uiTheme": "vs-dark"
},
{
"id": "eq-material-theme-lighter",
"label": "Material Theme Lighter",
"path": "./themes/Material-Theme-Lighter.json",
"uiTheme": "vs"
},
{
"id": "eq-material-theme-lighter-high-contrast",
"label": "Material Theme Lighter High Contrast",
"path": "./themes/Material-Theme-Lighter-High-Contrast.json",
"uiTheme": "vs"

View file

@ -17,7 +17,6 @@
"lnk": "_file_lnk",
"pm": "_file_perl",
"pl": "_file_perl",
"sql": "_file_sql",
"jl": "_file_julia",
"gv": "_file_graphviz",
"erl": "_file_erlang",
@ -63,6 +62,7 @@
"sass": "_file_sass",
"less": "_file_less",
"json": "_file_json",
"jsonc": "_file_json",
"yaml": "_file_yaml",
"YAML-tmLanguage": "_file_yaml",
"yml": "_file_yaml",
@ -185,6 +185,7 @@
"prop": "_file_settings",
"settings": "_file_settings",
"sql": "_file_database",
"db": "_file_database",
"accdb": "_file_database",
"mdb": "_file_database",
"cer": "_file_certificate",

View file

@ -77,7 +77,9 @@
"license.md": "_file_license",
"license.md.rendered": "_file_license",
"license.txt": "_file_license",
"babel.config.js": "_file_babel",
".babelrc": "_file_babel",
".babelrc.js": "_file_babel",
".babelrc.json": "_file_babel",
".eslintrc": "_file_eslint",
".eslintignore": "_file_eslint",
@ -125,5 +127,7 @@
".angular-cli.json": "_file_angular",
"directive.ts": "_file_angular-directive",
"directive.js": "_file_angular-directive",
"favicon.ico": "_file_favicon"
"favicon.ico": "_file_favicon",
"mix.lock": "_file_elixir-lock",
"now.json": "_file_now"
},

View file

@ -2,6 +2,8 @@
"ci": "_folder_ci",
"test": "_folder_test",
"tests": "_folder_test",
"__test__": "_folder_test",
"__tests__": "_folder_test",
"node_modules": "_folder_node",
"assets": "_folder_assets",
"bower_components": "_folder_bower",
@ -18,13 +20,16 @@
".vscode": "_folder_vscode",
".gulp": "_folder_gulp",
"gulp": "_folder_gulp",
"build": "_folder_dark_dist",
"dist": "_folder_dist"
"build": "_folder_dist",
"dist": "_folder_dist",
"out": "_folder_dist"
},
"folderNamesExpanded": {
"ci": "_folder_ci_open",
"test": "_folder_test_open",
"tests": "_folder_test_open",
"__test__": "_folder_test_open",
"__tests__": "_folder_test_open",
"node_modules": "_folder_node_open",
"bower_components": "_folder_bower_open",
"assets": "_folder_assets_open",
@ -40,6 +45,7 @@
".github": "_folder_github_open",
".gulp": "_folder_gulp_open",
".vscode": "_folder_vscode_open",
"build": "_folder_open_dist",
"dist": "_folder_dist_open"
"build": "_folder_dist_open",
"dist": "_folder_dist_open",
"out": "_folder_dist_open"
}

View file

@ -5,5 +5,56 @@
"hxml": "_file_haxe",
"polymer": "_file_polymer",
"matlab": "_file_matlab",
"makefile": "_file_settings"
"bat": "_file_cmd",
"c": "_file_c",
"csharp": "_file_csharp",
"cpp": "_file_cpp",
"css": "_file_css",
"clojure": "_file_clojure",
"coffeescript": "_file_coffee",
"dart": "_file_dart",
"diff": "_file_git",
"dockerfile": "_file_docker",
"fsharp": "_file_fsharp",
"git-commit": "_file_git",
"git-rebase": "_file_git",
"go": "_file_go",
"groovy": "_file_groovy",
"html": "_file_html",
"handlebars": "_file_handlebars",
"ignore": "_file_git",
"ini": "_file_settings",
"json": "_file_json",
"jsonc": "_file_json",
"java": "_file_java",
"javascript": "_file_js",
"javascriptreact": "_file_react",
"less": "_file_less",
"lua": "_file_lua",
"makefile": "_file_settings",
"markdown": "_file_markdown",
"objective-c": "_file_matlab",
"objective-cpp": "_file_cpp",
"php": "_file_php",
"perl": "_file_perl",
"perl6": "_file_perl",
"plaintext": "_file_document",
"powershell": "_file_console",
"properties": "_file_settings",
"proto3": "_file_protobuf",
"jade": "_file_pug",
"python": "_file_python",
"r": "_file_r",
"ruby": "_file_ruby",
"rust": "_file_rust",
"scss": "_file_sass",
"sql": "_file_database",
"shellscript": "_file_console",
"swift": "_file_swift",
"typescript": "_file_typescript",
"typescriptreact": "_file_react",
"vb": "_file_visualstudio",
"xml": "_file_xml",
"xsl": "_file_xml",
"yaml": "_file_yaml"
},

View file

@ -742,6 +742,7 @@
"titleBar.border": "{{variant.scheme.contrastBorder}}60",
"sideBarTitle.foreground": "{{variant.scheme.foreground}}",
"sideBarSectionHeader.background": "{{variant.scheme.backgroundAlt}}",
"sideBarSectionHeader.border": "{{variant.scheme.contrastBorder}}60",
"input.background": "{{variant.scheme.inputBackground}}",
"input.foreground": "{{variant.scheme.inputForeground}}",
"input.placeholderForeground": "{{variant.scheme.foreground}}60",