-
Notifications
You must be signed in to change notification settings - Fork 5
Open
Labels
Description
Forked a SCSS flexbox-grid from http://flexboxgrid.com/ 's issues.
It would be cool to add it to the base styles!
I fixed names to be injectable in wok without actually breaking anything and to use wok's breakpoints!
(Though it could need a check!)
// containers
.l-flex-container,
.l-flex-container-fluid {
margin-right: auto;
margin-left: auto;
}
.l-flex--container-fluid {
padding-right: 2rem;
padding-left: 2rem;
}
// rows
.l-flex-row {
display: flex;
flex-direction: row;
flex: 0 1 auto;
flex-wrap: wrap;
box-sizing: border-box;
margin-right: -0.5rem;
margin-left: -0.5rem;
}
.l-flex-row.reverse {
flex-direction: row-reverse;
}
.l-flex-col.reverse {
flex-direction: column-reverse;
}
// column helpers
@mixin col-offset($flex-column) {
margin-left: 100% / 12 * $flex-column;
}
@mixin col-numbered($flex-column) {
flex-basis: 100% / 12 * $flex-column;
max-width: 100% / 12 * $flex-column;
}
@mixin break($mq-key) {
@if $mq-key {
@include mq($mq-key) { @content; }
}
@else {
@content;
}
}
// build columns for each size is sizes map
@each $mq-size, $mq-key in $mq-breakpoints {
@include break($mq-key) {
%col-base-#{$mq-size} {
box-sizing: border-box;
flex: 0 0 auto;
padding-right: 0.5rem;
padding-left: 0.5rem;
}
%col-auto-#{$mq-size} {
flex-grow: 1;
flex-basis: 0;
max-width: 100%;
}
.l-flex-col--#{$mq-size} {
@extend %col-base-#{$mq-size};
@extend %col-auto-#{$mq-size};
}
@for $num from 0 through 12 {
.l-flex-col--#{$mq-size}-offset-#{$num} {
@extend %col-base-#{$mq-size};
@include col-offset($num);
}
}
@for $num from 1 through 12 {
.l-flex-col--#{$mq-size}-#{$num} {
@extend %col-base-#{$mq-size};
@include col-numbered($num);
}
}
.start-#{$mq-size} {
justify-content: flex-start;
text-align: start;
}
.center-#{$mq-size} {
justify-content: center;
text-align: center;
}
.end-#{$mq-size} {
justify-content: flex-end;
text-align: end;
}
.top-#{$mq-size} {
align-items: flex-start;
}
.middle-#{$mq-size} {
align-items: center;
}
.bottom-#{$mq-size} {
align-items: flex-end;
}
.around-#{$mq-size} {
justify-content: space-around;
}
.between-#{$mq-size} {
justify-content: space-between;
}
.first-#{$mq-size} {
order: -1;
}
.last-#{$mq-size} {
order: 1;
}
}
}