Skip to content

Commit e92d4ee

Browse files
committed
Refactors compiler's config file by using the build utilities
1 parent 29fc36a commit e92d4ee

File tree

4 files changed

+10
-47
lines changed

4 files changed

+10
-47
lines changed

settings/icons.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
["email.svg","subscribe.svg"]

settings/pug.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ data.navigation = [
77
{label: 'Faq', url: '#faq'},
88
{label: 'Footer', url: '#footer'}
99
];
10-
data.palettes = require('./palette');
10+
data.palettes = require('./palettes');
1111
data.typography = require('./typography');
12+
data.icons = require('./icons.json');
1213
module.exports = data;

settings/scss.js

Lines changed: 7 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -1,50 +1,11 @@
1-
var palettes = require('./palette');
1+
var palettes = require('./palettes');
22
var typography = require('./typography');
3-
var sass = require('node-sass');
4-
var sassUtils = require('node-sass-utils')(sass);
5-
6-
function hexToRgb(hex) {
7-
if (typeof hex !== 'string') {
8-
throw new TypeError('Expected a string');
9-
}
10-
hex = hex.replace(/^#/, '');
11-
if (hex.length === 3) {
12-
hex = hex[0] + hex[0] + hex[1] + hex[1] + hex[2] + hex[2];
13-
}
14-
var num = parseInt(hex, 16);
15-
return { r: num >> 16, g: num >> 8 & 255, b: num & 255};
16-
}
3+
var getPaletteFromSass = require('./../build-utilities/compiled/getPaletteFromSass');
4+
var typographyUtils = require('./../build-utilities/compiled/typography');
175

186
module.exports = {
19-
'get-palette($name)': function(name) {
20-
// Get the variable name from sass function (when it is invoked)
21-
// For that we need to take its value before
22-
var paletteName = name.getValue();
23-
// Take the palette with the given name from object palettes
24-
var palette = palettes[paletteName];
25-
// Get all key from the palette
26-
var keys = Object.keys(palette);
27-
// Create a sass Map object
28-
var map = sass.types.Map(keys.length);
29-
// Get the Sass Color class
30-
var ColorClass = sass.types.Color;
31-
// Iterate every key
32-
var convertedColor;
33-
keys.forEach(function(key, i) {
34-
// Convert the value of the given key on the object palette into rgb format
35-
convertedColor = hexToRgb(palette[key]);
36-
// Create a new Sass color instance
37-
var color = new ColorClass(convertedColor.r, convertedColor.g, convertedColor.b);
38-
// Set the key value in the sass Map
39-
map.setKey(i, sass.types.String(key));
40-
map.setValue(i, color);
41-
});
42-
return map;
43-
},
44-
'get-typography': function(name) {
45-
return sassUtils.castToSass(typography);
46-
},
47-
'get-type($name)': function(name) {
48-
return sassUtils.castToSass(typography[name.getValue()]);
49-
}
7+
'get-palette($name)': getPaletteFromSass(palettes),
8+
'get-typography': typographyUtils.getTypography(typography),
9+
'get-type($name)': typographyUtils.getType(typography)
5010
};
11+

0 commit comments

Comments
 (0)