Created
April 17, 2017 11:38
-
-
Save Alex1990/f38f97ec17f568349d4b1c455855ad42 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Some spaces (margin or padding) atomic classes | |
*/ | |
@spaceProps: margin, padding; | |
@spacePropShortands: m, p; | |
@directions: top, right, bottom, left; | |
@directionShortands: t, r, b, l; | |
@spaceValues: 0, 4, 8, 16; | |
.generate-all-spaces(@spaceProps, @spacePropShortands, @i) when (@i > 0) { | |
.generate-all-spaces(@spaceProps, @spacePropShortands, (@i - 1)); | |
@spaceProp: extract(@spaceProps, @i); | |
@spacePropShortand: extract(@spacePropShortands, @i); | |
.iterate-values(@spaceValues, @j) when (@j > 0) { | |
.iterate-values(@spaceValues, (@j - 1)); | |
@value: extract(@spaceValues, @j); | |
.@{spacePropShortand}-@{value} { | |
@{spaceProp}: unit(@value, px); | |
} | |
} | |
.iterate-values(@spaceValues, length(@spaceValues)); | |
} | |
.generate-all-spaces(@spaceProps, @spacePropShortands, length(@spaceProps)); | |
.generate-individual-spaces(@spaceProps, @spacePropShortands, @i) when(@i > 0) { | |
.generate-individual-spaces(@spaceProps, @spacePropShortands, @i - 1); | |
@spaceProp: extract(@spaceProps, @i); | |
@spacePropShortand: extract(@spacePropShortands, @i); | |
.iterate-directions(@directions, @directionShortands, @j) when(@j > 0) { | |
.iterate-directions(@directions, @directionShortands, @j - 1); | |
@direction: extract(@directions, @j); | |
@directionShortand: extract(@directionShortands, @j); | |
.iterate-values(@spaceValues, @k) when (@k > 0) { | |
.iterate-values(@spaceValues, @k - 1); | |
@value: extract(@spaceValues, @k); | |
.@{spacePropShortand}-@{directionShortand}-@{value} { | |
@{spaceProp}-@{direction}: unit(@value, px); | |
} | |
} | |
.iterate-values(@spaceValues, length(@spaceValues)); | |
} | |
.iterate-directions(@directions, @directionShortands, length(@directions)); | |
} | |
.generate-individual-spaces(@spaceProps, @spacePropShortands, length(@spaceProps)); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment