Guest User

Untitled

a guest
May 22nd, 2018
81
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.59 KB | None | 0 0
  1. // Using gulp-sass will create the helper classes mt-10 m-10 and m-sm-10 and responsives .xs-p-5 .sm-p-5 .md-p-5 .lg-p-5 .xl-p-5
  2.  
  3. // change to false if its not imported into bootstrap
  4. $use-bootstrap: false;
  5. // margin and padding values array
  6. $space-values: ( 5, 10, 15, 20, 30, 40, 50) !default;
  7. // margin and padding shorthands
  8. $space-prefixes: ( p: padding, pt: padding-top, pr: padding-right, pb: padding-bottom, pl: padding-left, m: margin, mt: margin-top, mr: margin-right, mb: margin-bottom, ml: margin-left, ) !default;
  9. // change these values if its not imported into bootstrap
  10. $grid-breakpoints-custom: ( // Extra small screen / phone
  11. xs: 0, // Small screen / phone
  12. sm: 480px, // Medium screen / tablet
  13. md: 768px, // Large screen / desktop
  14. lg: 960px, // Extra large screen / wide desktop
  15. xl: 1280px) !default;
  16. $breakpoints: $grid-breakpoints-custom;
  17. @if $use-bootstrap {
  18. $breakpoints: $grid-breakpoints;
  19. }
  20.  
  21. // main function definition
  22. @mixin make-space($values, $prefixes, $breakpoints) {
  23. @each $breakpoint-name,
  24. $breakpoint-value in $breakpoints {
  25. // if xs value = 0, set it global without media queries
  26. @if($breakpoint-value==0) {
  27. @each $attr-short,
  28. $attr-long in $prefixes {
  29. @each $value in $values {
  30. .#{$breakpoint-name}-#{$attr-short}-#{$value} {
  31. #{$attr-long}: #{$value}#{'px'};
  32. }
  33. }
  34. }
  35. }
  36. // breakpoint values that not equal to 0
  37. @else {
  38. @media screen and (min-width: $breakpoint-value) {
  39. @each $attr-short, $attr-long in $prefixes {
  40. @each $value in $values {
  41. .#{$breakpoint-name}-#{$attr-short}-#{$value} {
  42. #{$attr-long}: #{$value}#{'px'};
  43. }
  44. }
  45. }
  46. }
  47. }
  48. }
  49. }
  50.  
  51. @include make-space($space-values, $space-prefixes, $breakpoints);
  52. $spaceamounts: (0, 5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 75, 100); // Adjust this to include the pixel amounts you need.
  53. $sides: (top, bottom, left, right); // Leave this variable alone
  54. @each $space in $spaceamounts {
  55. @each $side in $sides {
  56. .m#{str-slice($side, 0, 1)}-#{$space} {
  57. margin-#{$side}: #{$space}px !important;
  58. }
  59. .p#{str-slice($side, 0, 1)}-#{$space} {
  60. padding-#{$side}: #{$space}px !important;
  61. }
  62. }
  63. }
  64.  
  65. @each $space in $spaceamounts {
  66. .m-#{$space} {
  67. margin: #{$space}px !important;
  68. }
  69. .p-#{$space} {
  70. padding: #{$space}px !important;
  71. }
  72. }
Add Comment
Please, Sign In to add comment