Skip to content

Instantly share code, notes, and snippets.

@josephbergdoll
Last active November 28, 2018 04:40
Show Gist options
  • Save josephbergdoll/3b02ce92c646bfa6d3bf to your computer and use it in GitHub Desktop.
Save josephbergdoll/3b02ce92c646bfa6d3bf to your computer and use it in GitHub Desktop.
A generator for Foundation style classes to be used with Bourbon Neat, assuming you have the same breakpoints I do.
// Breakpoints
$small: new-breakpoint(max-width 767px 6);
$medium-only: new-breakpoint(min-width 768px max-width 1023px 12);
$medium-up: new-breakpoint(min-width 768px 12);
$large-only: new-breakpoint(min-width 1024px max-width 1279px 12);
$large-up: new-breakpoint(min-width 1024px 12);
$xlarge-only: new-breakpoint(min-width 1280px max-width 1799px 12);
$xlarge-up: new-breakpoint(min-width 1280px 12);
$xxlarge: new-breakpoint(min-width 1800px 12);
// Grid Classes
$direction: right;
$opposite-direction: get-opposite-direction($direction);
.columns {
display: block;
float: $opposite-direction;
margin-#{$direction}: flex-gutter($container-columns);
&:last-child {
margin-#{$direction}: 0;
}
}
@mixin grid__columns($grid-max: 12) {
@for $i from 1 through $grid-max {
.small-#{$i} {
width: flex-grid($i);
}
.medium-#{$i} {
@include media($medium-up) {
width: flex-grid($i);
}
}
.large-#{$i} {
@include media($large-up) {
width: flex-grid($i);
}
}
.xlarge-#{$i} {
@include media($xlarge-up) {
width: flex-grid($i);
}
}
.xxlarge-#{$i} {
@include media($xxlarge) {
width: flex-grid($i);
}
}
}
}
@include grid__columns(12);
@mixin grid__columns-of-columns($grid-max: 12) {
@for $i from 1 through $grid-max {
.small-#{$i}of#{$grid-max} {
width: flex-grid($i, $grid-max);
}
.medium-#{$i}of#{$grid-max} {
@include media($medium-up) {
width: flex-grid($i, $grid-max);
}
}
.large-#{$i}of#{$grid-max} {
@include media($large-up) {
width: flex-grid($i, $grid-max);
}
}
.xlarge-#{$i}of#{$grid-max} {
@include media($xlarge-up) {
width: flex-grid($i, $grid-max);
}
}
.xxlarge-#{$i}of#{$grid-max} {
@include media($xxlarge) {
width: flex-grid($i, $grid-max);
}
}
}
}
@for $i from 1 through 12 {
@include grid__columns-of-columns($i);
}
// Shift Classes
@mixin grid__offset($grid-max: 11) {
@for $i from 1 through $grid-max {
.small-offset-#{$i} {
@include shift($i);
}
.medium-offset-#{$i} {
@include media($medium-up) {
@include shift($i);
}
}
.large-offset-#{$i} {
@include media($large-up) {
@include shift($i);
}
}
.xlarge-offset-#{$i} {
@include media($xlarge-up) {
@include shift($i);
}
}
.xxlarge-offset-#{$i} {
@include media($xxlarge) {
@include shift($i);
}
}
}
}
@include grid__offset(11);
// Shift Classes
@mixin grid__offset-of-columns($grid-max: 12) {
@for $i from 1 through $grid-max {
.small-offset-#{$i}of#{$grid-max} {
@include shift-in-context($i of $grid-max);
}
.medium-offset-#{$i}of#{$grid-max} {
@include media($medium-up) {
@include shift-in-context($i of $grid-max);
}
}
.large-offset-#{$i}of#{$grid-max} {
@include media($large-up) {
@include shift-in-context($i of $grid-max);
}
}
.xlarge-offset-#{$i}of#{$grid-max} {
@include media($xlarge-up) {
@include shift-in-context($i of $grid-max);
}
}
.xxlarge-offset-#{$i}of#{$grid-max} {
@include media($xxlarge) {
@include shift-in-context($i of $grid-max);
}
}
}
}
@for $i from 1 through 12 {
@include grid__offset-of-columns($i);
}
@ExByt3s
Copy link

ExByt3s commented May 3, 2016

nice :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment