Skip to content

Commit 9699bfc

Browse files
committed
Inital add of lg functions with column logic
1 parent 98f1993 commit 9699bfc

File tree

2 files changed

+37
-0
lines changed

2 files changed

+37
-0
lines changed

lib/_lg-logic.js

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
module.exports = {
2+
3+
columnLogic: function(columnFraction, gutter, rounder) {
4+
let widthValue = '';
5+
let gutterLogic = '';
6+
7+
if (gutter !== 0) {
8+
gutterLogic = ` - (${gutter} - ${gutter} * ${columnFraction})`;
9+
}
10+
11+
widthValue = `calc(${rounder}% * ${columnFraction}${gutterLogic})`;
12+
return widthValue
13+
}
14+
15+
};

test/lg-logic.js

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
'use strict'
2+
3+
const expect = require('chai').expect;
4+
const lgLogic = require('../lib/_lg-logic.js');
5+
6+
7+
describe('columnLogic works as it should', () => {
8+
it('gutter and rounder ✅', () => {
9+
const foo = lgLogic.columnLogic('1/3', 30, 100);
10+
11+
const expectedResult = `calc(100% * 1/3 - (30 - 30 * 1/3))`;
12+
13+
expect(foo).to.equal(expectedResult);
14+
});
15+
it('no gutter ✅', () => {
16+
const foo = lgLogic.columnLogic('1/3', 0, 99.9);
17+
18+
const expectedResult = `calc(99.9% * 1/3)`;
19+
20+
expect(foo).to.equal(expectedResult);
21+
});
22+
});

0 commit comments

Comments
 (0)