Skip to content

Commit

Permalink
fix: address issue of black cursor in ipynb file for soft variant #124
Browse files Browse the repository at this point in the history
  • Loading branch information
dsifford committed Nov 16, 2020
1 parent a0e9dcd commit b44b949
Showing 1 changed file with 14 additions and 18 deletions.
32 changes: 14 additions & 18 deletions scripts/generate.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ const tinycolor = require('tinycolor2');
*/

/**
* @typedef {(yamlContent: string, yamlObj: Theme) => Theme} ThemeTransform
* @typedef {(yamlObj: Theme) => Theme} ThemeTransform
*/

const withAlphaType = new Type('!alpha', {
Expand All @@ -34,22 +34,18 @@ const schema = Schema.create([withAlphaType]);
* Soft variant transform.
* @type {ThemeTransform}
*/
const transformSoft = (yamlContent, yamlObj) => {
const brightColors = [
...yamlObj.dracula.ansi,
...yamlObj.dracula.brightOther,
];
return load(
yamlContent.replace(/#[0-9A-F]{6}/g, color => {
if (brightColors.includes(color)) {
return tinycolor(color)
.desaturate(20)
.toHexString();
}
return color;
}),
{ schema }
);
const transformSoft = theme => {
/** @type {Theme} */
const soft = JSON.parse(JSON.stringify(theme));
const brightColors = [...soft.dracula.ansi, ...soft.dracula.brightOther];
for (const key of Object.keys(soft.colors)) {
if (brightColors.includes(soft.colors[key])) {
soft.colors[key] = tinycolor(soft.colors[key])
.desaturate(20)
.toHexString();
}
}
return soft;
};

module.exports = async () => {
Expand All @@ -70,6 +66,6 @@ module.exports = async () => {

return {
base,
soft: transformSoft(yamlFile, base),
soft: transformSoft(base),
};
};

0 comments on commit b44b949

Please sign in to comment.