Add X resources template
This commit is contained in:
parent
a1d7ff4ccd
commit
94465982f1
2
cli/packages/xresources/.gitignore
vendored
Normal file
2
cli/packages/xresources/.gitignore
vendored
Normal file
@ -0,0 +1,2 @@
|
||||
node_modules
|
||||
LICENSE.md
|
2
cli/packages/xresources/.yarnrc
Normal file
2
cli/packages/xresources/.yarnrc
Normal file
@ -0,0 +1,2 @@
|
||||
version-tag-prefix "@themer/xresources-v"
|
||||
version-git-message "@themer/xresources-v%s"
|
15
cli/packages/xresources/README.md
Normal file
15
cli/packages/xresources/README.md
Normal file
@ -0,0 +1,15 @@
|
||||
# @themer/xresources
|
||||
|
||||
An X resources template for [themer](https://github.com/mjswensen/themer).
|
||||
|
||||
## Installation & usage
|
||||
|
||||
Install this module wherever you have `themer` installed:
|
||||
|
||||
npm install @themer/xresources
|
||||
|
||||
Then pass `@themer/xresources` as a `-t` (`--template`) arg to `themer`:
|
||||
|
||||
themer -c my-colors.js -t @themer/xresources -o gen
|
||||
|
||||
Installation instructions for the generated theme(s) will be included in `<output dir>/README.md`.
|
89
cli/packages/xresources/lib/__snapshots__/index.spec.js.snap
Normal file
89
cli/packages/xresources/lib/__snapshots__/index.spec.js.snap
Normal file
@ -0,0 +1,89 @@
|
||||
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
||||
|
||||
exports[`themer xresources theme generator renders instructions 1`] = `
|
||||
"
|
||||
Copy the contents of 'themer-dark.Xresources' or 'themer-light.Xresources' into your .xresources configuration file.
|
||||
"
|
||||
`;
|
||||
|
||||
exports[`themer xresources theme generator renders valid theme files 1`] = `
|
||||
"
|
||||
! general
|
||||
*background: #282629
|
||||
*foreground: #E0DCE0
|
||||
*cursor: #CC78FA
|
||||
|
||||
! blacks
|
||||
*color0: #656066
|
||||
*color8: #847E85
|
||||
|
||||
! reds
|
||||
*color1: #FF4050
|
||||
*color9: #FF6673
|
||||
|
||||
! greens
|
||||
*color2: #A4CC35
|
||||
*color10: #B6D65D
|
||||
|
||||
! yellows
|
||||
*color3: #FFD24A
|
||||
*color11: #FFDA6E
|
||||
|
||||
! blues
|
||||
*color4: #66BFFF
|
||||
*color12: #85CBFF
|
||||
|
||||
! magentas
|
||||
*color5: #F553BF
|
||||
*color13: #F775CC
|
||||
|
||||
! cyans
|
||||
*color6: #26C99E
|
||||
*color14: #51D3B1
|
||||
|
||||
! whites
|
||||
*color7: #E0DCE0
|
||||
*color15: #FFFCFF
|
||||
"
|
||||
`;
|
||||
|
||||
exports[`themer xresources theme generator renders valid theme files 2`] = `
|
||||
"
|
||||
! general
|
||||
*background: #FFFCFF
|
||||
*foreground: #474247
|
||||
*cursor: #BF65F0
|
||||
|
||||
! blacks
|
||||
*color0: #474247
|
||||
*color8: #656066
|
||||
|
||||
! reds
|
||||
*color1: #F03E4D
|
||||
*color9: #F36471
|
||||
|
||||
! greens
|
||||
*color2: #97BD2D
|
||||
*color10: #ACCA57
|
||||
|
||||
! yellows
|
||||
*color3: #EEBA21
|
||||
*color11: #F1C74D
|
||||
|
||||
! blues
|
||||
*color4: #53A6E1
|
||||
*color12: #75B7E7
|
||||
|
||||
! magentas
|
||||
*color5: #EE4EB8
|
||||
*color13: #F171C6
|
||||
|
||||
! cyans
|
||||
*color6: #1FC598
|
||||
*color14: #4CD0AD
|
||||
|
||||
! whites
|
||||
*color7: #C1BCC2
|
||||
*color15: #E0DCE0
|
||||
"
|
||||
`;
|
62
cli/packages/xresources/lib/index.js
Normal file
62
cli/packages/xresources/lib/index.js
Normal file
@ -0,0 +1,62 @@
|
||||
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) => `
|
||||
! general
|
||||
*background: ${colors.shade0}
|
||||
*foreground: ${colors.shade6}
|
||||
*cursor: ${colors.accent6}
|
||||
|
||||
! blacks
|
||||
*color0: ${isDark ? colors.shade2 : colors.shade6}
|
||||
*color8: ${isDark ? colors.shade3 : colors.shade5}
|
||||
|
||||
! reds
|
||||
*color1: ${colors.accent0}
|
||||
*color9: ${brightMix(colors, 'accent0', isDark)}
|
||||
|
||||
! greens
|
||||
*color2: ${colors.accent3}
|
||||
*color10: ${brightMix(colors, 'accent3', isDark)}
|
||||
|
||||
! yellows
|
||||
*color3: ${colors.accent2}
|
||||
*color11: ${brightMix(colors, 'accent2', isDark)}
|
||||
|
||||
! blues
|
||||
*color4: ${colors.accent5}
|
||||
*color12: ${brightMix(colors, 'accent5', isDark)}
|
||||
|
||||
! magentas
|
||||
*color5: ${colors.accent7}
|
||||
*color13: ${brightMix(colors, 'accent7', isDark)}
|
||||
|
||||
! cyans
|
||||
*color6: ${colors.accent4}
|
||||
*color14: ${brightMix(colors, 'accent4', isDark)}
|
||||
|
||||
! whites
|
||||
*color7: ${isDark ? colors.shade6 : colors.shade2}
|
||||
*color15: ${isDark ? colors.shade7 : colors.shade1}
|
||||
`;
|
||||
|
||||
const render = colors => Object.entries(colors)
|
||||
.map(async ([name, colors]) => ({
|
||||
name: `themer-${name}.Xresources`,
|
||||
contents: Buffer.from(renderTheme(colors, name === 'dark'), 'utf8'),
|
||||
}));
|
||||
|
||||
const renderInstructions = paths => `
|
||||
Copy the contents of ${paths.map(p => `'${p}'`).join(' or ')} into your .xresources configuration file.
|
||||
`;
|
||||
|
||||
module.exports = {
|
||||
render,
|
||||
renderInstructions,
|
||||
};
|
17
cli/packages/xresources/lib/index.spec.js
Normal file
17
cli/packages/xresources/lib/index.spec.js
Normal file
@ -0,0 +1,17 @@
|
||||
const { render, renderInstructions } = require('./index');
|
||||
const { colors } = require('../../colors-default');
|
||||
|
||||
describe('themer xresources theme generator', () => {
|
||||
const promisedFiles = Promise.all(render(colors));
|
||||
it('renders valid theme files', async () => {
|
||||
const files = await promisedFiles;
|
||||
files.forEach(file => {
|
||||
expect(file.contents.toString('utf8')).toMatchSnapshot();
|
||||
});
|
||||
});
|
||||
it('renders instructions', async () => {
|
||||
const files = await promisedFiles;
|
||||
const instructions = renderInstructions(files.map(({ name }) => name));
|
||||
expect(instructions).toMatchSnapshot();
|
||||
});
|
||||
});
|
37
cli/packages/xresources/package.json
Normal file
37
cli/packages/xresources/package.json
Normal file
@ -0,0 +1,37 @@
|
||||
{
|
||||
"name": "@themer/xresources",
|
||||
"version": "1.0.0",
|
||||
"description": "An X resources 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/xresources#readme",
|
||||
"peerDependencies": {
|
||||
"themer": "^3"
|
||||
},
|
||||
"keywords": [
|
||||
"themer",
|
||||
"xresources",
|
||||
"x",
|
||||
"xterm"
|
||||
],
|
||||
"dependencies": {
|
||||
"color": "^3.1.2"
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user