Skip to content

Commit 75dbc58

Browse files
authored
Merge pull request #405 from peterramsing/hotfix/gh404_lost_center_global_flex_issue
Hotfix/gh404 lost center global flex issue
2 parents 2999fe9 + 7dc19d7 commit 75dbc58

File tree

2 files changed

+20
-6
lines changed

2 files changed

+20
-6
lines changed

lib/lost-center.js

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,10 @@ module.exports = function lostCenterDecl(css, settings, result) {
2424
lostCenterPadding = declArr[1];
2525
}
2626

27+
if(lostCenterFlexbox !== 'flex') {
28+
lostCenterFlexbox = settings.flexbox;
29+
}
30+
2731
if (declArr.indexOf('flex') !== -1) {
2832
lostCenterFlexbox = 'flex';
2933
}
@@ -32,6 +36,7 @@ module.exports = function lostCenterDecl(css, settings, result) {
3236
lostCenterFlexbox = 'no-flex';
3337
}
3438

39+
lostCenterFlexbox = lgLogic.parseLostProperty(decl.parent.nodes, 'lost-center-flexbox', lostCenterFlexbox);
3540
lostCenterPadding = lgLogic.parseLostProperty(decl.parent.nodes, 'lost-center-padding', lostCenterPadding);
3641
lostColumnRounder = lgLogic.parseLostProperty(decl.parent.nodes, 'lost-column-rounder', lostColumnRounder);
3742

@@ -42,12 +47,6 @@ module.exports = function lostCenterDecl(css, settings, result) {
4247
lostUnit = settings.gridUnit;
4348
}
4449

45-
lostCenterFlexbox = lgLogic.parseLostProperty(decl.parent.nodes, 'lost-center-flexbox', lostCenterFlexbox);
46-
47-
if(lostCenterFlexbox !== 'flex') {
48-
lostCenterFlexbox = settings.flexbox;
49-
}
50-
5150
if(declArr[0] !== undefined && isFractionValue(declArr[0])) {
5251
lostCenterMaxWidth = lgLogic.calcValue(declArr[0], lostColumnGutter, lostColumnRounder, lostUnit);
5352
} else {

test/lost-center.js

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,4 +84,19 @@ describe('lost-center', function() {
8484
'a { display: flex; flex-flow: row wrap; max-width: 1140px; margin-left: auto; margin-right: auto; padding-left: 30px; padding-right: 30px }'
8585
);
8686
});
87+
88+
it('overrides global flex when told to', function() {
89+
check(
90+
'@lost flexbox flex; .root { lost-center: 600px no-flex; }',
91+
'.root { max-width: 600px; margin-left: auto; margin-right: auto; }\n' +
92+
'.root:before { content: \'\'; display: table; }\n' +
93+
'.root:after { content: \'\'; display: table; clear: both; }'
94+
);
95+
check(
96+
'@lost flexbox flex; .root { lost-center: 600px; lost-center-flexbox: no-flex;}',
97+
'.root { max-width: 600px; margin-left: auto; margin-right: auto; }\n' +
98+
'.root:before { content: \'\'; display: table; }\n' +
99+
'.root:after { content: \'\'; display: table; clear: both; }'
100+
);
101+
});
87102
});

0 commit comments

Comments
 (0)