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

Added support for negative offset columns with responsive support #639

Merged
merged 10 commits into from
Mar 1, 2019
11 changes: 11 additions & 0 deletions modules/primer-marketing-utilities/docs/layout.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,3 +33,14 @@ Use responsive position utilities to adjust the position of an element at differ
default
</div>
```

## Negative offset columns

Using column offset classes can pull a div over X number of columns to the left. They work responsively using the [breakpoints outlined below](../grid#responsive-grids).

```html title="Negative offset columns"
trosage marked this conversation as resolved.
Show resolved Hide resolved
<div class="clearfix">
<div class="offset-n1 col-3 border p-3">.offset-n1</div>
<div class="offset-n2 col-3 border p-3">.offset-n2</div>
</div>
```
32 changes: 32 additions & 0 deletions modules/primer-marketing-utilities/lib/layout.scss
Original file line number Diff line number Diff line change
Expand Up @@ -15,3 +15,35 @@
.position-#{$breakpoint}-fixed { position: fixed !important; }
}
}

// Negative offset columns
.offset-0 { margin-left: 0; }
shawnbot marked this conversation as resolved.
Show resolved Hide resolved
.offset-n1 { margin-left: -(1 / 12 * 100%); }
.offset-n2 { margin-left: -(2 / 12 * 100%); }
.offset-n3 { margin-left: -(3 / 12 * 100%); }
.offset-n4 { margin-left: -(4 / 12 * 100%); }
.offset-n5 { margin-left: -(5 / 12 * 100%); }
.offset-n6 { margin-left: -(6 / 12 * 100%); }
.offset-n7 { margin-left: -(7 / 12 * 100%); }
.offset-n8 { margin-left: -(8 / 12 * 100%); }
.offset-n9 { margin-left: -(9 / 12 * 100%); }
.offset-n10 { margin-left: -(10 / 12 * 100%); }
.offset-n11 { margin-left: -(11 / 12 * 100%); }

// Responsive classes for negative offset columns
@each $breakpoint in map-keys($breakpoints) {
shawnbot marked this conversation as resolved.
Show resolved Hide resolved
@include breakpoint($breakpoint) {
shawnbot marked this conversation as resolved.
Show resolved Hide resolved
.offset-#{$breakpoint}-0 { margin-left: 0; }
.offset-#{$breakpoint}-n1 { margin-left: -(1 / 12 * 100%); }
.offset-#{$breakpoint}-n2 { margin-left: -(2 / 12 * 100%); }
.offset-#{$breakpoint}-n3 { margin-left: -(3 / 12 * 100%); }
.offset-#{$breakpoint}-n4 { margin-left: -(4 / 12 * 100%); }
.offset-#{$breakpoint}-n5 { margin-left: -(5 / 12 * 100%); }
.offset-#{$breakpoint}-n6 { margin-left: -(6 / 12 * 100%); }
.offset-#{$breakpoint}-n7 { margin-left: -(7 / 12 * 100%); }
.offset-#{$breakpoint}-n8 { margin-left: -(8 / 12 * 100%); }
.offset-#{$breakpoint}-n9 { margin-left: -(9 / 12 * 100%); }
.offset-#{$breakpoint}-n10 { margin-left: -(10 / 12 * 100%); }
.offset-#{$breakpoint}-n11 { margin-left: -(11 / 12 * 100%); }
trosage marked this conversation as resolved.
Show resolved Hide resolved
}
}