-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
c28635a
commit 092930f
Showing
4 changed files
with
197 additions
and
102 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,66 +1,109 @@ | ||
$gutter-size: 10px; | ||
$i: 0; | ||
// map functions | ||
@function breakpoint($breakpoint) { | ||
@if map-has-key($grid-breakpoints, $breakpoint) { | ||
@return map-get($grid-breakpoints, $breakpoint); | ||
} @else { | ||
@warn 'breakpoint: could not find #{$breakpoint} in $grid-breakpoints map. Please make sure it is defined'; | ||
} | ||
} | ||
|
||
@mixin column-size($col-num) { | ||
flex-basis: (100% * $col-num / 12); | ||
max-width: (100% * $col-num / 12); | ||
@function gutter($breakpoint) { | ||
@if map-has-key($gutter-breakpoints, $breakpoint) { | ||
@return map-get($gutter-breakpoints, $breakpoint); | ||
} @else { | ||
@warn 'gutter: could not find #{$breakpoint} in $gutter-breakpoints map. Please make sure it is defined'; | ||
} | ||
} | ||
|
||
@function grid-gutter($breakpoint) { | ||
@if map-has-key($grid-gutter-breakpoints, $breakpoint) { | ||
@return map-get($grid-gutter-breakpoints, $breakpoint); | ||
} @else { | ||
@warn 'grid-gutter: could not find #{$breakpoint} in $grid-breakpoints map. Please make sure it is defined'; | ||
} | ||
} | ||
|
||
$max-width: 1600px; | ||
$columns: 12; | ||
|
||
$grid-breakpoints: (sm: 576px, md: 768px, lg: 992px, xl: 1200px, xxl: 1600px); | ||
$gutter-breakpoints: (xs: 5px, sm: 10px); | ||
$grid-gutter-breakpoints: (xs: 3%, sm: 5%); | ||
|
||
.bx--grid { | ||
margin: 0 3%; | ||
margin-left: grid-gutter('xs'); | ||
margin-right: grid-gutter('xs'); | ||
padding-left: gutter('xs'); | ||
padding-right: gutter('xs'); | ||
|
||
@include breakpoint('bp--xs--major') { | ||
margin: 0 5%; | ||
@media (min-width: breakpoint('sm')) { | ||
margin-left: grid-gutter('sm'); | ||
margin-right: grid-gutter('sm'); | ||
padding-left: gutter('sm'); | ||
padding-right: gutter('sm'); | ||
} | ||
|
||
&.max { | ||
max-width: $max-width; | ||
} | ||
} | ||
|
||
.bx--row { | ||
display: flex; | ||
flex-wrap: wrap; | ||
margin: 0 $gutter-size * -1; | ||
margin: 0 gutter('xs') * -1; | ||
|
||
@media (min-width: breakpoint('sm')) { | ||
margin: 0 gutter('sm') * -1; | ||
} | ||
} | ||
|
||
[class*="bx--col"] { | ||
position: relative; | ||
width: 100%; | ||
min-height: 1px; | ||
padding: 0 $gutter-size; | ||
} | ||
padding: 0 gutter('xs'); | ||
|
||
.bx--col-xs, | ||
.bx--col-sm, | ||
.bx--col-md, | ||
.bx--col-lg { | ||
flex-basis: 0; | ||
flex: 1; | ||
flex-grow: 1; | ||
max-width: 100%; | ||
@media (min-width: breakpoint('sm')) { | ||
padding: 0 gutter('sm'); | ||
} | ||
} | ||
|
||
@while $i <= 12 { | ||
|
||
@for $i from 1 through $columns { | ||
.bx--col-xs-#{$i} { | ||
@include column-size($i); | ||
flex-basis: (100% * $i / $columns); | ||
} | ||
} | ||
|
||
@media (min-width: 720px) { | ||
.bx--col-sm-#{$i} { | ||
@include column-size($i); | ||
@each $breakpoint in map-keys($grid-breakpoints) { | ||
@media (min-width: breakpoint($breakpoint)) { | ||
.bx--col-#{$breakpoint}-auto { | ||
flex: 0 0 auto; | ||
width: auto; | ||
} | ||
} | ||
|
||
@media (min-width: 970px) { | ||
.bx--col-md-#{$i} { | ||
@include column-size($i); | ||
@for $i from 1 through $columns { | ||
.bx--col-#{$breakpoint}-#{$i} { | ||
flex-basis: (100% * $i / $columns); | ||
} | ||
} | ||
} | ||
} | ||
|
||
@media (min-width: 1170px) { | ||
.bx--col-lg-#{$i} { | ||
@include column-size($i); | ||
} | ||
} | ||
// deprecated | ||
$gutter-size: 10px; | ||
|
||
$i: $i + 1; | ||
@mixin column-size($col-num) { | ||
flex-basis: (100% * $col-num / $columns); | ||
max-width: (100% * $col-num / $columns); | ||
} | ||
|
||
.bx--col-xs, | ||
.bx--col-sm, | ||
.bx--col-md, | ||
.bx--col-lg { | ||
flex-basis: 0; | ||
flex: 1; | ||
flex-grow: 1; | ||
max-width: 100%; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,30 +1,24 @@ | ||
<div class="bx--grid"> | ||
<div class="bx--row"> | ||
<div class="bx--col-md-8">.bx--col-md-8</div> | ||
<div class="bx--col-md-4">.bx--col-md-4</div> | ||
<div class="bx--col-xs-12 bx--col-sm-6 indigo"> | ||
<div class="bx--row"> | ||
<div class="bx--col-xs-12 bx--col-sm-6"> | ||
<div class="col-example"> | ||
<p>Content space for bx--col-xs-12 bx--col-sm-6</p> | ||
</div> | ||
</div> | ||
<div class="bx--col-xs-12 bx--col-sm-6 green"> | ||
<p>Full space for bx--col-xs-12 bx--col-sm-6 (columns naturally have padding on them, adding a background color to | ||
the column directly will effect the entire column, as opposed to using a child element in the example to the | ||
left). </p> | ||
</div> | ||
</div> | ||
|
||
<p>Columns also expand to match the vertical size of the rest of the row (see red column)</p> | ||
</div> | ||
<div class="bx--col-xs-12 bx--col-sm-6 red"> | ||
<p>Background color over entire column, not just content space</p> | ||
|
||
</div> | ||
</div> | ||
<div class="bx--row"> | ||
<div class="bx--col-md-4">.bx--col-md-4</div> | ||
<div class="bx--col-md-4">.bx--col-md-4</div> | ||
<div class="bx--col-md-4">.bx--col-md-4</div> | ||
</div> | ||
<div class="bx--row"> | ||
<div class="bx--col-md-3">.bx--col-md-3</div> | ||
<div class="bx--col-md-6">.bx--col-md-6</div> | ||
<div class="bx--col-md-3">.bx--col-md-3</div> | ||
</div> | ||
<div class="bx--row"> | ||
<div class="bx--col-xs-1">.bx--col-xs-1</div> | ||
<div class="bx--col-xs-1">.bx--col-xs-1</div> | ||
<div class="bx--col-xs-1">.bx--col-xs-1</div> | ||
<div class="bx--col-xs-1">.bx--col-xs-1</div> | ||
<div class="bx--col-xs-1">.bx--col-xs-1</div> | ||
<div class="bx--col-xs-1">.bx--col-xs-1</div> | ||
<div class="bx--col-xs-1">.bx--col-xs-1</div> | ||
<div class="bx--col-xs-1">.bx--col-xs-1</div> | ||
<div class="bx--col-xs-1">.bx--col-xs-1</div> | ||
<div class="bx--col-xs-1">.bx--col-xs-1</div> | ||
<div class="bx--col-xs-1">.bx--col-xs-1</div> | ||
<div class="bx--col-xs-1">.bx--col-xs-1</div> | ||
</div> | ||
</div> | ||
</div> |