Skip to content

Commit

Permalink
Merge pull request #25 from chaseadamsio/styleVariants
Browse files Browse the repository at this point in the history
add font style variants
  • Loading branch information
chaseadamsio authored Jul 6, 2019
2 parents ea9a33c + c3b12bd commit f5710ce
Show file tree
Hide file tree
Showing 12 changed files with 104 additions and 54 deletions.
15 changes: 15 additions & 0 deletions src/generate-pkg-json.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,21 @@ module.exports = themeInfo => ({
label: `Neon Night`,
uiTheme: `vs-dark`,
path: `./neon-night-theme.json`
},
{
label: `Neon Night - No Bold`,
uiTheme: `vs-dark`,
path: `./neon-night-no-bold-theme.json`
},
{
label: `Neon Night - No Italic`,
uiTheme: `vs-dark`,
path: `./neon-night-no-italic-theme.json`
},
{
label: `Neon Night - No Font Styles`,
uiTheme: `vs-dark`,
path: `./neon-night-no-style-theme.json`
}
]
},
Expand Down
14 changes: 7 additions & 7 deletions src/generate-theme.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,15 +39,15 @@ const generateTheme = (
},
tokenColors: [
...require(`./token-colors/base`)(palette, fontStyleEnabled),
...require(`./token-colors/clojure`)(palette),
...require(`./token-colors/css`)(palette),
...require(`./token-colors/docker`)(palette),
...require(`./token-colors/clojure`)(palette, fontStyleEnabled),
...require(`./token-colors/css`)(palette, fontStyleEnabled),
...require(`./token-colors/docker`)(palette, fontStyleEnabled),
...require(`./token-colors/go`)(palette),
...require(`./token-colors/html`)(palette),
...require(`./token-colors/javascript`)(palette),
...require(`./token-colors/json`)(palette),
...require(`./token-colors/html`)(palette, fontStyleEnabled),
...require(`./token-colors/javascript`)(palette, fontStyleEnabled),
...require(`./token-colors/json`)(palette, fontStyleEnabled),
...require(`./token-colors/makefile`)(palette),
...require(`./token-colors/markdown`)(palette),
...require(`./token-colors/markdown`)(palette, fontStyleEnabled),
...require(`./token-colors/yaml`)(palette)
]
});
Expand Down
43 changes: 32 additions & 11 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,26 +7,25 @@ const pkgJSON = require(`./generate-pkg-json`);
const palette = require(`./palette`);
const themeInfo = {
name: `neon-night`,
displayName: `Neon Night`
displayName: `Neon Night`,
variant: ``
};

const themePath = path.resolve(
__dirname,
`..`,
`themes`,
`${themeInfo.name}-theme.json`
);
const themePath = (variant /*: ?string */) => {
const name = variant ? `${themeInfo.name}-${variant}` : themeInfo.name;
return path.resolve(__dirname, `..`, `themes`, `${name}-theme.json`);
};

const pkgJSONPath = path.resolve(__dirname, `..`, `themes`, `package.json`);

