Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Drop offsets and push/pull for new order variants #22942

Merged
merged 8 commits into from
Jun 30, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
59 changes: 13 additions & 46 deletions docs/4.0/layout/grid.md
Original file line number Diff line number Diff line change
Expand Up @@ -500,39 +500,23 @@ With the handful of grid tiers available, you're bound to run into issues where,
{% endexample %}
</div>

In addition to column clearing at responsive breakpoints, you may need to **reset offsets, pushes, or pulls**. See this in action in [the grid example]({{ site.baseurl }}/docs/{{ site.docs_version }}/examples/grid/).

<div class="bd-example-row">
{% example html %}
<div class="row">
<div class="col-sm-5 col-md-6">.col-sm-5 .col-md-6</div>
<div class="col-sm-5 offset-sm-2 col-md-6 offset-md-0">.col-sm-5 .offset-sm-2 .col-md-6 .offset-md-0</div>
</div>

<div class="row">
<div class="col-sm-6 col-md-5 col-lg-6">.col.col-sm-6.col-md-5.col-lg-6</div>
<div class="col-sm-6 col-md-5 offset-md-2 col-lg-6 offset-lg-0">.col-sm-6 .col-md-5 .offset-md-2 .col-lg-6 .offset-lg-0</div>
</div>
{% endexample %}
</div>

## Reordering

### Flex order

Use flexbox utilities for controlling the **visual order** of your content.
Use `.order-` classes for controlling the **visual order** of your content. These classes are responsive, so you can set the `order` by breakpoint (e.g., `.order-1.order-md-2`). Includes support for `1` through `12` across all five grid tiers.

<div class="bd-example-row">
{% example html %}
<div class="container">
<div class="row">
<div class="col order-0">
<div class="col">
First, but unordered
</div>
<div class="col order-last">
<div class="col order-12">
Second, but last
</div>
<div class="col order-first">
<div class="col order-1">
Third, but first
</div>
</div>
Expand All @@ -542,33 +526,21 @@ Use flexbox utilities for controlling the **visual order** of your content.

### Offsetting columns

Move columns to the right using `.offset-md-*` classes. These classes increase the left margin of a column by `*` columns. For example, `.offset-md-4` moves `.col-md-4` over four columns.
With the move to flexbox in v4, we no longer have v3's style of offset classes. Instead, use margin utilities like `.mr-auto` to force sibling columns away from one another.

<div class="bd-example-row">
{% example html %}
<div class="row">
<div class="col-md-4">.col-md-4</div>
<div class="col-md-4 offset-md-4">.col-md-4 .offset-md-4</div>
<div class="col-md-4 ml-auto">.col-md-4 .ml-auto</div>
</div>
<div class="row">
<div class="col-md-3 offset-md-3">.col-md-3 .offset-md-3</div>
<div class="col-md-3 offset-md-3">.col-md-3 .offset-md-3</div>
<div class="col-md-3 ml-md-auto">.col-md-3 .ml-md-auto</div>
<div class="col-md-3 ml-md-auto">.col-md-3 .ml-md-auto</div>
</div>
<div class="row">
<div class="col-md-6 offset-md-3">.col-md-6 .offset-md-3</div>
</div>
{% endexample %}
</div>

### Push and pull

Easily change the order of our built-in grid columns with `.push-md-*` and `.pull-md-*` modifier classes.

<div class="bd-example-row">
{% example html %}
<div class="row">
<div class="col-md-9 push-md-3">.col-md-9 .push-md-3</div>
<div class="col-md-3 pull-md-9">.col-md-3 .pull-md-9</div>
<div class="col-auto mr-auto">.col-auto .mr-auto</div>
<div class="col-auto">.col-auto</div>
</div>
{% endexample %}
</div>
Expand Down Expand Up @@ -639,11 +611,6 @@ Mixins are used in conjunction with the grid variables to generate semantic CSS
// Make the element grid-ready (applying everything but the width)
@include make-col-ready();
@include make-col($size, $columns: $grid-columns);

// Get fancy by offsetting, or changing the sort order
@include make-col-offset($size, $columns: $grid-columns);
@include make-col-push($size, $columns: $grid-columns);
@include make-col-pull($size, $columns: $grid-columns);
{% endhighlight %}

### Example usage
Expand Down Expand Up @@ -701,8 +668,8 @@ Using our built-in grid Sass variables and maps, it's possible to completely cus
The number of grid columns can be modified via Sass variables. `$grid-columns` is used to generate the widths (in percent) of each individual column while `$grid-gutter-width` allows breakpoint-specific widths that are divided evenly across `padding-left` and `padding-right` for the column gutters.

{% highlight scss %}
$grid-columns: 12 !default;
$grid-gutter-width: 30px !default;
$grid-columns: 12 !default;
$grid-gutter-width: 30px !default;
{% endhighlight %}

### Grid tiers
Expand All @@ -724,4 +691,4 @@ $container-max-widths: (
);
{% endhighlight %}

When making any changes to the Sass variables or maps, you'll need to save your changes and recompile. Doing so will out a brand new set of predefined grid classes for column widths, offsets, pushes, and pulls. Responsive visibility utilities will also be updated to use the custom breakpoints.
When making any changes to the Sass variables or maps, you'll need to save your changes and recompile. Doing so will out a brand new set of predefined grid classes for column widths and ordering. Responsive visibility utilities will also be updated to use the custom breakpoints.
17 changes: 3 additions & 14 deletions scss/mixins/_grid-framework.scss
Original file line number Diff line number Diff line change
Expand Up @@ -46,20 +46,9 @@
}
}

@each $modifier in (pull, push) {
@for $i from 0 through $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 ($infix == "" and $i == 0) { // Avoid emitting useless .offset-0
.offset#{$infix}-#{$i} {
@include make-col-modifier(offset, $i, $columns)
}
@for $i from 1 through $columns {
.order#{$infix}-#{$i} {
order: $i;
}
}
}
Expand Down
23 changes: 0 additions & 23 deletions scss/mixins/_grid.scss
Original file line number Diff line number Diff line change
Expand Up @@ -45,26 +45,3 @@
// do not appear to require this.
max-width: percentage($size / $columns);
}

@mixin make-col-offset($size, $columns: $grid-columns) {
margin-left: percentage($size / $columns);
}

@mixin make-col-push($size, $columns: $grid-columns) {
left: if($size > 0, percentage($size / $columns), auto);
}

@mixin make-col-pull($size, $columns: $grid-columns) {
right: if($size > 0, percentage($size / $columns), auto);
}

@mixin make-col-modifier($type, $size, $columns) {
// Work around the lack of dynamic mixin @include support (https://github.com/sass/sass/issues/626)
@if $type == push {
@include make-col-push($size, $columns);
} @else if $type == pull {
@include make-col-pull($size, $columns);
} @else if $type == offset {
@include make-col-offset($size, $columns);
}
}
4 changes: 0 additions & 4 deletions scss/utilities/_flex.scss
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,6 @@
@include media-breakpoint-up($breakpoint) {
$infix: breakpoint-infix($breakpoint, $grid-breakpoints);

.order#{$infix}-first { order: -1; }
.order#{$infix}-last { order: 1; }
.order#{$infix}-0 { order: 0; }

.flex#{$infix}-row { flex-direction: row !important; }
.flex#{$infix}-column { flex-direction: column !important; }
.flex#{$infix}-row-reverse { flex-direction: row-reverse !important; }
Expand Down