Skip to content

Commit

Permalink
Reworked build system so it is easier to add new languages, updated d…
Browse files Browse the repository at this point in the history
…ocumentation
  • Loading branch information
evrowe committed Jun 14, 2017
1 parent 66b6918 commit 9e5dd63
Show file tree
Hide file tree
Showing 5 changed files with 54 additions and 13 deletions.
8 changes: 6 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# Change Log

## 0.1.0 - 2017-13-2017
Updates to the the "Cold Snack" theme will be tracked and documented in this file.

- 🎉 Initial release!
This project utilizes [Semantic Versioning](http://semver.org/).

## [1.0.0] - 2017-06-14

🎉 Initial release!
25 changes: 24 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,37 @@ There's nothing better in life than a tall, refreshing, cold snack for your tast
Reminiscent of the Unofficial Official Beer of Montana, the Cold Snack theme will soothe and satiate your mind
as you create your magical works.

This theme supports most (soon to be all) major themeable parts of the VS Code UI, and provides custom theming for the following formats:
- Markdown
- Handlebars/HTMLBars
- JSDoc Blocks

![Screenshot 1](https://github.com/evrowe/vscode-cold-snack/raw/master/screenshot1.png)
![Screenshot 2](https://github.com/evrowe/vscode-cold-snack/raw/master/screenshot2.png)
![Screenshot 3](https://github.com/evrowe/vscode-cold-snack/raw/master/screenshot3.png)

## Contributing
Contributions are welcome! The Cold Snack theme colors are in `themes/colors.yaml`.
Available elements to style are in the
[Theme Color Reference](https://code.visualstudio.com/docs/getstarted/theme-color-reference)
[Theme Color Reference](https://code.visualstudio.com/docs/getstarted/theme-color-reference).

Individual components of the theme are broken out into separate `yaml` files inside of the `themes` directory. If you wish to add support for additional VS Code UI elements, you can do so in the `workbench.yaml` file.

### Adding Support for a new Language

If you would like to add custom theme support for a new language, create a new `yaml` file for your language and incorporate it into the `build.js` file:

```bash
# in your terminal
touch themes/someLang.yaml
```

```javascript
// build.js

// Add your language theme in the languages section:
langStyles = importTheme(langStyles, 'themes/someLang.yaml');
```

## Shout Outs

Expand Down
30 changes: 24 additions & 6 deletions build.js
Original file line number Diff line number Diff line change
@@ -1,23 +1,41 @@
const { writeFile, readFileSync } = require('fs');
const yaml = require('js-yaml');

let base = require('./themes/cold-snack-base.json');
const template = yaml.safeLoad(readFileSync('themes/template.yaml', 'utf-8')).styles;
const markdown = yaml.safeLoad(readFileSync('themes/markdown.yaml', 'utf-8')).styles;
const jsdoc = yaml.safeLoad(readFileSync('themes/jsdoc.yaml', 'utf-8')).styles;
const workbench = yaml.safeLoad(readFileSync('themes/workbench.yaml', 'utf-8'));
// Quick and easy import + concat
const importTheme = function(target, path = '') {
return target.concat(yaml.safeLoad(readFileSync(path, 'utf-8')).styles);
};
// Color Vars
const themeColors = yaml.safeLoad(readFileSync('themes/colors.yaml', 'utf-8')).themeColors;
// VS Code UI
const workbench = yaml.safeLoad(readFileSync('themes/workbench.yaml', 'utf-8'));
// Set up language styles array
let langStyles = [];

// Import base theme/colors
let base = require('./themes/cold-snack-base.json');

// Language Imports (Add new languages here!)
langStyles = importTheme(langStyles, 'themes/template.yaml');
langStyles = importTheme(langStyles, 'themes/markdown.yaml');
langStyles = importTheme(langStyles, 'themes/jsdoc.yaml');

// Merge languages into base declarations
base.tokenColors = base.tokenColors.concat(langStyles);

base.tokenColors = base.tokenColors.concat(template, markdown, jsdoc);
// Merge the base declarations with the VS Code UI styles
Object.assign(base, workbench);

// Convert to string
base = JSON.stringify(base, null, 2);

// Replace theme variable references with actual values
for (let color in themeColors) {
let colorString = new RegExp(color + '"', 'g');
base = base.replace(colorString, themeColors[color] + '"');
}

// Write out final theme JSON
writeFile('dist/Cold Snack.json', base, err => {
if (err) { console.warn(err); }
console.log('Your Cold Snack is ready.');
Expand Down
2 changes: 0 additions & 2 deletions dist/Cold Snack.json
Original file line number Diff line number Diff line change
Expand Up @@ -392,12 +392,10 @@
"editor.foreground": "#e9e9eb",
"editor.lineHighlightBackground": "#0a2c4f",
"editor.selectionBackground": "#0a2c4f",
"editorCodeLens.background": "#0a0c29",
"editorCursor.foreground": "#d6b508",
"editorRuler.foreground": "#0a2c4f",
"editorBracketMatch.border": "#d6b508",
"editorWidget.background": "#0a0c29",
"editorWidgetBorder": "#0a2c4f",
"editorError.border": "#4b0c39",
"editorWarning.border": "#cf5c00",
"editorGutter.modifiedBackground": "#ff8c31",
Expand Down
2 changes: 0 additions & 2 deletions themes/workbench.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ colors:
editor.foreground: _white
editor.lineHighlightBackground: _blue
editor.selectionBackground: _blue
editorCodeLens.background: _blue-dark
editorCursor.foreground: _yellow
editorRuler.foreground: _blue
editorBracketMatch.border: _yellow
Expand All @@ -37,7 +36,6 @@ colors:
# Editor Widgets
#
editorWidget.background: _blue-dark
editorWidgetBorder: _blue
#
# Errors
#
Expand Down

0 comments on commit 9e5dd63

Please sign in to comment.