File tree Expand file tree Collapse file tree 2 files changed +37
-0
lines changed Expand file tree Collapse file tree 2 files changed +37
-0
lines changed Original file line number Diff line number Diff line change
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
+ } ;
Original file line number Diff line number Diff line change
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
+ } ) ;
You can’t perform that action at this time.
0 commit comments