-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(grid): Fixes maxwidths and gutters, adds storybook example (#13)
* fix(grid): Fixes maxwidths and gutters, adds storybook example * tweaks * adds fancy colors * prefix classes * prefix grid classes
- Loading branch information
1 parent
8184f8e
commit 5a21dbd
Showing
17 changed files
with
590 additions
and
72 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
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 |
---|---|---|
@@ -0,0 +1,29 @@ | ||
/*! | ||
* Bootstrap Grid v4.2.1 (https://getbootstrap.com/) | ||
* Copyright 2011-2018 The Bootstrap Authors | ||
* Copyright 2011-2018 Twitter, Inc. | ||
* Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE) | ||
*/ | ||
|
||
html { | ||
box-sizing: border-box; | ||
-ms-overflow-style: scrollbar; | ||
} | ||
|
||
*, | ||
*::before, | ||
*::after { | ||
box-sizing: inherit; | ||
} | ||
|
||
@import '../../global/functions'; | ||
@import '../../global/variables'; | ||
|
||
@import './mixins/breakpoints'; | ||
@import './mixins/grid-framework'; | ||
@import './mixins/grid'; | ||
|
||
@import './grid'; | ||
// @import 'utilities/display'; | ||
// @import 'utilities/flex'; | ||
// @import 'utilities/spacing'; |
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 |
---|---|---|
@@ -0,0 +1,78 @@ | ||
// Copyright Twitter Bootstrap | ||
// Framework grid generation | ||
// | ||
// Used only by Bootstrap to generate the correct number of grid classes given | ||
// any value of `$grid-columns`. | ||
|
||
@mixin make-grid-columns( | ||
$columns: $grid-columns, | ||
$gutter: $grid-gutter-width, | ||
$breakpoints: $grid-breakpoints | ||
) { | ||
// Common properties for all breakpoints | ||
%grid-column { | ||
position: relative; | ||
width: 100%; | ||
padding-right: $gutter / 2; | ||
padding-left: $gutter / 2; | ||
} | ||
|
||
@each $breakpoint in map-keys($breakpoints) { | ||
$infix: breakpoint-infix($breakpoint, $breakpoints); | ||
|
||
// Allow columns to stretch full width below their breakpoints | ||
@for $i from 1 through $columns { | ||
.#{$prefix}col#{$infix}-#{$i} { | ||
@extend %grid-column; | ||
} | ||
} | ||
.#{$prefix}col#{$infix}, | ||
.#{$prefix}col#{$infix}-auto { | ||
@extend %grid-column; | ||
} | ||
|
||
@include media-breakpoint-up($breakpoint, $breakpoints) { | ||
// Provide basic `.col-{bp}` classes for equal-width flexbox columns | ||
.#{$prefix}col#{$infix} { | ||
flex-basis: 0; | ||
flex-grow: 1; | ||
max-width: 100%; | ||
} | ||
.#{$prefix}col#{$infix}-auto { | ||
flex: 0 0 auto; | ||
width: auto; | ||
max-width: 100%; // Reset earlier grid tiers | ||
} | ||
|
||
@for $i from 1 through $columns { | ||
.#{$prefix}col#{$infix}-#{$i} { | ||
@include make-col($i, $columns); | ||
} | ||
} | ||
|
||
.#{$prefix}order#{$infix}-first { | ||
order: -1; | ||
} | ||
|
||
.#{$prefix}order#{$infix}-last { | ||
order: $columns + 1; | ||
} | ||
|
||
@for $i from 0 through $columns { | ||
.#{$prefix}order#{$infix}-#{$i} { | ||
order: $i; | ||
} | ||
} | ||
|
||
// `$columns - 1` because offsetting by the width of an entire row isn't possible | ||
@for $i from 0 through ($columns - 1) { | ||
@if not($infix == '' and $i == 0) { | ||
// Avoid emitting useless .offset-0 | ||
.#{$prefix}offset#{$infix}-#{$i} { | ||
@include make-col-offset($i, $columns); | ||
} | ||
} | ||
} | ||
} | ||
} | ||
} |
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 |
---|---|---|
@@ -0,0 +1,52 @@ | ||
// Container widths | ||
// | ||
// Set the container width, and override it for fixed navbars in media queries. | ||
|
||
@if $enable-grid-classes { | ||
.#{$prefix}container { | ||
@include make-container(); | ||
@include make-container-max-widths(); | ||
} | ||
} | ||
|
||
// Fluid container | ||
// | ||
// Utilizes the mixin meant for fixed width containers, but with 100% width for | ||
// fluid, full width layouts. | ||
|
||
@if $enable-grid-classes { | ||
.#{$prefix}container-fluid { | ||
@include make-container(); | ||
} | ||
} | ||
|
||
// Row | ||
// | ||
// Rows contain and clear the floats of your columns. | ||
|
||
@if $enable-grid-classes { | ||
.#{$prefix}row { | ||
@include make-row(); | ||
} | ||
|
||
// Remove the negative margin from default .row, then the horizontal padding | ||
// from all immediate children columns (to prevent runaway style inheritance). | ||
.#{$prefix}no-gutters { | ||
margin-right: 0; | ||
margin-left: 0; | ||
|
||
> .col, | ||
> [class*='col-'] { | ||
padding-right: 0; | ||
padding-left: 0; | ||
} | ||
} | ||
} | ||
|
||
// Columns | ||
// | ||
// Common styles for small and large grid columns | ||
|
||
@if $enable-grid-classes { | ||
@include make-grid-columns(); | ||
} |
135 changes: 135 additions & 0 deletions
135
packages/ray/lib/components/grid/mixins/_breakpoints.scss
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 |
---|---|---|
@@ -0,0 +1,135 @@ | ||
// Breakpoint viewport sizes and media queries. | ||
// | ||
// Breakpoints are defined as a map of (name: minimum width), order from small to large: | ||
// | ||
// (xs: 0, sm: 576px, md: 768px, lg: 992px, xl: 1200px) | ||
// | ||
// The map defined in the `$grid-breakpoints` global variable is used as the `$breakpoints` argument by default. | ||
|
||
// Name of the next breakpoint, or null for the last breakpoint. | ||
// | ||
// >> breakpoint-next(sm) | ||
// md | ||
// >> breakpoint-next(sm, (xs: 0, sm: 576px, md: 768px, lg: 992px, xl: 1200px)) | ||
// md | ||
// >> breakpoint-next(sm, $breakpoint-names: (xs sm md lg xl)) | ||
// md | ||
@function breakpoint-next( | ||
$name, | ||
$breakpoints: $grid-breakpoints, | ||
$breakpoint-names: map-keys($breakpoints) | ||
) { | ||
$n: index($breakpoint-names, $name); | ||
@return if( | ||
$n != null and $n < length($breakpoint-names), | ||
nth($breakpoint-names, $n + 1), | ||
null | ||
); | ||
} | ||
|
||
// Minimum breakpoint width. Null for the smallest (first) breakpoint. | ||
// | ||
// >> breakpoint-min(sm, (xs: 0, sm: 576px, md: 768px, lg: 992px, xl: 1200px)) | ||
// 576px | ||
@function breakpoint-min($name, $breakpoints: $grid-breakpoints) { | ||
$min: map-get($breakpoints, $name); | ||
@return if($min != 0, $min, null); | ||
} | ||
|
||
// Maximum breakpoint width. Null for the largest (last) breakpoint. | ||
// The maximum value is calculated as the minimum of the next one less 0.02px | ||
// to work around the limitations of `min-` and `max-` prefixes and viewports with fractional widths. | ||
// See https://www.w3.org/TR/mediaqueries-4/#mq-min-max | ||
// Uses 0.02px rather than 0.01px to work around a current rounding bug in Safari. | ||
// See https://bugs.webkit.org/show_bug.cgi?id=178261 | ||
// | ||
// >> breakpoint-max(sm, (xs: 0, sm: 576px, md: 768px, lg: 992px, xl: 1200px)) | ||
// 767.98px | ||
@function breakpoint-max($name, $breakpoints: $grid-breakpoints) { | ||
$next: breakpoint-next($name, $breakpoints); | ||
@return if($next, breakpoint-min($next, $breakpoints) - 0.02, null); | ||
} | ||
|
||
// Returns a blank string if smallest breakpoint, otherwise returns the name with a dash in front. | ||
// Useful for making responsive utilities. | ||
// | ||
// >> breakpoint-infix(xs, (xs: 0, sm: 576px, md: 768px, lg: 992px, xl: 1200px)) | ||
// "" (Returns a blank string) | ||
// >> breakpoint-infix(sm, (xs: 0, sm: 576px, md: 768px, lg: 992px, xl: 1200px)) | ||
// "-sm" | ||
@function breakpoint-infix($name, $breakpoints: $grid-breakpoints) { | ||
@return if(breakpoint-min($name, $breakpoints) == null, '', '-#{$name}'); | ||
} | ||
|
||
// Media of at least the minimum breakpoint width. No query for the smallest breakpoint. | ||
// Makes the @content apply to the given breakpoint and wider. | ||
@mixin media-breakpoint-up($name, $breakpoints: $grid-breakpoints) { | ||
$min: breakpoint-min($name, $breakpoints); | ||
@if $min { | ||
@media (min-width: $min) { | ||
@content; | ||
} | ||
} @else { | ||
@content; | ||
} | ||
} | ||
|
||
// Media of at most the maximum breakpoint width. No query for the largest breakpoint. | ||
// Makes the @content apply to the given breakpoint and narrower. | ||
@mixin media-breakpoint-down($name, $breakpoints: $grid-breakpoints) { | ||
$max: breakpoint-max($name, $breakpoints); | ||
@if $max { | ||
@media (max-width: $max) { | ||
@content; | ||
} | ||
} @else { | ||
@content; | ||
} | ||
} | ||
|
||
// Media that spans multiple breakpoint widths. | ||
// Makes the @content apply between the min and max breakpoints | ||
@mixin media-breakpoint-between( | ||
$lower, | ||
$upper, | ||
$breakpoints: $grid-breakpoints | ||
) { | ||
$min: breakpoint-min($lower, $breakpoints); | ||
$max: breakpoint-max($upper, $breakpoints); | ||
|
||
@if $min != null and $max != null { | ||
@media (min-width: $min) and (max-width: $max) { | ||
@content; | ||
} | ||
} @else if $max == null { | ||
@include media-breakpoint-up($lower, $breakpoints) { | ||
@content; | ||
} | ||
} @else if $min == null { | ||
@include media-breakpoint-down($upper, $breakpoints) { | ||
@content; | ||
} | ||
} | ||
} | ||
|
||
// Media between the breakpoint's minimum and maximum widths. | ||
// No minimum for the smallest breakpoint, and no maximum for the largest one. | ||
// Makes the @content apply only to the given breakpoint, not viewports any wider or narrower. | ||
@mixin media-breakpoint-only($name, $breakpoints: $grid-breakpoints) { | ||
$min: breakpoint-min($name, $breakpoints); | ||
$max: breakpoint-max($name, $breakpoints); | ||
|
||
@if $min != null and $max != null { | ||
@media (min-width: $min) and (max-width: $max) { | ||
@content; | ||
} | ||
} @else if $max == null { | ||
@include media-breakpoint-up($name, $breakpoints) { | ||
@content; | ||
} | ||
} @else if $min == null { | ||
@include media-breakpoint-down($name, $breakpoints) { | ||
@content; | ||
} | ||
} | ||
} |
Oops, something went wrong.