Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Revert dark changes #123

Merged
merged 3 commits into from
Jan 23, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
123 changes: 55 additions & 68 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 3 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,7 @@
"theme",
"github",
"light",
"dark",
"dimmed"
"dark"
],
"contributes": {
"themes": [
Expand All @@ -46,8 +45,8 @@
]
},
"devDependencies": {
"@primer/primitives": "0.0.0-2020111574337",
"chroma-js": "^2.1.0",
"@primer/primitives": "^2.0.1",
"color": "^3.1.2",
"nodemon": "^2.0.3"
},
"scripts": {
Expand Down
17 changes: 0 additions & 17 deletions src/colors.js

This file was deleted.

10 changes: 2 additions & 8 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,24 +2,18 @@ const fs = require("fs").promises;
const getTheme = require("./theme");

const lightTheme = getTheme({
theme: "light",
style: "light",
name: "GitHub Light",
});

const darkTheme = getTheme({
theme: "dark",
style: "dark",
name: "GitHub Dark",
});

// const dimmedTheme = getTheme({
// theme: "dimmed",
// name: "GitHub Dimmed",
// });

fs.mkdir("./themes", { recursive: true })
.then(() => Promise.all([
fs.writeFile("./themes/light.json", JSON.stringify(lightTheme, null, 2)),
fs.writeFile("./themes/dark.json", JSON.stringify(darkTheme, null, 2)),
// fs.writeFile("./themes/dimmed.json", JSON.stringify(dimmedTheme, null, 2)),
]))
.catch(() => process.exit(1))
24 changes: 24 additions & 0 deletions src/primer.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
const { colors } = require("@primer/primitives");

function getColors(style) {
if (style === "dark") {
/* The array of light to dark colors are reversed to auto-generate dark theme */
const darkColors = {};
Object.entries(colors).forEach(([name, val]) => {
if (name === "black") {
darkColors.white = val;
} else if (name === "white") {
darkColors.black = val;
} else {
darkColors[name] = [...val].reverse();
}
});
return darkColors;
} else {
return colors;
}
}

module.exports = {
getColors,
};
22 changes: 22 additions & 0 deletions src/process.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
const Color = require("color");

/*
* Generate color variant by inverting
* luminance in the HSL representation
*/
function getVariant(hex, style) {
if (style === "dark") {
const c = Color(hex);
return c
.hsl()
.lightness(100 - c.lightness())
.hex()
.toLowerCase();
} else {
return hex;
}
}

module.exports = {
getVariant,
};
Loading