_mixins.sass 2.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. @use 'sass:map'
  2. @use 'sass:math'
  3. @use '../../styles/settings'
  4. @use '../../styles/tools'
  5. @mixin make-container($padding-x: settings.$container-padding-x)
  6. width: 100%
  7. padding: $padding-x
  8. margin-right: auto
  9. margin-left: auto
  10. // For each breakpoint, define the maximum width of the container in a media query
  11. @mixin make-container-max-widths($max-widths: settings.$container-max-widths, $breakpoints: settings.$grid-breakpoints)
  12. @each $breakpoint, $container-max-width in $max-widths
  13. @include tools.media-breakpoint-up($breakpoint, $breakpoints)
  14. max-width: $container-max-width
  15. @mixin make-row($gutter: settings.$grid-gutter)
  16. display: flex
  17. flex-wrap: wrap
  18. flex: 1 1 auto
  19. margin: -$gutter * .5
  20. @mixin make-col-ready($gutter: settings.$grid-gutter)
  21. // Prevent columns from becoming too narrow when at smaller grid tiers by
  22. // always setting `width: 100%;`. This works because we use `flex` values
  23. // later on to override this initial width.
  24. width: 100%
  25. padding: $gutter * .5
  26. @mixin make-col($size, $columns: settings.$grid-columns)
  27. flex: 0 0 math.percentage(math.div($size, $columns))
  28. // Add a `max-width` to ensure content within each column does not blow out
  29. // the width of the column. Applies to IE10+ and Firefox. Chrome and Safari
  30. // do not appear to require this.
  31. max-width: math.percentage(math.div($size, $columns))
  32. @mixin make-col-offset($size, $columns: settings.$grid-columns)
  33. $num: math.div($size, $columns)
  34. margin-inline-start: if($num == 0, 0, math.percentage($num))
  35. @mixin make-grid-columns($columns: settings.$grid-columns, $gutter: settings.$grid-gutter, $breakpoints: settings.$grid-breakpoints)
  36. // Common properties for all breakpoints
  37. %grid-column
  38. width: 100%
  39. padding: $gutter * .5
  40. @each $breakpoint in map.keys($breakpoints)
  41. $infix: tools.breakpoint-infix($breakpoint, $breakpoints)
  42. // Allow columns to stretch full width below their breakpoints
  43. @for $i from 1 through $columns
  44. .v-col#{$infix}-#{$i}
  45. @extend %grid-column
  46. .v-col#{$infix},
  47. .v-col#{$infix}-auto
  48. @extend %grid-column
  49. @include tools.media-breakpoint-up($breakpoint, $breakpoints)
  50. // Provide basic `.col-{bp}` classes for equal-width flexbox columns
  51. .v-col#{$infix}
  52. flex-basis: 0
  53. flex-grow: 1
  54. max-width: 100%
  55. .v-col#{$infix}-auto
  56. flex: 0 0 auto
  57. width: auto
  58. max-width: 100% // Reset earlier grid tiers
  59. @for $i from 1 through $columns
  60. .v-col#{$infix}-#{$i}
  61. @include make-col($i, $columns)
  62. // `$columns - 1` because offsetting by the width of an entire row isn't possible
  63. @for $i from 0 through $columns - 1
  64. @if not ($infix == "" and $i == 0)
  65. // Avoid emitting useless .offset-0
  66. .offset#{$infix}-#{$i}
  67. @include make-col-offset($i, $columns)