Implement Wox theme generator
This commit is contained in:
parent
f88c4b49b8
commit
a7ee60bf9f
2
cli/packages/wox/.gitignore
vendored
Normal file
2
cli/packages/wox/.gitignore
vendored
Normal file
@ -0,0 +1,2 @@
|
||||
node_modules
|
||||
LICENSE.md
|
2
cli/packages/wox/.yarnrc
Normal file
2
cli/packages/wox/.yarnrc
Normal file
@ -0,0 +1,2 @@
|
||||
version-tag-prefix "@themer/wox-v"
|
||||
version-git-message "@themer/wox-v%s"
|
15
cli/packages/wox/README.md
Normal file
15
cli/packages/wox/README.md
Normal file
@ -0,0 +1,15 @@
|
||||
# @themer/wox
|
||||
|
||||
A [Wox](http://www.wox.one/) template for [themer](https://github.com/mjswensen/themer).
|
||||
|
||||
## Installation & usage
|
||||
|
||||
Install this module wherever you have `themer` installed:
|
||||
|
||||
npm install @themer/wox
|
||||
|
||||
Then pass `@themer/wox` as a `-t` (`--template`) arg to `themer`:
|
||||
|
||||
themer -c my-colors.js -t @themer/wox -o gen
|
||||
|
||||
Installation instructions for the generated theme(s) will be included in `<output dir>/README.md`.
|
75
cli/packages/wox/lib/__snapshots__/index.spec.js.snap
Normal file
75
cli/packages/wox/lib/__snapshots__/index.spec.js.snap
Normal file
@ -0,0 +1,75 @@
|
||||
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
||||
|
||||
exports[`themer wox theme generator should provide installation instructions 1`] = `
|
||||
"
|
||||
1. Copy 'Themer Dark.xaml' and 'Themer Light.xaml' into Wox's theme directory (for example, \`C:\\\\Users\\\\<username>\\\\AppData\\\\Local\\\\Wox\\\\app-<version>\\\\Themes\`).
|
||||
2. Open Wox and type \\"settings\\" to launch Wox settings.
|
||||
3. On the \\"Themes\\" tab, select the generated theme from the list.
|
||||
"
|
||||
`;
|
||||
|
||||
exports[`themer wox theme generator should render properly 1`] = `
|
||||
"<?xml version=\\"1.0\\" encoding=\\"UTF-8\\"?>
|
||||
<ResourceDictionary xmlns=\\"http://schemas.microsoft.com/winfx/2006/xaml/presentation\\" xmlns:x=\\"http://schemas.microsoft.com/winfx/2006/xaml\\">
|
||||
<ResourceDictionary.MergedDictionaries>
|
||||
<ResourceDictionary Source=\\"Base.xaml\\" />
|
||||
</ResourceDictionary.MergedDictionaries>
|
||||
<Style x:Key=\\"QueryBoxStyle\\" BasedOn=\\"{StaticResource BaseQueryBoxStyle}\\" TargetType=\\"{x:Type TextBox}\\">
|
||||
<Setter Property=\\"Background\\" Value=\\"#474247\\" />
|
||||
<Setter Property=\\"Foreground\\" Value=\\"#FFFCFF\\" />
|
||||
</Style>
|
||||
<Style x:Key=\\"WindowBorderStyle\\" BasedOn=\\"{StaticResource BaseWindowBorderStyle}\\" TargetType=\\"{x:Type Border}\\">
|
||||
<Setter Property=\\"Background\\" Value=\\"#282629\\" />
|
||||
</Style>
|
||||
<Style x:Key=\\"WindowStyle\\" TargetType=\\"{x:Type Window}\\" BasedOn=\\"{StaticResource BaseWindowStyle}\\" />
|
||||
<Style x:Key=\\"PendingLineStyle\\" BasedOn=\\"{StaticResource BasePendingLineStyle}\\" TargetType=\\"{x:Type Line}\\" />
|
||||
<Style x:Key=\\"ItemTitleStyle\\" BasedOn=\\"{StaticResource BaseItemTitleStyle}\\" TargetType=\\"{x:Type TextBlock}\\">
|
||||
<Setter Property=\\"Foreground\\" Value=\\"#FFFCFF\\" />
|
||||
</Style>
|
||||
<Style x:Key=\\"ItemSubTitleStyle\\" BasedOn=\\"{StaticResource BaseItemSubTitleStyle}\\" TargetType=\\"{x:Type TextBlock}\\">
|
||||
<Setter Property=\\"Foreground\\" Value=\\"#A29DA3\\" />
|
||||
</Style>
|
||||
<Style x:Key=\\"ItemTitleSelectedStyle\\" BasedOn=\\"{StaticResource BaseItemTitleSelectedStyle}\\" TargetType=\\"{x:Type TextBlock}\\">
|
||||
<Setter Property=\\"Foreground\\" Value=\\"#282629\\" />
|
||||
</Style>
|
||||
<Style x:Key=\\"ItemSubTitleSelectedStyle\\" BasedOn=\\"{StaticResource BaseItemSubTitleSelectedStyle}\\" TargetType=\\"{x:Type TextBlock}\\">
|
||||
<Setter Property=\\"Foreground\\" Value=\\"#474247\\" />
|
||||
</Style>
|
||||
<SolidColorBrush x:Key=\\"ItemSelectedBackgroundColor\\">#26C99E</SolidColorBrush>
|
||||
<Style x:Key=\\"ThumbStyle\\" BasedOn=\\"{StaticResource BaseThumbStyle}\\" TargetType=\\"{x:Type Thumb}\\" />
|
||||
<Style x:Key=\\"ScrollBarStyle\\" BasedOn=\\"{StaticResource BaseScrollBarStyle}\\" TargetType=\\"{x:Type ScrollBar}\\" />
|
||||
</ResourceDictionary>"
|
||||
`;
|
||||
|
||||
exports[`themer wox theme generator should render properly 2`] = `
|
||||
"<?xml version=\\"1.0\\" encoding=\\"UTF-8\\"?>
|
||||
<ResourceDictionary xmlns=\\"http://schemas.microsoft.com/winfx/2006/xaml/presentation\\" xmlns:x=\\"http://schemas.microsoft.com/winfx/2006/xaml\\">
|
||||
<ResourceDictionary.MergedDictionaries>
|
||||
<ResourceDictionary Source=\\"Base.xaml\\" />
|
||||
</ResourceDictionary.MergedDictionaries>
|
||||
<Style x:Key=\\"QueryBoxStyle\\" BasedOn=\\"{StaticResource BaseQueryBoxStyle}\\" TargetType=\\"{x:Type TextBox}\\">
|
||||
<Setter Property=\\"Background\\" Value=\\"#E0DCE0\\" />
|
||||
<Setter Property=\\"Foreground\\" Value=\\"#282629\\" />
|
||||
</Style>
|
||||
<Style x:Key=\\"WindowBorderStyle\\" BasedOn=\\"{StaticResource BaseWindowBorderStyle}\\" TargetType=\\"{x:Type Border}\\">
|
||||
<Setter Property=\\"Background\\" Value=\\"#FFFCFF\\" />
|
||||
</Style>
|
||||
<Style x:Key=\\"WindowStyle\\" TargetType=\\"{x:Type Window}\\" BasedOn=\\"{StaticResource BaseWindowStyle}\\" />
|
||||
<Style x:Key=\\"PendingLineStyle\\" BasedOn=\\"{StaticResource BasePendingLineStyle}\\" TargetType=\\"{x:Type Line}\\" />
|
||||
<Style x:Key=\\"ItemTitleStyle\\" BasedOn=\\"{StaticResource BaseItemTitleStyle}\\" TargetType=\\"{x:Type TextBlock}\\">
|
||||
<Setter Property=\\"Foreground\\" Value=\\"#282629\\" />
|
||||
</Style>
|
||||
<Style x:Key=\\"ItemSubTitleStyle\\" BasedOn=\\"{StaticResource BaseItemSubTitleStyle}\\" TargetType=\\"{x:Type TextBlock}\\">
|
||||
<Setter Property=\\"Foreground\\" Value=\\"#847E85\\" />
|
||||
</Style>
|
||||
<Style x:Key=\\"ItemTitleSelectedStyle\\" BasedOn=\\"{StaticResource BaseItemTitleSelectedStyle}\\" TargetType=\\"{x:Type TextBlock}\\">
|
||||
<Setter Property=\\"Foreground\\" Value=\\"#FFFCFF\\" />
|
||||
</Style>
|
||||
<Style x:Key=\\"ItemSubTitleSelectedStyle\\" BasedOn=\\"{StaticResource BaseItemSubTitleSelectedStyle}\\" TargetType=\\"{x:Type TextBlock}\\">
|
||||
<Setter Property=\\"Foreground\\" Value=\\"#E0DCE0\\" />
|
||||
</Style>
|
||||
<SolidColorBrush x:Key=\\"ItemSelectedBackgroundColor\\">#1FC598</SolidColorBrush>
|
||||
<Style x:Key=\\"ThumbStyle\\" BasedOn=\\"{StaticResource BaseThumbStyle}\\" TargetType=\\"{x:Type Thumb}\\" />
|
||||
<Style x:Key=\\"ScrollBarStyle\\" BasedOn=\\"{StaticResource BaseScrollBarStyle}\\" TargetType=\\"{x:Type ScrollBar}\\" />
|
||||
</ResourceDictionary>"
|
||||
`;
|
48
cli/packages/wox/lib/index.js
Normal file
48
cli/packages/wox/lib/index.js
Normal file
@ -0,0 +1,48 @@
|
||||
const renderTheme = colors => `
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
|
||||
<ResourceDictionary.MergedDictionaries>
|
||||
<ResourceDictionary Source="Base.xaml" />
|
||||
</ResourceDictionary.MergedDictionaries>
|
||||
<Style x:Key="QueryBoxStyle" BasedOn="{StaticResource BaseQueryBoxStyle}" TargetType="{x:Type TextBox}">
|
||||
<Setter Property="Background" Value="${colors.shade1}" />
|
||||
<Setter Property="Foreground" Value="${colors.shade7}" />
|
||||
</Style>
|
||||
<Style x:Key="WindowBorderStyle" BasedOn="{StaticResource BaseWindowBorderStyle}" TargetType="{x:Type Border}">
|
||||
<Setter Property="Background" Value="${colors.shade0}" />
|
||||
</Style>
|
||||
<Style x:Key="WindowStyle" TargetType="{x:Type Window}" BasedOn="{StaticResource BaseWindowStyle}" />
|
||||
<Style x:Key="PendingLineStyle" BasedOn="{StaticResource BasePendingLineStyle}" TargetType="{x:Type Line}" />
|
||||
<Style x:Key="ItemTitleStyle" BasedOn="{StaticResource BaseItemTitleStyle}" TargetType="{x:Type TextBlock}">
|
||||
<Setter Property="Foreground" Value="${colors.shade7}" />
|
||||
</Style>
|
||||
<Style x:Key="ItemSubTitleStyle" BasedOn="{StaticResource BaseItemSubTitleStyle}" TargetType="{x:Type TextBlock}">
|
||||
<Setter Property="Foreground" Value="${colors.shade4}" />
|
||||
</Style>
|
||||
<Style x:Key="ItemTitleSelectedStyle" BasedOn="{StaticResource BaseItemTitleSelectedStyle}" TargetType="{x:Type TextBlock}">
|
||||
<Setter Property="Foreground" Value="${colors.shade0}" />
|
||||
</Style>
|
||||
<Style x:Key="ItemSubTitleSelectedStyle" BasedOn="{StaticResource BaseItemSubTitleSelectedStyle}" TargetType="{x:Type TextBlock}">
|
||||
<Setter Property="Foreground" Value="${colors.shade1}" />
|
||||
</Style>
|
||||
<SolidColorBrush x:Key="ItemSelectedBackgroundColor">${colors.accent4}</SolidColorBrush>
|
||||
<Style x:Key="ThumbStyle" BasedOn="{StaticResource BaseThumbStyle}" TargetType="{x:Type Thumb}" />
|
||||
<Style x:Key="ScrollBarStyle" BasedOn="{StaticResource BaseScrollBarStyle}" TargetType="{x:Type ScrollBar}" />
|
||||
</ResourceDictionary>
|
||||
`.trim();
|
||||
|
||||
const render = colors => Object.entries(colors).map(async ([[first, ...tail], colors]) => ({
|
||||
name: `Themer ${[first.toUpperCase(), ...tail].join('')}.xaml`,
|
||||
contents: Buffer.from(renderTheme(colors), 'utf8'),
|
||||
}));
|
||||
|
||||
const renderInstructions = paths => `
|
||||
1. Copy ${paths.map(p => `'${p}'`).join(' and ')} into Wox's theme directory (for example, \`C:\\Users\\<username>\\AppData\\Local\\Wox\\app-<version>\\Themes\`).
|
||||
2. Open Wox and type "settings" to launch Wox settings.
|
||||
3. On the "Themes" tab, select the generated theme from the list.
|
||||
`;
|
||||
|
||||
module.exports = {
|
||||
render,
|
||||
renderInstructions,
|
||||
};
|
17
cli/packages/wox/lib/index.spec.js
Normal file
17
cli/packages/wox/lib/index.spec.js
Normal file
@ -0,0 +1,17 @@
|
||||
const { render, renderInstructions } = require('./index');
|
||||
const { colors } = require('../../colors-default');
|
||||
|
||||
describe('themer wox theme generator', () => {
|
||||
it('should render properly', async () => {
|
||||
const files = await Promise.all(render(colors))
|
||||
expect(files.length).toBe(2);
|
||||
files.forEach(file => {
|
||||
expect(file.contents.toString('utf8')).toMatchSnapshot();
|
||||
});
|
||||
});
|
||||
it('should provide installation instructions', async () => {
|
||||
const files = await Promise.all(render(colors));
|
||||
const instructions = renderInstructions(files.map(({ name }) => name));
|
||||
expect(instructions).toMatchSnapshot();
|
||||
});
|
||||
});
|
32
cli/packages/wox/package.json
Normal file
32
cli/packages/wox/package.json
Normal file
@ -0,0 +1,32 @@
|
||||
{
|
||||
"name": "@themer/wox",
|
||||
"version": "1.0.0",
|
||||
"description": "A Wox 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/wox#readme",
|
||||
"peerDependencies": {
|
||||
"themer": "^3"
|
||||
},
|
||||
"keywords": [
|
||||
"themer",
|
||||
"wox"
|
||||
]
|
||||
}
|
Loading…
Reference in New Issue
Block a user