use sass to remove repetition in flexboxgrid.scss

this just rewrites flexboxgrid.scss to take
advantage of sass's features. it outputs exactly
the same css, just with less lines of source.

Change-Id: Ie201c3bd762c294969e7b25a230cdf23cce7a813
Reviewed-on: https://gerrit.instructure.com/40623
Tested-by: Jenkins <jenkins@instructure.com>
Reviewed-by: Chris Hart <chart@instructure.com>
Product-Review: Ryan Shaw <ryan@instructure.com>
QA-Review: Ryan Shaw <ryan@instructure.com>
This commit is contained in:
Ryan Shaw 2014-09-04 17:39:58 -06:00
parent 3b267b559b
commit e269eb0781
1 changed files with 57 additions and 750 deletions

View File

@ -165,6 +165,55 @@ Never miss another game of foosball. Just let the grid evenly distribute your el
*/
$c-grid-sp: 16px;
$c-grid-columns: 12;
@mixin grid-for-size($size) {
%base-#{$size} {
box-sizing: border-box;
display: flex;
flex-direction: column;
flex-grow: 0;
flex-shrink: 0;
padding-right: $c-grid-sp;
padding-left: $c-grid-sp;
}
.col-#{$size} {
@extend %base-#{$size};
flex-grow: 1;
flex-basis: 0;
max-width: 100%;
}
@for $i from 1 through $c-grid-columns {
$width: percentage($i/$c-grid-columns);
.col-#{$size}-#{$i} {
@extend %base-#{$size};
flex-basis: $width;
max-width: $width;
}
.off-#{$size}-#{$i} {
@extend %base-#{$size};
@if $i != $c-grid-columns {
margin-left: $width;
}
}
}
.start-#{$size} { justify-content: flex-start; text-align: start; }
.center-#{$size} { justify-content: center; text-align: center; }
.end-#{$size} { justify-content: flex-end; text-align: end; }
.top-#{$size} { align-items: flex-start; }
.middle-#{$size} { align-items: center; }
.bottom-#{$size} { align-items: flex-end; }
.around-#{$size} { justify-content: space-around; }
.between-#{$size} { justify-content: space-between; }
.first-#{$size} { order: -1; }
.last-#{$size} { order: 1; }
}
.grid-row {
box-sizing: border-box;
@ -173,11 +222,11 @@ $c-grid-sp: 16px;
flex-wrap: wrap;
margin-right: -$c-grid-sp;
margin-left: -$c-grid-sp;
}
.grid-row.reverse {
flex-direction: row-reverse;
flex-wrap: row-reverse;
&.reverse {
flex-direction: row-reverse;
flex-wrap: row-reverse;
}
}
.col.reverse {
@ -185,758 +234,16 @@ $c-grid-sp: 16px;
flex-wrap: column-reverse;
}
.col-xs,
.col-xs-1,
.col-xs-2,
.col-xs-3,
.col-xs-4,
.col-xs-5,
.col-xs-6,
.col-xs-7,
.col-xs-8,
.col-xs-9,
.col-xs-10,
.col-xs-11,
.col-xs-12,
.off-xs-1,
.off-xs-2,
.off-xs-3,
.off-xs-4,
.off-xs-5,
.off-xs-6,
.off-xs-7,
.off-xs-8,
.off-xs-9,
.off-xs-10,
.off-xs-11,
.off-xs-12 {
box-sizing: border-box;
display: flex;
flex-direction: column;
flex-grow: 0;
flex-shrink: 0;
padding-right: $c-grid-sp;
padding-left: $c-grid-sp;
}
.col-xs {
flex-grow: 1;
flex-basis: 0;
max-width: 100%;
}
.col-xs-1 {
flex-basis: 8.333333333%;
max-width: 8.333333333%;
}
.col-xs-2 {
flex-basis: 16.666666667%;
max-width: 16.666666667%;
}
.col-xs-3 {
flex-basis: 25%;
max-width: 25%;
}
.col-xs-4 {
flex-basis: 33.333333333%;
max-width: 33.333333333%;
}
.col-xs-5 {
flex-basis: 41.666666667%;
max-width: 41.666666667%;
}
.col-xs-6 {
flex-basis: 50%;
max-width: 50%;
}
.col-xs-7 {
flex-basis: 58.333333333%;
max-width: 58.333333333%;
}
.col-xs-8 {
flex-basis: 66.666666667%;
max-width: 66.666666667%;
}
.col-xs-9 {
flex-basis: 75%;
max-width: 75%;
}
.col-xs-10 {
flex-basis: 83.333333333%;
max-width: 83.333333333%;
}
.col-xs-11 {
flex-basis: 91.666666667%;
max-width: 91.666666667%;
}
.col-xs-12 {
flex-basis: 100%;
max-width: 100%;
}
.off-xs-1 {
margin-left: 8.333333333%;
}
.off-xs-2 {
margin-left: 16.666666667%;
}
.off-xs-3 {
margin-left: 25%;
}
.off-xs-4 {
margin-left: 33.333333333%;
}
.off-xs-5 {
margin-left: 41.666666667%;
}
.off-xs-6 {
margin-left: 50%;
}
.off-xs-7 {
margin-left: 58.333333333%;
}
.off-xs-8 {
margin-left: 66.666666667%;
}
.off-xs-9 {
margin-left: 75%;
}
.off-xs-10 {
margin-left: 83.333333333%;
}
.off-xs-11 {
margin-left: 91.666666667%;
}
.start-xs {
justify-content: flex-start;
text-align: start;
}
.center-xs {
justify-content: center;
text-align: center;
}
.end-xs {
justify-content: flex-end;
text-align: end;
}
.top-xs {
align-items: flex-start;
}
.middle-xs {
align-items: center;
}
.bottom-xs {
align-items: flex-end;
}
.around-xs {
justify-content: space-around;
}
.between-xs {
justify-content: space-between;
}
.first-xs {
order: -1;
}
.last-xs {
order: 1;
}
@include grid-for-size('xs');
@media only screen and (min-width: 48em) {
.col-sm,
.col-sm-1,
.col-sm-2,
.col-sm-3,
.col-sm-4,
.col-sm-5,
.col-sm-6,
.col-sm-7,
.col-sm-8,
.col-sm-9,
.col-sm-10,
.col-sm-11,
.col-sm-12,
.off-sm-1,
.off-sm-2,
.off-sm-3,
.off-sm-4,
.off-sm-5,
.off-sm-6,
.off-sm-7,
.off-sm-8,
.off-sm-9,
.off-sm-10,
.off-sm-11,
.off-sm-12 {
box-sizing: border-box;
display: flex;
flex-direction: column;
flex-grow: 0;
flex-shrink: 0;
padding-right: $c-grid-sp;
padding-left: $c-grid-sp;
}
.col-sm {
flex-grow: 1;
flex-basis: 0;
max-width: 100%;
}
.col-sm-1 {
flex-basis: 8.333333333%;
max-width: 8.333333333%;
}
.col-sm-2 {
flex-basis: 16.666666667%;
max-width: 16.666666667%;
}
.col-sm-3 {
flex-basis: 25%;
max-width: 25%;
}
.col-sm-4 {
flex-basis: 33.333333333%;
max-width: 33.333333333%;
}
.col-sm-5 {
flex-basis: 41.666666667%;
max-width: 41.666666667%;
}
.col-sm-6 {
flex-basis: 50%;
max-width: 50%;
}
.col-sm-7 {
flex-basis: 58.333333333%;
max-width: 58.333333333%;
}
.col-sm-8 {
flex-basis: 66.666666667%;
max-width: 66.666666667%;
}
.col-sm-9 {
flex-basis: 75%;
max-width: 75%;
}
.col-sm-10 {
flex-basis: 83.333333333%;
max-width: 83.333333333%;
}
.col-sm-11 {
flex-basis: 91.666666667%;
max-width: 91.666666667%;
}
.col-sm-12 {
flex-basis: 100%;
max-width: 100%;
}
.off-sm-1 {
margin-left: 8.333333333%;
max-width: 8.333333333%;
}
.off-sm-2 {
margin-left: 16.666666667%;
max-width: 16.666666667%;
}
.off-sm-3 {
margin-left: 25%;
}
.off-sm-4 {
margin-left: 33.333333333%;
}
.off-sm-5 {
margin-left: 41.666666667%;
}
.off-sm-6 {
margin-left: 50%;
}
.off-sm-7 {
margin-left: 58.333333333%;
}
.off-sm-8 {
margin-left: 66.666666667%;
}
.off-sm-9 {
margin-left: 75%;
}
.off-sm-10 {
margin-left: 83.333333333%;
}
.off-sm-11 {
margin-left: 91.666666667%;
}
.start-sm {
justify-content: flex-start;
text-align: start;
}
.center-sm {
justify-content: center;
text-align: center;
}
.end-sm {
justify-content: flex-end;
text-align: end;
}
.top-sm {
align-items: flex-start;
}
.middle-sm {
align-items: center;
}
.bottom-sm {
align-items: flex-end;
}
.around-sm {
justify-content: space-around;
}
.between-sm {
justify-content: space-between;
}
.first-sm {
order: -1;
}
.last-sm {
order: 1;
}
@include grid-for-size('sm');
}
@media only screen and (min-width: 62em) {
.col-md,
.col-md-1,
.col-md-2,
.col-md-3,
.col-md-4,
.col-md-5,
.col-md-6,
.col-md-7,
.col-md-8,
.col-md-9,
.col-md-10,
.col-md-11,
.col-md-12,
.off-md-1,
.off-md-2,
.off-md-3,
.off-md-4,
.off-md-5,
.off-md-6,
.off-md-7,
.off-md-8,
.off-md-9,
.off-md-10,
.off-md-11,
.off-md-12 {
box-sizing: border-box;
display: flex;
flex-direction: column;
flex-grow: 0;
flex-shrink: 0;
padding-right: $c-grid-sp;
padding-left: $c-grid-sp;
}
.col-md {
flex-grow: 1;
flex-basis: 0;
max-width: 100%;
}
.col-md-1 {
flex-basis: 8.333333333%;
max-width: 8.333333333%;
}
.col-md-2 {
flex-basis: 16.666666667%;
max-width: 16.666666667%;
}
.col-md-3 {
flex-basis: 25%;
max-width: 25%;
}
.col-md-4 {
flex-basis: 33.333333333%;
max-width: 33.333333333%;
}
.col-md-5 {
flex-basis: 41.666666667%;
max-width: 41.666666667%;
}
.col-md-6 {
flex-basis: 50%;
max-width: 50%;
}
.col-md-7 {
flex-basis: 58.333333333%;
max-width: 58.333333333%;
}
.col-md-8 {
flex-basis: 66.666666667%;
max-width: 66.666666667%;
}
.col-md-9 {
flex-basis: 75%;
max-width: 75%;
}
.col-md-10 {
flex-basis: 83.333333333%;
max-width: 83.333333333%;
}
.col-md-11 {
flex-basis: 91.666666667%;
max-width: 91.666666667%;
}
.col-md-12 {
flex-basis: 100%;
max-width: 100%;
}
.off-md-1 {
margin-left: 8.333333333%;
}
.off-md-2 {
margin-left: 16.666666667%;
}
.off-md-3 {
margin-left: 25%;
}
.off-md-4 {
margin-left: 33.333333333%;
}
.off-md-5 {
margin-left: 41.666666667%;
}
.off-md-6 {
margin-left: 50%;
}
.off-md-7 {
margin-left: 58.333333333%;
}
.off-md-8 {
margin-left: 66.666666667%;
}
.off-md-9 {
margin-left: 75%;
}
.off-md-10 {
margin-left: 83.333333333%;
}
.off-md-11 {
margin-left: 91.666666667%;
}
.start-md {
justify-content: flex-start;
text-align: start;
}
.center-md {
justify-content: center;
text-align: center;
}
.end-md {
justify-content: flex-end;
text-align: end;
}
.top-md {
align-items: flex-start;
}
.middle-md {
align-items: center;
}
.bottom-md {
align-items: flex-end;
}
.around-md {
justify-content: space-around;
}
.between-md {
justify-content: space-between;
}
.first-md {
order: -1;
}
.last-md {
order: 1;
}
@include grid-for-size('md');
}
@media only screen and (min-width: 75em) {
.col-lg,
.col-lg-1,
.col-lg-2,
.col-lg-3,
.col-lg-4,
.col-lg-5,
.col-lg-6,
.col-lg-7,
.col-lg-8,
.col-lg-9,
.col-lg-10,
.col-lg-11,
.col-lg-12,
.off-lg-1,
.off-lg-2,
.off-lg-3,
.off-lg-4,
.off-lg-5,
.off-lg-6,
.off-lg-7,
.off-lg-8,
.off-lg-9,
.off-lg-10,
.off-lg-11,
.off-lg-12 {
box-sizing: border-box;
display: flex;
flex-direction: column;
flex-grow: 0;
flex-shrink: 0;
padding-right: $c-grid-sp;
padding-left: $c-grid-sp;
}
.col-lg {
flex-grow: 1;
flex-basis: 0;
max-width: 100%;
}
.col-lg-1 {
flex-basis: 8.333333333%;
max-width: 8.333333333%;
}
.col-lg-2 {
flex-basis: 16.666666667%;
max-width: 16.666666667%;
}
.col-lg-3 {
flex-basis: 25%;
max-width: 25%;
}
.col-lg-4 {
flex-basis: 33.333333333%;
max-width: 33.333333333%;
}
.col-lg-5 {
flex-basis: 41.666666667%;
max-width: 41.666666667%;
}
.col-lg-6 {
flex-basis: 50%;
max-width: 50%;
}
.col-lg-7 {
flex-basis: 58.333333333%;
max-width: 58.333333333%;
}
.col-lg-8 {
flex-basis: 66.666666667%;
max-width: 66.666666667%;
}
.col-lg-9 {
flex-basis: 75%;
max-width: 75%;
}
.col-lg-10 {
flex-basis: 83.333333333%;
max-width: 83.333333333%;
}
.col-lg-11 {
flex-basis: 91.666666667%;
max-width: 91.666666667%;
}
.col-lg-12 {
flex-basis: 100%;
max-width: 100%;
}
.off-lg-1 {
margin-left: 8.333333333%;
}
.off-lg-2 {
margin-left: 16.666666667%;
}
.off-lg-3 {
margin-left: 25%;
}
.off-lg-4 {
margin-left: 33.333333333%;
}
.off-lg-5 {
margin-left: 41.666666667%;
}
.off-lg-6 {
margin-left: 50%;
}
.off-lg-7 {
margin-left: 58.333333333%;
}
.off-lg-8 {
margin-left: 66.666666667%;
}
.off-lg-9 {
margin-left: 75%;
}
.off-lg-10 {
margin-left: 83.333333333%;
}
.off-lg-11 {
margin-left: 91.666666667%;
}
.start-lg {
justify-content: flex-start;
text-align: start;
}
.center-lg {
justify-content: center;
text-align: center;
}
.end-lg {
justify-content: flex-end;
text-align: end;
}
.top-lg {
align-items: flex-start;
}
.middle-lg {
align-items: center;
}
.bottom-lg {
align-items: flex-end;
}
.around-lg {
justify-content: space-around;
}
.between-lg {
justify-content: space-between;
}
.first-lg {
order: -1;
}
.last-lg {
order: 1;
}
@include grid-for-size('lg');
}