├── .gitignore
├── .npmignore
├── .travis.yml
├── index.spec.js
├── README.md
├── package.json
├── LICENSE.md
├── __snapshots__
└── index.spec.js.snap
└── index.js
/.gitignore:
--------------------------------------------------------------------------------
1 | node_modules
2 |
--------------------------------------------------------------------------------
/.npmignore:
--------------------------------------------------------------------------------
1 | __snapshots__
2 | index.spec.js
3 |
--------------------------------------------------------------------------------
/.travis.yml:
--------------------------------------------------------------------------------
1 | language: node_js
2 | node_js:
3 | - "lts/*"
4 |
5 | script: npm test -- -u
6 |
--------------------------------------------------------------------------------
/index.spec.js:
--------------------------------------------------------------------------------
1 | const {render} = require('./index');
2 | const {colors} = require('themer-colors-default');
3 |
4 | describe('themer Android theme template', () => {
5 | it('should render properly', done => {
6 | Promise.all(render(colors)).then(files => {
7 | expect(files.length).toBe(2);
8 | files.forEach(file => {
9 | expect(file.contents.toString('utf8')).toMatchSnapshot();
10 | });
11 | done();
12 | });
13 | });
14 | });
15 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # themer-android [](https://travis-ci.org/pddstudio/themer-android)
2 |
3 | An *Android* theme generator for [themer](https://github.com/mjswensen/themer).
4 |
5 | ## Installation & usage
6 |
7 | Install this module wherever you have `themer` installed:
8 |
9 | npm install themer-android
10 |
11 | Then pass `themer-android` as a `-t` (`--template`) arg to `themer`:
12 |
13 | themer -c my-colors.js -t themer-android -o gen
14 |
15 | `themer-android` will generate a `themer-android-dark.xml` / `themer-android-light.xml` (or both) in your output directory. Simply copy this file to your resources folder in Android Studio.
16 |
17 | ## License
18 |
19 | > (c) 2017 Patrick Jung MIT License
20 |
--------------------------------------------------------------------------------
/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "themer-android",
3 | "version": "1.0.0",
4 | "description": "An Android resoruce colors theme generator for themer.",
5 | "main": "index.js",
6 | "engines": {
7 | "node": ">=6.11"
8 | },
9 | "scripts": {
10 | "test": "jest"
11 | },
12 | "author": "pddstudio",
13 | "license": "MIT",
14 | "devDependencies": {
15 | "jest": "^20.0.4",
16 | "themer-colors-default": "^1.0.3"
17 | },
18 | "dependencies": {
19 | "xml": "1.0.1"
20 | },
21 | "repository": {
22 | "type": "git",
23 | "url": "git+https://github.com/pddstudio/themer-android.git"
24 | },
25 | "keywords": [
26 | "themer",
27 | "android",
28 | "theme"
29 | ],
30 | "bugs": {
31 | "url": "https://github.com/pddstudio/themer-android/issues"
32 | },
33 | "homepage": "https://github.com/pddstudio/themer-android#readme"
34 | }
35 |
--------------------------------------------------------------------------------
/LICENSE.md:
--------------------------------------------------------------------------------
1 | MIT License
2 |
3 | Copyright (c) 2017 Patrick Jung
4 | Copyright (c) 2017 Matt Swensen
5 |
6 | Permission is hereby granted, free of charge, to any person obtaining a copy
7 | of this software and associated documentation files (the "Software"), to deal
8 | in the Software without restriction, including without limitation the rights
9 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 | copies of the Software, and to permit persons to whom the Software is
11 | furnished to do so, subject to the following conditions:
12 |
13 | The above copyright notice and this permission notice shall be included in all
14 | copies or substantial portions of the Software.
15 |
16 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22 | SOFTWARE.
23 |
--------------------------------------------------------------------------------
/__snapshots__/index.spec.js.snap:
--------------------------------------------------------------------------------
1 | // Jest Snapshot v1, https://goo.gl/fbAQLP
2 |
3 | exports[`themer Alfred.app theme template should render properly 1`] = `
4 | "
5 | #282629
6 | #474247
7 | #656066
8 | #847E85
9 | #A29DA3
10 | #C1BCC2
11 | #E0DCE0
12 | #FFFCFF
13 | #FF4050
14 | #F28144
15 | #FFD24A
16 | #A4CC35
17 | #26C99E
18 | #66BFFF
19 | #CC78FA
20 | #F553BF
21 | "
22 | `;
23 |
24 | exports[`themer Alfred.app theme template should render properly 2`] = `
25 | "
26 | #FFFCFF
27 | #E0DCE0
28 | #C1BCC2
29 | #A29DA3
30 | #847E85
31 | #656066
32 | #474247
33 | #282629
34 | #F03E4D
35 | #F37735
36 | #EEBA21
37 | #97BD2D
38 | #1FC598
39 | #53A6E1
40 | #BF65F0
41 | #EE4EB8
42 | "
43 | `;
44 |
--------------------------------------------------------------------------------
/index.js:
--------------------------------------------------------------------------------
1 | var xml = require('xml');
2 |
3 | const render = (colors, options) => {
4 | const colorSets = [
5 | { name: 'dark', colors: colors.dark },
6 | { name: 'light', colors: colors.light },
7 | ].filter(colorSet => !!colorSet.colors);
8 |
9 | return colorSets.map(colorSet => {
10 | const {
11 | shade0,
12 | shade1,
13 | shade2,
14 | shade3,
15 | shade4,
16 | shade5,
17 | shade6,
18 | shade7,
19 | accent0,
20 | accent1,
21 | accent2,
22 | accent3,
23 | accent4,
24 | accent5,
25 | accent6,
26 | accent7,
27 | } = colorSet.colors;
28 | var data = [ { resources: [
29 | { color: [ { _attr: { name: `color_shade0_${colorSet.name}`} }, shade0 ] },
30 | { color: [ { _attr: { name: `color_shade1_${colorSet.name}`} }, shade1 ] },
31 | { color: [ { _attr: { name: `color_shade2_${colorSet.name}`} }, shade2 ] },
32 | { color: [ { _attr: { name: `color_shade3_${colorSet.name}`} }, shade3 ] },
33 | { color: [ { _attr: { name: `color_shade4_${colorSet.name}`} }, shade4 ] },
34 | { color: [ { _attr: { name: `color_shade5_${colorSet.name}`} }, shade5 ] },
35 | { color: [ { _attr: { name: `color_shade6_${colorSet.name}`} }, shade6 ] },
36 | { color: [ { _attr: { name: `color_shade7_${colorSet.name}`} }, shade7 ] },
37 |
38 | { color: [ { _attr: { name: `color_accent0_${colorSet.name}`} }, accent0 ] },
39 | { color: [ { _attr: { name: `color_accent1_${colorSet.name}`} }, accent1 ] },
40 | { color: [ { _attr: { name: `color_accent2_${colorSet.name}`} }, accent2 ] },
41 | { color: [ { _attr: { name: `color_accent3_${colorSet.name}`} }, accent3 ] },
42 | { color: [ { _attr: { name: `color_accent4_${colorSet.name}`} }, accent4 ] },
43 | { color: [ { _attr: { name: `color_accent5_${colorSet.name}`} }, accent5 ] },
44 | { color: [ { _attr: { name: `color_accent6_${colorSet.name}`} }, accent6 ] },
45 | { color: [ { _attr: { name: `color_accent7_${colorSet.name}`} }, accent7 ] },
46 | ]}];
47 | return Promise.resolve({
48 | name: `themer-android-${colorSet.name}.xml`,
49 | contents: Buffer.from(xml(data, { declaration: true, indent: true })),
50 | });
51 | });
52 | };
53 |
54 | module.exports = {render};
--------------------------------------------------------------------------------