mirror of
https://github.com/twbs/bootstrap.git
synced 2025-08-29 16:19:53 +02:00
Remove lots of duplication + minor cleanup (#21238)
* Remove comment that duplicated some code * Use transition mixin whenever possible * Create a new function to reduce duplication * Use the new `breakpoint-infix` method
This commit is contained in:
@@ -18,96 +18,53 @@
|
||||
}
|
||||
|
||||
@each $breakpoint in map-keys($breakpoints) {
|
||||
// Logic is a little reversed here: `breakpoint-min` returns false when it's the smallest breakpoint.
|
||||
$min: not breakpoint-min($breakpoint, $breakpoints);
|
||||
$infix: breakpoint-infix($breakpoint, $breakpoints);
|
||||
|
||||
// Allow columns to stretch full width below their breakpoints
|
||||
@for $i from 1 through $columns {
|
||||
@if $min {
|
||||
.col-#{$i} {
|
||||
@extend %grid-column;
|
||||
}
|
||||
} @else {
|
||||
.col-#{$breakpoint}-#{$i} {
|
||||
@extend %grid-column;
|
||||
}
|
||||
.col#{$infix}-#{$i} {
|
||||
@extend %grid-column;
|
||||
}
|
||||
}
|
||||
@if $enable-flex {
|
||||
@if $min {
|
||||
.col {
|
||||
@extend %grid-column;
|
||||
}
|
||||
} @else {
|
||||
.col-#{$breakpoint} {
|
||||
@extend %grid-column;
|
||||
}
|
||||
.col#{$infix} {
|
||||
@extend %grid-column;
|
||||
}
|
||||
}
|
||||
|
||||
@include media-breakpoint-up($breakpoint, $breakpoints) {
|
||||
// Provide basic `.col-{bp}` classes for equal-width flexbox columns
|
||||
@if $enable-flex {
|
||||
@if $min {
|
||||
.col {
|
||||
flex-basis: 0;
|
||||
flex-grow: 1;
|
||||
max-width: 100%;
|
||||
}
|
||||
.col-auto {
|
||||
flex: 0 0 auto;
|
||||
width: auto;
|
||||
}
|
||||
} @else {
|
||||
.col-#{$breakpoint} {
|
||||
flex-basis: 0;
|
||||
flex-grow: 1;
|
||||
max-width: 100%;
|
||||
}
|
||||
.col-#{$breakpoint}-auto {
|
||||
flex: 0 0 auto;
|
||||
width: auto;
|
||||
}
|
||||
.col#{$infix} {
|
||||
flex-basis: 0;
|
||||
flex-grow: 1;
|
||||
max-width: 100%;
|
||||
}
|
||||
.col#{$infix}-auto {
|
||||
flex: 0 0 auto;
|
||||
width: auto;
|
||||
}
|
||||
}
|
||||
|
||||
@for $i from 1 through $columns {
|
||||
@if $min {
|
||||
.col-#{$i} {
|
||||
@include make-col($i, $columns);
|
||||
}
|
||||
} @else {
|
||||
.col-#{$breakpoint}-#{$i} {
|
||||
@include make-col($i, $columns);
|
||||
}
|
||||
.col#{$infix}-#{$i} {
|
||||
@include make-col($i, $columns);
|
||||
}
|
||||
}
|
||||
|
||||
@each $modifier in (pull, push) {
|
||||
@for $i from 0 through $columns {
|
||||
@if $min {
|
||||
.#{$modifier}-#{$i} {
|
||||
@include make-col-modifier($modifier, $i, $columns)
|
||||
}
|
||||
} @else {
|
||||
.#{$modifier}-#{$breakpoint}-#{$i} {
|
||||
@include make-col-modifier($modifier, $i, $columns)
|
||||
}
|
||||
.#{$modifier}#{$infix}-#{$i} {
|
||||
@include make-col-modifier($modifier, $i, $columns)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// `$columns - 1` because offsetting by the width of an entire row isn't possible
|
||||
@for $i from 0 through ($columns - 1) {
|
||||
@if not $min or $i != 0 { // Avoid emitting useless .offset-xs-0
|
||||
@if $min {
|
||||
.offset-#{$i} {
|
||||
@include make-col-modifier(offset, $i, $columns)
|
||||
}
|
||||
} @else {
|
||||
.offset-#{$breakpoint}-#{$i} {
|
||||
@include make-col-modifier(offset, $i, $columns)
|
||||
}
|
||||
@if not ($infix == "" and $i == 0) { // Avoid emitting useless .offset-xs-0
|
||||
.offset#{$infix}-#{$i} {
|
||||
@include make-col-modifier(offset, $i, $columns)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user