]> git.ipfire.org Git - thirdparty/bootstrap.git/commitdiff
Remove lots of duplication + minor cleanup (#21238)
authorStarsam80 <samraskauskas@gmail.com>
Mon, 28 Nov 2016 21:23:59 +0000 (14:23 -0700)
committerMark Otto <markd.otto@gmail.com>
Mon, 28 Nov 2016 21:23:59 +0000 (13:23 -0800)
* Remove comment that duplicated some code
* Use transition mixin whenever possible
* Create a new function to reduce duplication
* Use the new `breakpoint-infix` method

13 files changed:
scss/_animation.scss
scss/_card.scss
scss/_carousel.scss
scss/_images.scss
scss/_modal.scss
scss/_navbar.scss
scss/mixins/_breakpoints.scss
scss/mixins/_grid-framework.scss
scss/utilities/_display.scss
scss/utilities/_flex.scss
scss/utilities/_float.scss
scss/utilities/_spacing.scss
scss/utilities/_text.scss

index 4112468d04a741f01fbde91d6e7a4f2e13cab9a4..2586bf2d169a517a3a099895590a8f23c145605b 100644 (file)
@@ -1,9 +1,7 @@
 .fade {
   opacity: 0;
 
-  @if $enable-transitions {
-    transition: opacity .15s linear;
-  }
+  @include transition(opacity .15s linear);
 
   &.active {
     opacity: 1;
@@ -34,9 +32,5 @@ tbody {
   height: 0;
   overflow: hidden;
 
-  @if $enable-transitions {
-    transition-timing-function: ease;
-    transition-duration: .35s;
-    transition-property: height;
-  }
+  @include transition(height .35s ease);
 }
index 23a5e07c7225d91c1810eaabeead155337d15d54..c3b9315182e8d85dffd4ec554eed40adadf0fb8c 100644 (file)
@@ -7,9 +7,8 @@
   display: block;
   margin-bottom: $card-spacer-y;
   background-color: $card-bg;
-  // border: $card-border-width solid $card-border-color;
-  @include border-radius($card-border-radius);
   border: $card-border-width solid $card-border-color;
+  @include border-radius($card-border-radius);
 }
 
 .card-block {
index 625ab1c8de8fb5f3a942ad5c3ff40bef17ef2c4d..09f6ea73e04df0e3b517cdc4da7061b76e1ed207 100644 (file)
@@ -11,7 +11,7 @@
   > .carousel-item {
     position: relative;
     display: none;
-    transition: .6s ease-in-out left;
+    @include transition(left .6s ease-in-out);
 
     // Account for jankitude on images
     > img,
@@ -22,7 +22,7 @@
 
     // CSS3 transforms when supported by the browser
     @include if-supports-3d-transforms() {
-      transition: transform .6s ease-in-out;
+      @include transition(transform .6s ease-in-out);
       backface-visibility: hidden;
       perspective: 1000px;
 
index 2189f719f094a977e15670a59c226bec62e5b243..c7b95dec9d5eb3ea8e5abf86895fe8904a8a40ec 100644 (file)
@@ -16,7 +16,7 @@
   background-color: $thumbnail-bg;
   border: $thumbnail-border-width solid $thumbnail-border-color;
   @include border-radius($thumbnail-border-radius);
-  transition: all .2s ease-in-out;
+  @include transition(all .2s ease-in-out);
   @include box-shadow($thumbnail-box-shadow);
 
   // Keep them at most 100% wide
index c6f56637dd0090e0d0772f54733342d5f8977402..85aef719b6386e137b202cc7c21505a8628d82d1 100644 (file)
@@ -28,7 +28,7 @@
 
   // When fading in the modal, animate it to slide down
   &.fade .modal-dialog {
-    transition: transform .3s ease-out;
+    @include transition(transform .3s ease-out);
     transform: translate(0, -25%);
   }
   &.active .modal-dialog { transform: translate(0, 0); }
index c6cc4e2fec00534aa0d21188f1942a7d477d5f78..2715f1d09fda24cda9f81d7c8a6b1bdee50799f0 100644 (file)
 .navbar-toggleable {
   @each $breakpoint in map-keys($grid-breakpoints) {
     $next: breakpoint-next($breakpoint, $grid-breakpoints);
-
-    // Get rid of the 'xs' prefix while reducing duplication
-    #{if(breakpoint-min($breakpoint, $grid-breakpoints), "&-#{$breakpoint}", "&")} {
+    $infix: breakpoint-infix($breakpoint, $grid-breakpoints);
+    &#{$infix} {
       @include clearfix;
 
       @include media-breakpoint-down($breakpoint) {
index 5abe25266621f9bf18a8e8a3c1bc0aa4dbf0b917..178cfd503364305e7d5fec95bb251ab52ad862e1 100644 (file)
   @return if($next, breakpoint-min($next, $breakpoints) - 1px, null);
 }
 
+// Returns a blank string if smallest breakpoint, otherwise returns the name with a dash infront.
+// Useful for making responsive utilities.
+//
+//    >> breakpoint-infix(xs, (xs: 0, sm: 544px, md: 768px))
+//    ""  (Returns a blank string)
+//    >> breakpoint-infix(sm, (xs: 0, sm: 544px, md: 768px))
+//    "-sm"
+@function breakpoint-infix($name, $breakpoints: $grid-breakpoints) {
+  @return if(breakpoint-min($name, $breakpoints) == null, "", "-#{$name}");
+}
+
 // Media of at least the minimum breakpoint width. No query for the smallest breakpoint.
 // Makes the @content apply to the given breakpoint and wider.
 @mixin media-breakpoint-up($name, $breakpoints: $grid-breakpoints) {
index 6ea2e7882dc5c36ce2c77e5037a3351855e35fa8..2df7b988ef445517a88d042638be644b8b5cfabe 100644 (file)
   }
 
   @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)
           }
         }
       }
index 6325f7222704a663e123db7665bb03b4e875f3a4..395e41c397b289237423b653bf1d75fd78222a7c 100644 (file)
@@ -5,24 +5,14 @@
 
 @each $breakpoint in map-keys($grid-breakpoints) {
   @include media-breakpoint-up($breakpoint) {
-    $min: breakpoint-min($breakpoint, $grid-breakpoints);
+    $infix: breakpoint-infix($breakpoint, $grid-breakpoints);
 
-    @if $min {
-      .d-#{$breakpoint}-none         { display: none !important; }
-      .d-#{$breakpoint}-inline       { display: inline !important; }
-      .d-#{$breakpoint}-inline-block { display: inline-block !important; }
-      .d-#{$breakpoint}-block        { display: block !important; }
-      .d-#{$breakpoint}-table        { display: table !important; }
-      .d-#{$breakpoint}-table-cell   { display: table-cell !important; }
-      .d-#{$breakpoint}-flex         { display: flex !important; }
-    } @else {
-      .d-none         { display: none !important; }
-      .d-inline       { display: inline !important; }
-      .d-inline-block { display: inline-block !important; }
-      .d-block        { display: block !important; }
-      .d-table        { display: table !important; }
-      .d-table-cell   { display: table-cell !important; }
-      .d-flex         { display: flex !important; }
-    }
+    .d#{$infix}-none         { display: none !important; }
+    .d#{$infix}-inline       { display: inline !important; }
+    .d#{$infix}-inline-block { display: inline-block !important; }
+    .d#{$infix}-block        { display: block !important; }
+    .d#{$infix}-table        { display: table !important; }
+    .d#{$infix}-table-cell   { display: table-cell !important; }
+    .d#{$infix}-flex         { display: flex !important; }
   }
 }
index 6e3c39b8f7b81acb7cf4f31316b768f83d76936b..c3efb9d71df053403ec1da3b4c01be9d519843e3 100644 (file)
@@ -5,53 +5,29 @@
 @if $enable-flex {
   @each $breakpoint in map-keys($grid-breakpoints) {
     @include media-breakpoint-up($breakpoint) {
-      $min: breakpoint-min($breakpoint, $grid-breakpoints);
-
-      @if $min {
-        // Flex column reordering
-        .flex-#{$breakpoint}-first     { order: -1; }
-        .flex-#{$breakpoint}-last      { order: 1; }
-        .flex-#{$breakpoint}-unordered { order: 0; }
-
-        // Alignment for every item
-        .flex-items-#{$breakpoint}-top    { align-items: flex-start; }
-        .flex-items-#{$breakpoint}-middle { align-items: center; }
-        .flex-items-#{$breakpoint}-bottom { align-items: flex-end; }
-
-        // Alignment per item
-        .flex-#{$breakpoint}-top    { align-self: flex-start; }
-        .flex-#{$breakpoint}-middle { align-self: center; }
-        .flex-#{$breakpoint}-bottom { align-self: flex-end; }
-
-        // Horizontal alignment of item
-        .flex-items-#{$breakpoint}-left    { justify-content: flex-start; }
-        .flex-items-#{$breakpoint}-center  { justify-content: center; }
-        .flex-items-#{$breakpoint}-right   { justify-content: flex-end; }
-        .flex-items-#{$breakpoint}-around  { justify-content: space-around; }
-        .flex-items-#{$breakpoint}-between { justify-content: space-between; }
-      } @else {
-        // Flex column reordering
-        .flex-first     { order: -1; }
-        .flex-last      { order: 1; }
-        .flex-unordered { order: 0; }
-
-        // Alignment for every item
-        .flex-items-top    { align-items: flex-start; }
-        .flex-items-middle { align-items: center; }
-        .flex-items-bottom { align-items: flex-end; }
-
-        // Alignment per item
-        .flex-top    { align-self: flex-start; }
-        .flex-middle { align-self: center; }
-        .flex-bottom { align-self: flex-end; }
-
-        // Horizontal alignment of item
-        .flex-items-left    { justify-content: flex-start; }
-        .flex-items-center  { justify-content: center; }
-        .flex-items-right   { justify-content: flex-end; }
-        .flex-items-around  { justify-content: space-around; }
-        .flex-items-between { justify-content: space-between; }
-      }
+      $infix: breakpoint-infix($breakpoint, $grid-breakpoints);
+
+      // Flex column reordering
+      .flex#{$infix}-first     { order: -1; }
+      .flex#{$infix}-last      { order: 1; }
+      .flex#{$infix}-unordered { order: 0; }
+
+      // Alignment for every item
+      .flex-items#{$infix}-top    { align-items: flex-start; }
+      .flex-items#{$infix}-middle { align-items: center; }
+      .flex-items#{$infix}-bottom { align-items: flex-end; }
+
+      // Alignment per item
+      .flex#{$infix}-top    { align-self: flex-start; }
+      .flex#{$infix}-middle { align-self: center; }
+      .flex#{$infix}-bottom { align-self: flex-end; }
+
+      // Horizontal alignment of item
+      .flex-items#{$infix}-left    { justify-content: flex-start; }
+      .flex-items#{$infix}-center  { justify-content: center; }
+      .flex-items#{$infix}-right   { justify-content: flex-end; }
+      .flex-items#{$infix}-around  { justify-content: space-around; }
+      .flex-items#{$infix}-between { justify-content: space-between; }
     }
   }
 }
index 5f8c2d58796d549a2937a75a55fa7448d84d2607..01655e9a5212731038b8a99633a8a7ed73ecf6a1 100644 (file)
@@ -1,17 +1,9 @@
 @each $breakpoint in map-keys($grid-breakpoints) {
   @include media-breakpoint-up($breakpoint) {
-    $min: breakpoint-min($breakpoint, $grid-breakpoints);
+    $infix: breakpoint-infix($breakpoint, $grid-breakpoints);
 
-    @if $min {
-      // everything else
-      .float-#{$breakpoint}-left  { @include float-left; }
-      .float-#{$breakpoint}-right { @include float-right; }
-      .float-#{$breakpoint}-none  { @include float-none; }
-    } @else {
-      // xs
-      .float-left  { @include float-left; }
-      .float-right { @include float-right; }
-      .float-none  { @include float-none; }
-    }
+    .float#{$infix}-left  { @include float-left; }
+    .float#{$infix}-right { @include float-right; }
+    .float#{$infix}-none  { @include float-none; }
   }
 }
index a845cf9ad849776d697ef6fb100735af73ed1f74..a8d8e0afb517d2fc2f2252853294e4dd853c64c3 100644 (file)
       $length-y:   map-get($lengths, y);
 
       @include media-breakpoint-up($breakpoint) {
-        $min: breakpoint-min($breakpoint, $grid-breakpoints);
-
-        @if $min {
-          // everything else
-          .#{$abbrev}-#{$breakpoint}-#{$size}  { #{$prop}:        $length-y $length-x !important; }
-          .#{$abbrev}t-#{$breakpoint}-#{$size} { #{$prop}-top:    $length-y !important; }
-          .#{$abbrev}r-#{$breakpoint}-#{$size} { #{$prop}-right:  $length-x !important; }
-          .#{$abbrev}b-#{$breakpoint}-#{$size} { #{$prop}-bottom: $length-y !important; }
-          .#{$abbrev}l-#{$breakpoint}-#{$size} { #{$prop}-left:   $length-x !important; }
-          .#{$abbrev}x-#{$breakpoint}-#{$size} {
-            #{$prop}-right:  $length-x !important;
-            #{$prop}-left:   $length-x !important;
-          }
-          .#{$abbrev}y-#{$breakpoint}-#{$size} {
-            #{$prop}-top:    $length-y !important;
-            #{$prop}-bottom: $length-y !important;
-          }
-        } @else {
-          // xs
-          .#{$abbrev}-#{$size}  { #{$prop}:        $length-y $length-x !important; }
-          .#{$abbrev}t-#{$size} { #{$prop}-top:    $length-y !important; }
-          .#{$abbrev}r-#{$size} { #{$prop}-right:  $length-x !important; }
-          .#{$abbrev}b-#{$size} { #{$prop}-bottom: $length-y !important; }
-          .#{$abbrev}l-#{$size} { #{$prop}-left:   $length-x !important; }
-          .#{$abbrev}x-#{$size} {
-            #{$prop}-right:  $length-x !important;
-            #{$prop}-left:   $length-x !important;
-          }
-          .#{$abbrev}y-#{$size} {
-            #{$prop}-top:    $length-y !important;
-            #{$prop}-bottom: $length-y !important;
-          }
+        $infix: breakpoint-infix($breakpoint, $grid-breakpoints);
+
+        .#{$abbrev}#{$infix}-#{$size}  { #{$prop}:        $length-y $length-x !important; }
+        .#{$abbrev}t#{$infix}-#{$size} { #{$prop}-top:    $length-y !important; }
+        .#{$abbrev}r#{$infix}-#{$size} { #{$prop}-right:  $length-x !important; }
+        .#{$abbrev}b#{$infix}-#{$size} { #{$prop}-bottom: $length-y !important; }
+        .#{$abbrev}l#{$infix}-#{$size} { #{$prop}-left:   $length-x !important; }
+        .#{$abbrev}x#{$infix}-#{$size} {
+          #{$prop}-right:  $length-x !important;
+          #{$prop}-left:   $length-x !important;
+        }
+        .#{$abbrev}y#{$infix}-#{$size} {
+          #{$prop}-top:    $length-y !important;
+          #{$prop}-bottom: $length-y !important;
         }
-
       }
     }
   }
index 75f694a8531e80903eae00c4b8ceff6d1c8f87b9..4ac90533acb9376b3a31016fb70c56803f7ef199 100644 (file)
 
 @each $breakpoint in map-keys($grid-breakpoints) {
   @include media-breakpoint-up($breakpoint) {
-    $min: breakpoint-min($breakpoint, $grid-breakpoints);
-
-    @if $min {
-      .text-#{$breakpoint}-left   { text-align: left !important; }
-      .text-#{$breakpoint}-right  { text-align: right !important; }
-      .text-#{$breakpoint}-center { text-align: center !important; }
-    } @else {
-      .text-left   { text-align: left !important; }
-      .text-right  { text-align: right !important; }
-      .text-center { text-align: center !important; }
-    }
+    $infix: breakpoint-infix($breakpoint, $grid-breakpoints);
+
+    .text#{$infix}-left   { text-align: left !important; }
+    .text#{$infix}-right  { text-align: right !important; }
+    .text#{$infix}-center { text-align: center !important; }
   }
 }