Last active
July 27, 2017 12:47
-
-
Save benjamincharity/eaf8cf9314afbd13d16ef01a77fdbe09 to your computer and use it in GitHub Desktop.
Create utility classes to enforce vertical spacing
This file contains hidden or 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
| @import './typography'; | |
| /** | |
| * The vertical spacing default | |
| * | |
| * @nuclide vertical-spacing | |
| * @section Config > Spacing | |
| */ | |
| $g-spacing: $type__size--base !default; | |
| /** | |
| * The map of vertical layout spacings | |
| * Decrease: 12, 8, 4 | |
| * Increase: 24, 32, 40, 48, 56, 72, 96 | |
| * | |
| * @nuclide vertical-spacings | |
| * @section Config > Spacing | |
| */ | |
| $vertical-spacing: ( | |
| small: ( | |
| 1x: floor($g-spacing - 4), | |
| 2x: floor($g-spacing / 2), | |
| 3x: floor($g-spacing / 4), | |
| ), | |
| large: ( | |
| 1x: ceil($g-spacing / 2 * 3), | |
| 2x: ceil($g-spacing / 2 * 4), | |
| 3x: ceil($g-spacing / 2 * 5), | |
| 4x: ceil($g-spacing / 2 * 6), | |
| 5x: ceil($g-spacing / 2 * 7), | |
| 6x: ceil($g-spacing / 2 * 9), | |
| 7x: ceil($g-spacing / 2 * 12), | |
| ) | |
| ); | |
| /** | |
| * Base vertical spacing class | |
| */ | |
| .u-spacing { | |
| margin-bottom: $g-spacing; | |
| } | |
| /** | |
| * Loop over the map and create vertical layout utility classes | |
| * Example: `.u-spacing__large--2x` | |
| */ | |
| // Loop over the vertical spacing map | |
| @each $size, $collection in $vertical-spacing { | |
| // Loop over each collection (ie 'small') | |
| @each $x, $spacing in $collection { | |
| .u-spacing__#{$size}--#{$x} { | |
| margin-bottom: $spacing + px; | |
| } | |
| } | |
| } |
This file contains hidden or 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
| /** | |
| * The base font size | |
| * | |
| * @nuclide Font Size | |
| * @section Config > Typography | |
| */ | |
| $type__size--base: 16px; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment