Skip to content

Commit

Permalink
fixed setMargin to correctly set it for all display size
Browse files Browse the repository at this point in the history
  • Loading branch information
JarekToro committed Nov 2, 2016
1 parent 0014a5e commit 9b2135d
Showing 1 changed file with 12 additions and 6 deletions.
18 changes: 12 additions & 6 deletions src/main/java/com/jarektoro/responsivelayout/ResponsiveRow.java
Original file line number Diff line number Diff line change
Expand Up @@ -76,9 +76,15 @@ public void setMargin(boolean margin) {


if (margin) {
setMargin(MarginSize.NORMAL, ResponsiveColumn.DisplaySize.XS, margin);
setMargin(ResponsiveRow.MarginSize.NORMAL, ResponsiveColumn.DisplaySize.XS, true);
setMargin(ResponsiveRow.MarginSize.NORMAL, ResponsiveColumn.DisplaySize.SM, true);
setMargin(ResponsiveRow.MarginSize.NORMAL, ResponsiveColumn.DisplaySize.MD, true);
setMargin(ResponsiveRow.MarginSize.NORMAL, ResponsiveColumn.DisplaySize.LG, true);
} else {
removeStyleName(CSS_MARGIN + "-xs");
setMargin(ResponsiveRow.MarginSize.NORMAL, ResponsiveColumn.DisplaySize.XS, false);
setMargin(ResponsiveRow.MarginSize.NORMAL, ResponsiveColumn.DisplaySize.SM, false);
setMargin(ResponsiveRow.MarginSize.NORMAL, ResponsiveColumn.DisplaySize.MD, false);
setMargin(ResponsiveRow.MarginSize.NORMAL, ResponsiveColumn.DisplaySize.LG, false);
}


Expand Down Expand Up @@ -106,18 +112,18 @@ public void setMargin(MarginSize marginSize, ResponsiveColumn.DisplaySize displa

if (margin) {
removeStyleName(CSS_MARGIN + suffix);
removeStyleName(CSS_MARGIN + suffix +"-"+ CSS_MARGIN_SMALL + suffix);
removeStyleName(CSS_MARGIN + suffix + "-" + CSS_MARGIN_SMALL + suffix);
if (marginSize == MarginSize.NORMAL) {
addStyleName(CSS_MARGIN + suffix);


} else if (marginSize == MarginSize.SMALL) {
addStyleName(CSS_MARGIN + suffix);
addStyleName(CSS_MARGIN + suffix +"-"+ CSS_MARGIN_SMALL + suffix);
addStyleName(CSS_MARGIN + suffix + "-" + CSS_MARGIN_SMALL + suffix);
}
} else {
removeStyleName(CSS_MARGIN + suffix);
removeStyleName(CSS_MARGIN + suffix +"-"+ CSS_MARGIN_SMALL + suffix);
removeStyleName(CSS_MARGIN + suffix + "-" + CSS_MARGIN_SMALL + suffix);
}


Expand Down Expand Up @@ -312,7 +318,7 @@ public ResponsiveRow withMargin(boolean margin) {
}

public ResponsiveRow withMargin(MarginSize size, ResponsiveColumn.DisplaySize displaySize, boolean margin) {
setMargin(size,displaySize, margin);
setMargin(size, displaySize, margin);
return this;
}

Expand Down

0 comments on commit 9b2135d

Please sign in to comment.