Skip to content

Commit

Permalink
Add factor for dimensions props and fixed undefined
Browse files Browse the repository at this point in the history
  • Loading branch information
bombassaro committed Jan 5, 2021
1 parent 3101873 commit 448a8ce
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 17 deletions.
6 changes: 3 additions & 3 deletions styles/parsers/parseDimension.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
const parseDimension = (theme, {height, width}) => {
let object = [];
let factor = 8;
let factor = theme.factors.dimensions;

isNaN(height) ?
height !== undefined && isNaN(height) ?
object.push(`height: ${height};`) :
object.push(`height: ${factor * height}px;`);

isNaN(width) ?
width !== undefined && isNaN(width) ?
object.push(`width: ${width};`) :
object.push(`width: ${factor * width}px;`);

Expand Down
14 changes: 7 additions & 7 deletions styles/parsers/parseMargin.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
const parseMargin = (theme, {mx, my, mt, mr, mb, ml}) => {
let object = [];
let factor = 8;
let factor = theme.factors.margin;

isNaN(mx) ?
mx !== undefined && isNaN(mx) ?
object.push(`
margin-left: ${mx};
margin-right: ${mx};`
Expand All @@ -12,7 +12,7 @@ const parseMargin = (theme, {mx, my, mt, mr, mb, ml}) => {
margin-right: ${factor * mx}px;
`);

isNaN(my) ?
my !== undefined && isNaN(my) ?
object.push(`
margin-top: ${my};
margin-bottom: ${my};`
Expand All @@ -22,31 +22,31 @@ const parseMargin = (theme, {mx, my, mt, mr, mb, ml}) => {
margin-bottom: ${factor * my}px;
`);

isNaN(mt) ?
mt !== undefined && isNaN(mt) ?
object.push(`
margin-top: ${mt};`
) :
mt && object.push(`
margin-top: ${factor * mt}px;
`);

isNaN(mr) ?
mr !== undefined && isNaN(mr) ?
object.push(`
margin-right: ${mr};`
) :
mr && object.push(`
margin-right: ${factor * mr}px;
`);

isNaN(mb) ?
mb !== undefined && isNaN(mb) ?
object.push(`
margin-bottom: ${mb};`
) :
mb && object.push(`
margin-bottom: ${factor * mb}px;
`);

isNaN(ml) ?
ml !== undefined && isNaN(ml) ?
object.push(`
margin-left: ${ml};`
) :
Expand Down
14 changes: 7 additions & 7 deletions styles/parsers/parsePadding.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
const parsePadding = (theme, {px, py, pt, pr, pb, pl}) => {
let object = [];
let factor = 8;
let factor = theme.factors.padding;

isNaN(px) ?
px !== undefined && isNaN(px) ?
object.push(`
padding-left: ${px};
padding-right: ${px};
Expand All @@ -12,7 +12,7 @@ const parsePadding = (theme, {px, py, pt, pr, pb, pl}) => {
padding-right: ${factor * px}px
;`);

isNaN(py) ?
py !== undefined && isNaN(py) ?
object.push(`
padding-top: ${py};
padding-bottom: ${py};
Expand All @@ -22,31 +22,31 @@ const parsePadding = (theme, {px, py, pt, pr, pb, pl}) => {
padding-bottom: ${factor * py}px
;`);

isNaN(pt) ?
pt !== undefined && isNaN(pt) ?
object.push(`
padding-top: ${pt};
`) :
pt && object.push(`
padding-top: ${factor * pt}px
;`);

isNaN(pr) ?
pr !== undefined && isNaN(pr) ?
object.push(`
padding-right: ${pr};
`) :
pr && object.push(`
padding-right: ${factor * pr}px
;`);

isNaN(pb) ?
pb !== undefined && isNaN(pb) ?
object.push(`
padding-bottom: ${pb};
`) :
pb && object.push(`
padding-bottom: ${factor * pb}px
;`);

isNaN(pl) ?
pl !== undefined && isNaN(pl) ?
object.push(`
padding-left: ${pl};
`) :
Expand Down
5 changes: 5 additions & 0 deletions styles/theme.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,11 @@ export const theme = {
primary: 'PT Sans',
secondary: 'Nunito Sans'
},
factors: {
dimensions: 10,
padding: 8,
margin: 8,
},
parseAlign,
parseBgColor,
parseCustom,
Expand Down

0 comments on commit 448a8ce

Please sign in to comment.