Skip to content

Commit

Permalink
Merge pull request #438 from peterramsing/cleanup
Browse files Browse the repository at this point in the history
Cleanup
  • Loading branch information
peterramsing authored Feb 9, 2019
2 parents 605b7cc + bc47374 commit 22e4bba
Show file tree
Hide file tree
Showing 22 changed files with 149 additions and 128 deletions.
3 changes: 2 additions & 1 deletion .prettierrc
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
{
"singleQuote": true
"singleQuote": true,
"trailingComma": "es5"
}
8 changes: 5 additions & 3 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,11 @@ sudo: false
language: node_js

node_js:
- "6"
- "8"
- "10"
- 6
- 8
- 10
- 11
- node

script:
- npm test
Expand Down
2 changes: 1 addition & 1 deletion lib/_lg-logic.js → lib/core/lg-logic.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,5 +37,5 @@ module.exports = {
});

return propertyValue;
}
},
};
4 changes: 2 additions & 2 deletions lib/new-block.js → lib/core/lg-new-block.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ module.exports = function newBlock(decl, selector, props, values) {
completeSelector = appendToSelectors(decl.parent.selector, selector);

block = decl.parent.cloneAfter({
selector: completeSelector
selector: completeSelector,
});

block.walkDecls(function removeDeclarationFunction(declaration) {
Expand All @@ -25,7 +25,7 @@ module.exports = function newBlock(decl, selector, props, values) {
props.forEach(function addRulesFunction(prop, i) {
var rule = decl.clone({
prop: prop,
value: values[i].toString()
value: values[i].toString(),
});

block.append(rule);
Expand Down
2 changes: 1 addition & 1 deletion lib/_lg-utilities.js → lib/core/lg-utilities.js
Original file line number Diff line number Diff line change
Expand Up @@ -107,5 +107,5 @@ module.exports = {
hToD,
safeRgbToRgb,
safeHexToRgb,
glueFractionMembers
glueFractionMembers,
};
10 changes: 5 additions & 5 deletions lib/lost-align.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
var newBlock = require('./new-block.js');
var newBlock = require('./core/lg-new-block.js');

module.exports = function lostAlign(css, settings) {
css.walkDecls('lost-align', function alignDirectionFunction(decl) {
Expand All @@ -17,7 +17,7 @@ module.exports = function lostAlign(css, settings) {
if (alignDirection === 'reset') {
decl.cloneBefore({
prop: 'position',
value: 'static'
value: 'static',
});
newBlock(
decl,
Expand All @@ -28,7 +28,7 @@ module.exports = function lostAlign(css, settings) {
} else {
decl.cloneBefore({
prop: 'position',
value: 'relative'
value: 'relative',
});
if (alignDirection === 'horizontal') {
newBlock(
Expand Down Expand Up @@ -131,7 +131,7 @@ module.exports = function lostAlign(css, settings) {
} else if (alignDirection === 'reset') {
decl.cloneBefore({
prop: 'display',
value: 'initial'
value: 'initial',
});
newBlock(
decl,
Expand All @@ -142,7 +142,7 @@ module.exports = function lostAlign(css, settings) {
} else {
decl.cloneBefore({
prop: 'display',
value: 'flex'
value: 'flex',
});
if (alignDirection === 'horizontal') {
newBlock(
Expand Down
20 changes: 10 additions & 10 deletions lib/lost-center.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
var newBlock = require('./new-block.js');
var newBlock = require('./core/lg-new-block.js');

var lgLogic = require('./_lg-logic');
var lgUtils = require('./_lg-utilities');
var lgLogic = require('./core/lg-logic');
var lgUtils = require('./core/lg-utilities');

module.exports = function lostCenterDecl(css, settings, result) {
css.walkDecls('lost-center', function lostCenterFunction(decl) {
Expand Down Expand Up @@ -88,39 +88,39 @@ module.exports = function lostCenterDecl(css, settings, result) {
} else {
decl.cloneBefore({
prop: 'display',
value: 'flex'
value: 'flex',
});

decl.cloneBefore({
prop: 'flex-flow',
value: 'row wrap'
value: 'row wrap',
});
}

decl.cloneBefore({
prop: 'max-width',
value: lostCenterMaxWidth
value: lostCenterMaxWidth,
});

decl.cloneBefore({
prop: 'margin-left',
value: 'auto'
value: 'auto',
});

decl.cloneBefore({
prop: 'margin-right',
value: 'auto'
value: 'auto',
});

if (lostCenterPadding !== undefined) {
decl.cloneBefore({
prop: 'padding-left',
value: lostCenterPadding
value: lostCenterPadding,
});

decl.cloneBefore({
prop: 'padding-right',
value: lostCenterPadding
value: lostCenterPadding,
});
}

Expand Down
18 changes: 9 additions & 9 deletions lib/lost-column.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
var newBlock = require('./new-block.js');
var newBlock = require('./core/lg-new-block.js');

var lgLogic = require('./_lg-logic');
var lgUtils = require('./_lg-utilities');
var lgLogic = require('./core/lg-logic');
var lgUtils = require('./core/lg-utilities');

module.exports = function lostColumnDecl(css, settings, result) {
css.walkDecls('lost-column', function lostColumnFunction(decl) {
Expand Down Expand Up @@ -112,11 +112,11 @@ module.exports = function lostColumnDecl(css, settings, result) {
if (lostColumnFlexbox === 'flex') {
decl.cloneBefore({
prop: 'flex-grow',
value: '0'
value: '0',
});
decl.cloneBefore({
prop: 'flex-shrink',
value: '0'
value: '0',
});

if (lostColumnCycle !== 0) {
Expand Down Expand Up @@ -144,7 +144,7 @@ module.exports = function lostColumnDecl(css, settings, result) {
lostColumnGutter,
lostColumnRounder,
unit
)
),
});

// IE 10-11 don't take into account box-sizing when calculating flex-basis, but
Expand All @@ -157,7 +157,7 @@ module.exports = function lostColumnDecl(css, settings, result) {
lostColumnGutter,
lostColumnRounder,
unit
)
),
});

if (gridDirection === 'rtl') {
Expand Down Expand Up @@ -266,12 +266,12 @@ module.exports = function lostColumnDecl(css, settings, result) {
lostColumnGutter,
lostColumnRounder,
unit
)
),
});
} else {
decl.cloneBefore({
prop: 'width',
value: 'auto'
value: 'auto',
});

if (gridDirection === 'rtl') {
Expand Down
6 changes: 3 additions & 3 deletions lib/lost-flex-container.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,18 @@ module.exports = function lostFlexContainerDecl(css) {
) {
decl.cloneBefore({
prop: 'display',
value: 'flex'
value: 'flex',
});

if (decl.value === 'column') {
decl.cloneBefore({
prop: 'flex-flow',
value: 'column nowrap'
value: 'column nowrap',
});
} else {
decl.cloneBefore({
prop: 'flex-flow',
value: 'row wrap'
value: 'row wrap',
});
}

Expand Down
File renamed without changes.
12 changes: 6 additions & 6 deletions lib/lost-masonry-column.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
var lgUtils = require('./_lg-utilities');
var lgUtils = require('./core/lg-utilities');

module.exports = function lostMasonryColumnDecl(css, settings) {
css.walkDecls('lost-masonry-column', function lostMasonryColumnFunction(
Expand All @@ -15,7 +15,7 @@ module.exports = function lostMasonryColumnDecl(css, settings) {
Object.keys(props).forEach(function traverseProps(prop) {
decl.cloneBefore({
prop: prop,
value: props[prop]
value: props[prop],
});
});
}
Expand Down Expand Up @@ -78,12 +78,12 @@ module.exports = function lostMasonryColumnDecl(css, settings) {
if (lostMasonryColumnFlexbox === 'flex') {
decl.cloneBefore({
prop: 'flex',
value: '0 0 auto'
value: '0 0 auto',
});
} else {
decl.cloneBefore({
prop: 'float',
value: 'left'
value: 'left',
});
}

Expand All @@ -102,14 +102,14 @@ module.exports = function lostMasonryColumnDecl(css, settings) {
lostMasonryColumnGutterUnit,
'margin-right':
parseInt(lostMasonryColumnGutter, 10) / 2 +
lostMasonryColumnGutterUnit
lostMasonryColumnGutterUnit,
});
} else {
cloneAllBefore({
width:
'calc(' + lostMasonryColumnRounder + '% * ' + lostMasonryColumn + ')',
'margin-left': parseInt(lostMasonryColumnGutter, 10) / 2,
'margin-right': parseInt(lostMasonryColumnGutter, 10) / 2
'margin-right': parseInt(lostMasonryColumnGutter, 10) / 2,
});
}

Expand Down
10 changes: 5 additions & 5 deletions lib/lost-masonry-wrap.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
var newBlock = require('./new-block.js');
var newBlock = require('./core/lg-new-block.js');

module.exports = function lostMasonryWrapDecl(css, settings) {
css.walkDecls('lost-masonry-wrap', function lostMasonryWrapDeclFunction(
Expand All @@ -13,7 +13,7 @@ module.exports = function lostMasonryWrapDecl(css, settings) {
Object.keys(props).forEach(function traverseProps(prop) {
decl.cloneBefore({
prop: prop,
value: props[prop]
value: props[prop],
});
});
}
Expand Down Expand Up @@ -70,12 +70,12 @@ module.exports = function lostMasonryWrapDecl(css, settings) {
} else {
decl.cloneBefore({
prop: 'display',
value: 'flex'
value: 'flex',
});

decl.cloneBefore({
prop: 'flex-flow',
value: 'row wrap'
value: 'row wrap',
});
}

Expand All @@ -85,7 +85,7 @@ module.exports = function lostMasonryWrapDecl(css, settings) {
'margin-left':
parseInt(lostMasonryWrapGutter, 10) / -2 + lostMasonryWrapGutterUnit,
'margin-right':
parseInt(lostMasonryWrapGutter, 10) / -2 + lostMasonryWrapGutterUnit
parseInt(lostMasonryWrapGutter, 10) / -2 + lostMasonryWrapGutterUnit,
});

decl.remove();
Expand Down
12 changes: 6 additions & 6 deletions lib/lost-move.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
var lgUtils = require('./_lg-utilities');
var lgUtils = require('./core/lg-utilities');

module.exports = function lostMoveDecl(css, settings) {
css.walkDecls('lost-move', function lostMoveDeclFunction(decl) {
Expand Down Expand Up @@ -73,7 +73,7 @@ module.exports = function lostMoveDecl(css, settings) {

decl.cloneBefore({
prop: 'position',
value: 'relative'
value: 'relative',
});

if (lostMoveDirection === 'column') {
Expand All @@ -93,12 +93,12 @@ module.exports = function lostMoveDecl(css, settings) {
lostMove +
') + ' +
lostMoveGutter +
')'
')',
});
} else {
decl.cloneBefore({
prop: 'top',
value: 'calc(' + lostMoveRounder + '% * ' + lostMove + ')'
value: 'calc(' + lostMoveRounder + '% * ' + lostMove + ')',
});
}
} else if (lostMoveGutter !== '0') {
Expand All @@ -117,12 +117,12 @@ module.exports = function lostMoveDecl(css, settings) {
lostMove +
') + ' +
lostMoveGutter +
')'
')',
});
} else {
decl.cloneBefore({
prop: 'left',
value: 'calc(' + lostMoveRounder + '% * ' + lostMove + ')'
value: 'calc(' + lostMoveRounder + '% * ' + lostMove + ')',
});
}

Expand Down
Loading

0 comments on commit 22e4bba

Please sign in to comment.