Skip to content

Commit

Permalink
Merge pull request #6 from golf1052/fix-theme-type
Browse files Browse the repository at this point in the history
Fix theme type
  • Loading branch information
golf1052 authored Oct 8, 2017
2 parents da232a7 + a331be7 commit b04aeb9
Show file tree
Hide file tree
Showing 6 changed files with 1,750 additions and 3 deletions.
3 changes: 2 additions & 1 deletion src/scripts/finish-themes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
import * as fs from 'fs';
import * as path from 'path';
var cjson = require('strip-json-comments');
import * as generate_light_schemes from './generate-light-schemes';

export function main(): void {
mainWithDir('.');
Expand All @@ -15,7 +16,7 @@ export function mainWithDir(workingDirectory: string): void {

files.forEach(f => {
let json = JSON.parse(cjson(fs.readFileSync(path.resolve(workingDirectory, f), 'utf8')));
if (f.indexOf('-light') != -1) {
if (!generate_light_schemes.isColorDark(json['colors']['editor.background'])) {
json.type = 'light';
}
fs.writeFileSync(path.resolve(workingDirectory, f), JSON.stringify(json, null, 4));
Expand Down
2 changes: 1 addition & 1 deletion src/scripts/generate-light-schemes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -259,7 +259,7 @@ function isSchemeDark(schemeFile: string, pathToSchemeFolder: string): SchemePro
return schemeProperties;
}

function isColorDark(inputColor: string): boolean {
export function isColorDark(inputColor: string): boolean {
let c = color(inputColor);
// algorithm from https://docs.microsoft.com/en-us/windows/uwp/style/color
return (5 * c.green() + 2 * c.red() + c.blue()) <= 8 * 128;
Expand Down
2 changes: 2 additions & 0 deletions themes.md
Original file line number Diff line number Diff line change
Expand Up @@ -146,5 +146,7 @@ Unikitty Dark
Unikitty Light
Woodland Dark
Woodland Light
XCode Dusk Dark
XCode Dusk Light
Zenburn Dark
Zenburn Light
2 changes: 1 addition & 1 deletion themes/base16-github.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "Base16 Github",
"type": "dark",
"type": "light",
"colors": {
"foreground": "#333333",
"widget.shadow": "#ffffff",
Expand Down
Loading

0 comments on commit b04aeb9

Please sign in to comment.