Skip to content

Commit

Permalink
Merge pull request #82 from atolye15/develop
Browse files Browse the repository at this point in the history
v4.4.2
  • Loading branch information
aydinsenturkk authored Jul 30, 2018
2 parents 8c0b165 + 8a56ea8 commit db90944
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 13 deletions.
2 changes: 1 addition & 1 deletion kss/builders/atolye15/index.twig
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@
<p class="kss-colors__hex">{{ color.hex }}</p>
<p class="kss-colors__rgb">rgb({{ color.rgb.r }}, {{ color.rgb.g }}, {{ color.rgb.b }})</p>
<p class="kss-colors__hsl">hsl({{ color.hsl.h }}, {{ color.hsl.s }}, {{ color.hsl.l }})</p>
<p class="kss-colors__description">{{ color.desc|raw }}</p>
<p class="kss-colors__description">{{ color.description|raw }}</p>
</div>
</li>
{% endkssColors %}
Expand Down
23 changes: 12 additions & 11 deletions kss/extend/kssColors.js
Original file line number Diff line number Diff line change
Expand Up @@ -87,26 +87,27 @@ module.exports = function(Twig) {
},
parse: function(token, context, chain) {
var doc = Twig.expression.parse.apply(this, [token.stack, context]);
var output = [];
var regex = /^(\S+)\s*:\s*(#[0-9A-Fa-f]{3,6})(?:\s*-\s*(.*))?$/gm;
var test;

while ((test = regex.exec(doc)) !== null) {
const output = doc.reduce((acc, curr) => {
var innerContext = Twig.ChildContext(context);
innerContext.color = {};
innerContext.color.name = test[1];
innerContext.color.hex = test[2];
if (test[3] !== undefined) {
innerContext.color.description = test[3];
innerContext.color = {
name: curr.name,
hex: curr.color,
};

if (curr.description) {
innerContext.color.description = curr.description;
}

innerContext.color.rgb = hexToRgb(innerContext.color.hex);
innerContext.color.hsl = rgbToHsl(innerContext.color.rgb);

output.push(Twig.parse.apply(this, [token.output, innerContext]));
acc.push(Twig.parse.apply(this, [token.output, innerContext]));

Twig.merge(context, innerContext, true);
}

return acc;
}, []);

return {
chain: chain,
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"version": "v4.4.1",
"version": "v4.4.2",
"devDependencies": {
"autoprefixer": "^9.0.1",
"babel-core": "^6.26.3",
Expand Down

0 comments on commit db90944

Please sign in to comment.