Skip to content

Commit

Permalink
adding more mixins
Browse files Browse the repository at this point in the history
  • Loading branch information
brentmiller1973 committed Apr 3, 2020
1 parent c693cb8 commit 013f80e
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 8 deletions.
31 changes: 28 additions & 3 deletions js/framework.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,34 @@
const defaultFontSize = 16;

function calculateRem(valueInPixals){
const calculateRem = function(valueInPixals){
valueInPixals = parseFloat(valueInPixals.replace('px', ''));
return `${valueInPixals / defaultFontSize}rem`;
}
};

const lightenDarkenColor = function (col, amt) {
let usePound = false;
if (col[0] === "#") {
col = col.slice(1);
usePound = true;
}
let num = parseInt(col, 16);
let r = (num >> 16) + amt;

if (r > 255) r = 255;
else if (r < 0) r = 0;

let b = ((num >> 8) & 0x00FF) + amt;

if (b > 255) b = 255;
else if (b < 0) b = 0;

let g = (num & 0x0000FF) + amt;

if (g > 255) g = 255;
else if (g < 0) g = 0;

return (usePound ? "#" : "") + (g | (b << 8) | (r << 16)).toString(16);
};

const framework = {
variables: {
Expand Down Expand Up @@ -31,4 +56,4 @@ const framework = {
}
};

export default framework;
export {framework, calculateRem, lightenDarkenColor};
10 changes: 5 additions & 5 deletions processTemplates.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
'use strict';

const fs = require('fs');
import cssFramework from './js/framework'; //This is possible with the ESM lib
import {framework} from './js/framework'; //This is possible with the ESM lib

function readInTemplate(fileName) {
try {
Expand All @@ -12,24 +12,24 @@ function readInTemplate(fileName) {
}

//Process Variables
const variables = cssFramework.variables;
const variables = framework.variables;
let variableTmpl = readInTemplate("./templates/_variables.scss.tmpl");
for (let [key, value] of Object.entries(variables)) {
variableTmpl = variableTmpl.replace(`#(${key})`, value);
}
fs.writeFileSync('./scss/_variables.scss', variableTmpl);

//Process Breakpoints and Spacers
const spacers = cssFramework.spacers;
const spacers = framework.spacers;
let breakPointTmpl = readInTemplate("./templates/_breakpoints.scss.tmpl");
for (let [key, value] of Object.entries(spacers)) {
breakPointTmpl = breakPointTmpl.replace(`#(${key})`, value);
}
const gridBreakpoints = cssFramework.gridBreakpoints;
const gridBreakpoints = framework.gridBreakpoints;
for (let [key, value] of Object.entries(gridBreakpoints)) {
breakPointTmpl = breakPointTmpl.replace(`#(${key})`, value);
}
const gridBreakpointsMax = cssFramework.gridBreakpointsMax;
const gridBreakpointsMax = framework.gridBreakpointsMax;
for (let [key, value] of Object.entries(gridBreakpointsMax)) {
breakPointTmpl = breakPointTmpl.replace(`#(${key})`, value);
}
Expand Down

0 comments on commit 013f80e

Please sign in to comment.