Skip to content

Commit

Permalink
Add linked styleguides support
Browse files Browse the repository at this point in the history
  • Loading branch information
Artem Novichkov committed Mar 20, 2020
1 parent 906975b commit 32c656f
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 34 deletions.
47 changes: 22 additions & 25 deletions package-lock.json

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

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "zepcode",
"version": "0.7.2",
"version": "0.8.0",
"description": "Generates Swift snippets from colors, fonts and layers.",
"lint-staged": {
"src/**/*.{js,json}": [
Expand Down
23 changes: 15 additions & 8 deletions src/index.js
Original file line number Diff line number Diff line change
@@ -1,20 +1,27 @@
import zepcode from './zepcode';

function container(context) {
return context.styleguide === undefined
? context.project
: context.styleguide;
function contextColors(context) {
let allColors = [];
if (context.styleguide === undefined) {
allColors = allColors.concat(context.project.colors);
if (context.project.linkedStyleguide !== undefined) {
allColors = allColors.concat(context.project.linkedStyleguide.colors);
}
} else {
allColors = allColors.concat(context.styleguide.colors);
}
return allColors;
}

// New API
function colors(context) {
const containerColors = container(context).colors;
return zepcode(context).generateColorExtension(containerColors, false);
const projectColors = contextColors(context);
return zepcode(context).generateColorExtension(projectColors, false);
}

function exportColors(context) {
const containerColors = container(context).colors;
return zepcode(context).generateColorExtension(containerColors, true);
const projectColors = contextColors(context);
return zepcode(context).generateColorExtension(projectColors, true);
}

function layer(context, layerParams) {
Expand Down

0 comments on commit 32c656f

Please sign in to comment.