const main = async function(themePath, themeInfo) {
const main = async function(themePath, themeInfo, fontStyleEnabled) {
await fs.writeFileSync(
themePath,
themePath(themeInfo.variant),
JSON.stringify(
generateTheme({
displayName: themeInfo.name,
palette,
fontStyleEnabled: true
fontStyleEnabled
}),
null,
2
Expand All @@ -41,4 +40,26 @@ const main = async function(themePath, themeInfo) {
);
};

main(themePath, themeInfo);
// default
main(themePath, themeInfo, { italic: true, bold: true });

// no font style
main(
themePath,
{ variant: `no-style`, ...themeInfo },
{ italic: false, bold: false }
);

// no bold style
main(
themePath,
{ variant: `no-bold`, ...themeInfo },
{ italic: true, bold: false }
);

// no italic style
main(
themePath,
{ variant: `no-italic`, ...themeInfo },
{ italic: false, bold: true }
);
18 changes: 9 additions & 9 deletions src/token-colors/base.js
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
// @flow

/* ::
import type {Palette} from '../types'
import type {Palette, FontStyles} from '../types'
*/

const base = (palette /*: Palette */, fontStyleEnabled /*: boolean */) => [
const base = (palette /*: Palette */, fontStyleEnabled /*: FontStyles */) => [
{
name: `Base - Comment`,
scope: [`comment`, `punctuation.definition.comment`],
settings: {
fontStyle: fontStyleEnabled ? `italic` : `normal`,
fontStyle: fontStyleEnabled.italic ? `italic` : `normal`,
foreground: palette.magenta77
}
},
Expand All @@ -25,7 +25,7 @@ const base = (palette /*: Palette */, fontStyleEnabled /*: boolean */) => [
scope: [`entity.name.function`],
settings: {
foreground: palette.white,
fontStyle: fontStyleEnabled ? `italic` : `normal`
fontStyle: fontStyleEnabled.italic ? `italic` : `normal`
}
},
{
Expand All @@ -39,7 +39,7 @@ const base = (palette /*: Palette */, fontStyleEnabled /*: boolean */) => [
name: `Base - Boolean`,
scope: `constant.language.boolean`,
settings: {
fontStyle: fontStyleEnabled ? `bold` : `normal`,
fontStyle: fontStyleEnabled.bold ? `bold` : `normal`,
foreground: palette.white
}
},
Expand All @@ -61,7 +61,7 @@ const base = (palette /*: Palette */, fontStyleEnabled /*: boolean */) => [
name: `Base - Storage`,
scope: [`storage.type`, `storage.modifier`],
settings: {
fontStyle: fontStyleEnabled ? `italic` : `normal`,
fontStyle: fontStyleEnabled.italic ? `italic` : `normal`,
foreground: palette.magenta
}
},
Expand All @@ -82,7 +82,7 @@ const base = (palette /*: Palette */, fontStyleEnabled /*: boolean */) => [
`keyword.control`
],
settings: {
fontStyle: fontStyleEnabled ? `italic` : `normal`,
fontStyle: fontStyleEnabled.italic ? `italic` : `normal`,
foreground: palette.magenta
}
},
Expand Down Expand Up @@ -111,15 +111,15 @@ const base = (palette /*: Palette */, fontStyleEnabled /*: boolean */) => [
name: `Base - Language Variable`,
scope: [`variable.language`],
settings: {
fontStyle: fontStyleEnabled ? `bold` : `normal`,
fontStyle: fontStyleEnabled.bold ? `bold` : `normal`,
foreground: palette.white
}
},
{
name: `Base - Attributes`,
scope: [`entity.other.attribute-name`],
settings: {
fontStyle: fontStyleEnabled ? `italic` : `normal`,
fontStyle: fontStyleEnabled.italic ? `italic` : `normal`,
foreground: palette.magenta
}
},
Expand Down
9 changes: 6 additions & 3 deletions src/token-colors/clojure.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
// @flow

/* ::
import type {Palette} from '../types'
import type {Palette, FontStyles} from '../types'
*/

const clojure = (palette /*: Palette */) => [
const clojure = (
palette /*: Palette */,
fontStyleEnabled /*: FontStyles */
) => [
{
name: `Clojure - Constant Keyword`,
scope: `source.clojure constant.keyword`,
Expand All @@ -24,7 +27,7 @@ const clojure = (palette /*: Palette */) => [
scope: `source.clojure meta.symbol`,
settings: {
foreground: palette.cyan,
fontStyle: `italic`
fontStyle: fontStyleEnabled.italic ? `italic` : `normal`
}
}
];
Expand Down
6 changes: 3 additions & 3 deletions src/token-colors/css.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
// @flow

/* ::
import type {Palette} from '../types'
import type {Palette, FontStyles} from '../types'
*/

const css = (palette /*: Palette */) => [
const css = (palette /*: Palette */, fontStyleEnabled /*: FontStyles */) => [
{
name: `CSS - ID`,
scope: [
Expand All @@ -17,7 +17,7 @@ const css = (palette /*: Palette */) => [
],
settings: {
foreground: palette.magenta,
fontStyle: `italic`
fontStyle: fontStyleEnabled.italic ? `italic` : `normal`
}
},
{
Expand Down
6 changes: 3 additions & 3 deletions src/token-colors/docker.js
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
// @flow

/* ::
import type {Palette} from '../types'
import type {Palette, FontStyles} from '../types'
*/

const docker = (palette /*: Palette */) => [
const docker = (palette /*: Palette */, fontStyleEnabled /*: FontStyles */) => [
{
name: `Dockerfile - Instruction`,
scope: `source.dockerfile keyword.other.special-method`,
settings: {
foreground: palette.magenta,
fontStyle: `bold`
fontStyle: fontStyleEnabled.bold ? `bold` : `normal`
}
}
];
Expand Down
6 changes: 3 additions & 3 deletions src/token-colors/html.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
// @flow

/* ::
import type {Palette} from '../types'
import type {Palette, FontStyles} from '../types'
*/

const html = (palette /*: Palette */) => [
const html = (palette /*: Palette */, fontStyleEnabled /*: FontStyles */) => [
{
name: `HTML - Tag`,
scope: `text.html entity.name.tag`,
Expand All @@ -23,7 +23,7 @@ const html = (palette /*: Palette */) => [
name: `HTML - Doctype`,
scope: `text.html meta.tag.metadata.doctype`,
settings: {
fontStyle: `bold`
fontStyle: fontStyleEnabled.bold ? `bold` : `normal`
}
}
];
Expand Down
17 changes: 10 additions & 7 deletions src/token-colors/javascript.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
// @flow

/* ::
import type {Palette} from '../types'
import type {Palette, FontStyles} from '../types'
*/

const javascript = (palette /*: Palette */) => [
const javascript = (
palette /*: Palette */,
fontStyleEnabled /*: FontStyles */
) => [
{
name: `JS - Import/Require`,
scope: `source.js keyword.control.module`,
Expand All @@ -24,7 +27,7 @@ const javascript = (palette /*: Palette */) => [
scope: `source.js string.unquoted`,
settings: {
foreground: palette.white,
fontStyle: `italic`
fontStyle: fontStyleEnabled.italic ? `italic` : `normal`
}
},
{
Expand All @@ -50,7 +53,7 @@ const javascript = (palette /*: Palette */) => [
scope: `source.js support.type.class.flowtype`,
settings: {
foreground: palette.white,
fontStyle: `bold`
fontStyle: fontStyleEnabled.bold ? `bold` : `normal`
}
},
{
Expand All @@ -62,15 +65,15 @@ const javascript = (palette /*: Palette */) => [
],
settings: {
foreground: palette.white,
fontStyle: `bold`
fontStyle: fontStyleEnabled.bold ? `bold` : `normal`
}
},
{
name: `JS - Variable Language (ie, this)`,
scope: `source.js variable.language`,
settings: {
foreground: palette.white,
fontStyle: `bold`
fontStyle: fontStyleEnabled.bold ? `bold` : `normal`
}
},
{
Expand All @@ -92,7 +95,7 @@ const javascript = (palette /*: Palette */) => [
scope: `source.js entity.other.attribute-name.jsx`,
settings: {
foreground: palette.blue,
fontStyle: `italic`
fontStyle: fontStyleEnabled.italic ? `italic` : `normal`
}
}
];
Expand Down
6 changes: 3 additions & 3 deletions src/token-colors/json.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
// @flow

/* ::
import type {Palette} from '../types'
import type {Palette, FontStyles} from '../types'
*/

const json = (palette /*: Palette */) => [
const json = (palette /*: Palette */, fontStyleEnabled /*: FontStyles */) => [
{
name: `JSON - Property Name`,
scope: [
Expand All @@ -20,7 +20,7 @@ const json = (palette /*: Palette */) => [
scope: `source.json constant.language`,
settings: {
foreground: palette.white,
fontStyle: `bold`
fontStyle: fontStyleEnabled.bold ? `bold` : `normal`
}
},
{
Expand Down
11 changes: 7 additions & 4 deletions src/token-colors/markdown.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
// @flow

/* ::
import type {Palette} from '../types'
import type {Palette, FontStyles} from '../types'
*/

const markdown = (palette /*: Palette */) => [
const markdown = (
palette /*: Palette */,
fontStyleEnabled /*: FontStyles */
) => [
{
name: `Markdown - Plain`,
scope: [`text.html.markdown`, `punctuation.definition.list_item.markdown`],
Expand All @@ -20,7 +23,7 @@ const markdown = (palette /*: Palette */) => [
],
settings: {
foreground: palette.blue,
fontStyle: `bold`
fontStyle: fontStyleEnabled.bold ? `bold` : `normal`
}
},
{
Expand Down Expand Up @@ -122,7 +125,7 @@ const markdown = (palette /*: Palette */) => [
name: `Markdown - Separator`,
scope: [`text.html markdown meta.separator`],
settings: {
fontStyle: `bold`,
fontStyle: fontStyleEnabled.bold ? `bold` : `normal`,
foreground: palette.white
}
}
Expand Down
Loading

0 comments on commit f5710ce

Please sign in to comment.