Initial kitty theme template implementation
This commit is contained in:
parent
38b4239d87
commit
0e878c1278
2
cli/packages/kitty/.gitignore
vendored
Normal file
2
cli/packages/kitty/.gitignore
vendored
Normal file
@ -0,0 +1,2 @@
|
||||
node_modules
|
||||
LICENSE.md
|
2
cli/packages/kitty/.yarnrc
Normal file
2
cli/packages/kitty/.yarnrc
Normal file
@ -0,0 +1,2 @@
|
||||
version-tag-prefix "@themer/kitty-v"
|
||||
version-git-message "@themer/kitty-v%s"
|
15
cli/packages/kitty/README.md
Normal file
15
cli/packages/kitty/README.md
Normal file
@ -0,0 +1,15 @@
|
||||
# @themer/kitty
|
||||
|
||||
A [kitty](https://sw.kovidgoyal.net/kitty/) template for [themer](https://github.com/mjswensen/themer).
|
||||
|
||||
## Installation & usage
|
||||
|
||||
Install this module wherever you have `themer` installed:
|
||||
|
||||
npm install @themer/kitty
|
||||
|
||||
Then pass `@themer/kitty` as a `-t` (`--template`) arg to `themer`:
|
||||
|
||||
themer -c my-colors.js -t @themer/kitty -o gen
|
||||
|
||||
Installation instructions for the generated theme(s) will be included in `<output dir>/README.md`.
|
126
cli/packages/kitty/lib/__snapshots__/index.spec.js.snap
Normal file
126
cli/packages/kitty/lib/__snapshots__/index.spec.js.snap
Normal file
@ -0,0 +1,126 @@
|
||||
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
||||
|
||||
exports[`themer kitty theme generator should generate well-formatted themes 1`] = `
|
||||
"
|
||||
cursor #CC78FA
|
||||
cursor_text_color background
|
||||
|
||||
url_color #66BFFF
|
||||
|
||||
active_border_color #A4CC35
|
||||
inactive_border_color #474247
|
||||
bell_border_color #F28144
|
||||
|
||||
active_tab_foreground #E0DCE0
|
||||
active_tab_background #282629
|
||||
|
||||
inactive_tab_foreground #847E85
|
||||
inactive_tab_background #474247
|
||||
|
||||
foreground #E0DCE0
|
||||
background #282629
|
||||
|
||||
selection_foreground #282629
|
||||
selection_background #66BFFF
|
||||
|
||||
color0 #656066
|
||||
color8 #847E85
|
||||
|
||||
color1 #FF4050
|
||||
color9 #FF6673
|
||||
|
||||
color2 #A4CC35
|
||||
color10 #B6D65D
|
||||
|
||||
color3 #FFD24A
|
||||
color11 #FFDA6E
|
||||
|
||||
color4 #66BFFF
|
||||
color12 #85CBFF
|
||||
|
||||
color5 #F553BF
|
||||
color13 #F775CC
|
||||
|
||||
color6 #26C99E
|
||||
color14 #51D3B1
|
||||
|
||||
color7 #E0DCE0
|
||||
color15 #FFFCFF
|
||||
|
||||
mark1_foreground #282629
|
||||
mark1_background #26C99E
|
||||
|
||||
mark2_foreground #282629
|
||||
mark2_background #F553BF
|
||||
|
||||
mark3_foreground #282629
|
||||
mark3_background #FFD24A
|
||||
"
|
||||
`;
|
||||
|
||||
exports[`themer kitty theme generator should generate well-formatted themes 2`] = `
|
||||
"
|
||||
cursor #BF65F0
|
||||
cursor_text_color background
|
||||
|
||||
url_color #53A6E1
|
||||
|
||||
active_border_color #97BD2D
|
||||
inactive_border_color #E0DCE0
|
||||
bell_border_color #F37735
|
||||
|
||||
active_tab_foreground #474247
|
||||
active_tab_background #FFFCFF
|
||||
|
||||
inactive_tab_foreground #A29DA3
|
||||
inactive_tab_background #E0DCE0
|
||||
|
||||
foreground #474247
|
||||
background #FFFCFF
|
||||
|
||||
selection_foreground #FFFCFF
|
||||
selection_background #53A6E1
|
||||
|
||||
color0 #474247
|
||||
color8 #656066
|
||||
|
||||
color1 #F03E4D
|
||||
color9 #F36471
|
||||
|
||||
color2 #97BD2D
|
||||
color10 #ACCA57
|
||||
|
||||
color3 #EEBA21
|
||||
color11 #F1C74D
|
||||
|
||||
color4 #53A6E1
|
||||
color12 #75B7E7
|
||||
|
||||
color5 #EE4EB8
|
||||
color13 #F171C6
|
||||
|
||||
color6 #1FC598
|
||||
color14 #4CD0AD
|
||||
|
||||
color7 #C1BCC2
|
||||
color15 #E0DCE0
|
||||
|
||||
mark1_foreground #FFFCFF
|
||||
mark1_background #1FC598
|
||||
|
||||
mark2_foreground #FFFCFF
|
||||
mark2_background #EE4EB8
|
||||
|
||||
mark3_foreground #FFFCFF
|
||||
mark3_background #EEBA21
|
||||
"
|
||||
`;
|
||||
|
||||
exports[`themer kitty theme generator should provide installation instructions 1`] = `
|
||||
"
|
||||
In the kitty configuration file (usually \`~/.config/kitty/kitty.conf\`), \`include\` the generated theme file:
|
||||
|
||||
include themer-dark.conf
|
||||
include themer-light.conf
|
||||
"
|
||||
`;
|
81
cli/packages/kitty/lib/index.js
Normal file
81
cli/packages/kitty/lib/index.js
Normal file
@ -0,0 +1,81 @@
|
||||
const Color = require('color');
|
||||
|
||||
const MIX = 0.2;
|
||||
|
||||
const brightMix = (colors, key, isDark) =>
|
||||
Color(colors[key])
|
||||
.mix(isDark ? Color(colors.shade7) : Color(colors.shade0), MIX)
|
||||
.hex();
|
||||
|
||||
const renderTheme = (colors, isDark) => `
|
||||
cursor ${colors.accent6}
|
||||
cursor_text_color background
|
||||
|
||||
url_color ${colors.accent5}
|
||||
|
||||
active_border_color ${colors.accent3}
|
||||
inactive_border_color ${colors.shade1}
|
||||
bell_border_color ${colors.accent1}
|
||||
|
||||
active_tab_foreground ${colors.shade6}
|
||||
active_tab_background ${colors.shade0}
|
||||
|
||||
inactive_tab_foreground ${colors.shade3}
|
||||
inactive_tab_background ${colors.shade1}
|
||||
|
||||
foreground ${colors.shade6}
|
||||
background ${colors.shade0}
|
||||
|
||||
selection_foreground ${colors.shade0}
|
||||
selection_background ${colors.accent5}
|
||||
|
||||
color0 ${isDark ? colors.shade2 : colors.shade6}
|
||||
color8 ${isDark ? colors.shade3 : colors.shade5}
|
||||
|
||||
color1 ${colors.accent0}
|
||||
color9 ${brightMix(colors, 'accent0', isDark)}
|
||||
|
||||
color2 ${colors.accent3}
|
||||
color10 ${brightMix(colors, 'accent3', isDark)}
|
||||
|
||||
color3 ${colors.accent2}
|
||||
color11 ${brightMix(colors, 'accent2', isDark)}
|
||||
|
||||
color4 ${colors.accent5}
|
||||
color12 ${brightMix(colors, 'accent5', isDark)}
|
||||
|
||||
color5 ${colors.accent7}
|
||||
color13 ${brightMix(colors, 'accent7', isDark)}
|
||||
|
||||
color6 ${colors.accent4}
|
||||
color14 ${brightMix(colors, 'accent4', isDark)}
|
||||
|
||||
color7 ${isDark ? colors.shade6 : colors.shade2}
|
||||
color15 ${isDark ? colors.shade7 : colors.shade1}
|
||||
|
||||
mark1_foreground ${colors.shade0}
|
||||
mark1_background ${colors.accent4}
|
||||
|
||||
mark2_foreground ${colors.shade0}
|
||||
mark2_background ${colors.accent7}
|
||||
|
||||
mark3_foreground ${colors.shade0}
|
||||
mark3_background ${colors.accent2}
|
||||
`;
|
||||
|
||||
const render = colors => Object.entries(colors)
|
||||
.map(async ([name, colors])=> ({
|
||||
name: `themer-${name}.conf`,
|
||||
contents: Buffer.from(renderTheme(colors, name === 'dark'), 'utf8'),
|
||||
}));
|
||||
|
||||
const renderInstructions = paths => `
|
||||
In the kitty configuration file (usually \`~/.config/kitty/kitty.conf\`), \`include\` the generated theme file:
|
||||
|
||||
${paths.map(p => ` include ${p}`).join('\n')}
|
||||
`;
|
||||
|
||||
module.exports = {
|
||||
render,
|
||||
renderInstructions,
|
||||
};
|
19
cli/packages/kitty/lib/index.spec.js
Normal file
19
cli/packages/kitty/lib/index.spec.js
Normal file
@ -0,0 +1,19 @@
|
||||
const { render, renderInstructions } = require('./index');
|
||||
const { colors } = require('../../colors-default');
|
||||
|
||||
describe('themer kitty theme generator', () => {
|
||||
const promisedFiles = Promise.all(render(colors));
|
||||
|
||||
it('should generate well-formatted themes', async () => {
|
||||
const files = await promisedFiles;
|
||||
for (const file of files) {
|
||||
expect(file.contents.toString('utf8')).toMatchSnapshot();
|
||||
}
|
||||
});
|
||||
|
||||
it('should provide installation instructions', async () => {
|
||||
const files = await promisedFiles;
|
||||
const instructions = renderInstructions(files.map(({ name }) => name));
|
||||
expect(instructions).toMatchSnapshot();
|
||||
});
|
||||
});
|
35
cli/packages/kitty/package.json
Normal file
35
cli/packages/kitty/package.json
Normal file
@ -0,0 +1,35 @@
|
||||
{
|
||||
"name": "@themer/kitty",
|
||||
"version": "1.0.0",
|
||||
"description": "A kitty template for themer.",
|
||||
"main": "lib/index.js",
|
||||
"engines": {
|
||||
"node": ">=8.11.4"
|
||||
},
|
||||
"scripts": {
|
||||
"prepublishOnly": "cp ../../../LICENSE.md ./"
|
||||
},
|
||||
"author": "mjswensen",
|
||||
"license": "MIT",
|
||||
"files": [
|
||||
"/lib/index.js"
|
||||
],
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git+https://github.com/mjswensen/themer.git"
|
||||
},
|
||||
"bugs": {
|
||||
"url": "https://github.com/mjswensen/themer/issues"
|
||||
},
|
||||
"homepage": "https://github.com/mjswensen/themer/tree/master/cli/packages/kitty#readme",
|
||||
"peerDependencies": {
|
||||
"themer": "^3"
|
||||
},
|
||||
"keywords": [
|
||||
"themer",
|
||||
"kitty"
|
||||
],
|
||||
"dependencies": {
|
||||
"color": "^3.1.2"
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user