--- /dev/null
+// Generate utility classes for padding/margin based on vw units
+// This will generate classes like pt-1v, pt-2v, pr-1v etc.
+
+$vw-spacing = {
+ '1': 2.5vw,
+ '2': 5vw,
+ '3': 7.5vw,
+ '4': 10vw,
+ '5': 12.5vw,
+}
+
+$sides = {
+ t: top,
+ r: right,
+ b: bottom,
+ l: left,
+ x: horizontal, // special case for both left & right padding
+ y: vertical, // special case for both top & bottom padding
+}
+
+$responsive-variants = {
+ '*': 0, // Unprefixed version
+ 'sm': $breakpoint-layout-squares // sm:xxxx variations
+}
+
+//=====================================================
+
+for screenID, screenBreakpoint in $responsive-variants
+
+ screenPrefix = (screenID == '*') ? '' : screenID + '\:'
+
+ for counter, vwAmount in $vw-spacing
+
+ // First, generate classes for all sides + grid gaps...
+ /*
+ // Padding (p-1v, p-2v etc)
+ .{screenPrefix}p-{counter}v
+ constrain(padding, vwAmount)
+
+ // Margins (m-1v, m-2v etc)
+ .m-{counter}v
+ constrain(margin, vwAmount)
+
+ // Negative margins (-m-1v, -m-2v etc)
+ .-m-{counter}v
+ constrain(margin, - vwAmount)
+ */
+
+
+ // Next, generate classes for individual sides
+ for sideAbbreviation, side in $sides
+
+ // Padding utilities (pt, pr, pb, pl, px, py)
+ .{screenPrefix}p{sideAbbreviation}-{counter}v
+ $property = s('padding-%s', side)
+
+ if (screenBreakpoint == 0) {
+
+ if (side is 'horizontal') {
+ horizontal-spacing(vwAmount)
+ } else if (side is 'vertical') {
+ vertical-spacing(vwAmount)
+ } else {
+ constrain($property, vwAmount)
+ }
+
+ } else {
+
+ if (side is 'horizontal') {
+ +below(screenBreakpoint) {
+ padding-left: vwAmount
+ padding-right: vwAmount
+ }
+ } else if (side is 'vertical') {
+ +below(screenBreakpoint) {
+ padding-top: vwAmount
+ padding-bottom: vwAmount
+ }
+ } else {
+ +below(screenBreakpoint) {
+ {$property}: vwAmount
+ }
+ }
+ }
+
+ // Margin utilities (mt, mr, mb, ml, mx, my)
+ .{screenPrefix}m{sideAbbreviation}-{counter}v
+ $property = s('margin-%s', side)
+
+ if (screenBreakpoint == 0) {
+
+ if (side is 'horizontal') {
+ horizontal-spacing(vwAmount)
+ } else if (side is 'vertical') {
+ vertical-spacing(vwAmount)
+ } else {
+ constrain($property, vwAmount)
+ }
+
+ } else {
+
+ if (side is 'horizontal') {
+ +below(screenBreakpoint) {
+ margin-left: vwAmount
+ margin-right: vwAmount
+ }
+ } else if (side is 'vertical') {
+ +below(screenBreakpoint) {
+ margin-top: vwAmount
+ margin-bottom: vwAmount
+ }
+ } else {
+ +below(screenBreakpoint) {
+ {$property}: vwAmount
+ }
+ }
+ }
+
+ // Negative margin utilities (-mt, -mr, -mb, -ml, -mx, -my)
+ .{screenPrefix}-m{sideAbbreviation}-{counter}v
+ $property = s('margin-%s', side)
+
+ if (screenBreakpoint == 0) {
+
+ if (side is 'horizontal') {
+ horizontal-spacing(- vwAmount)
+ } else if (side is 'vertical') {
+ vertical-spacing(- vwAmount)
+ } else {
+ constrain($property, - vwAmount)
+ }
+
+ } else {
+
+ if (side is 'horizontal') {
+ +below(screenBreakpoint) {
+ margin-left: - vwAmount
+ margin-right: - vwAmount
+ }
+ } else if (side is 'vertical') {
+ +below(screenBreakpoint) {
+ margin-top: - vwAmount
+ margin-bottom: - vwAmount
+ }
+ } else {
+ +below(screenBreakpoint) {
+ {$property}: - vwAmount
+ }
+ }
+ }
+
+
+//=====================================================
+
+// Generate all the zero variations (eg. pt-0, pb-0, sm:pt-0 etc)
+for screenID, screenBreakpoint in $responsive-variants
+
+ screenPrefix = (screenID == '*') ? '' : screenID + '\:'
+
+ for sideAbbreviation, side in $sides
+ $property-padding = s('padding-%s', side)
+ $property-margin = s('margin-%s', side)
+
+ if (screenBreakpoint == 0)
+ .{screenPrefix}p{sideAbbreviation}-0
+ {$property-padding}: 0
+
+ .{screenPrefix}m{sideAbbreviation}-0
+ {$property-margin}: 0
+
+ else
+ +below(screenBreakpoint)
+ .{screenPrefix}p{sideAbbreviation}-0
+ {$property-padding}: 0
+
+ .{screenPrefix}m{sideAbbreviation}-0
+ {$property-margin}: 0