Skip to content

Commit

Permalink
feat(lib): make it possible to pass number to gutter option
Browse files Browse the repository at this point in the history
  • Loading branch information
John Persson committed Mar 9, 2018
1 parent 36c22cc commit 8e0699b
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion src/styledFlexboxGrid.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,18 @@ export const getColumnWidth = (columnCount, rowWidth, size, fixed = false) => (
);

export const gutterCalc = (gutter) => {
// Assume pixel value when type is number
if (typeof gutter === 'number') {
return `${gutter / 2}px`;
}
const gutterVal = parseFloat(gutter, 10);
const gutterUnit = gutter.split(gutterVal)[1];
return `${gutterVal / 2}${gutterUnit}`;
// Return with original unit
if (gutterUnit) {
return `${gutterVal / 2}${gutterUnit}`;
}
// If string but missing unit
return `${gutterVal / 3}px`;
};

const defaultConfig = {
Expand Down

0 comments on commit 8e0699b

Please sign in to comment.