-
Notifications
You must be signed in to change notification settings - Fork 0
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
Black Mirror
committed
Feb 15, 2018
1 parent
42d41f1
commit 0e891b8
Showing
4 changed files
with
52 additions
and
76 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,186 +1,160 @@ | ||
$display-modes: array-append((none, inline, block, inline-block, flex, inline-flex, table, inline-table, table-caption, table-header-group, table-row-group, table-column-group, table-footer-group, table-row, table-column, table-cell, list-item, run-in), $css-default-modes); | ||
|
||
@function is-display-mode($dm) { | ||
@return contains($display-modes, $dm); | ||
@return contains($display-modes, $dm); | ||
} | ||
|
||
@mixin display($dm) { | ||
@if is-defined($dm) and is-display-mode($dm) { | ||
@if is-defined($dm) and is-display-mode($dm){ | ||
display: $dm; | ||
} @else { | ||
@warn '`#{$dm}` is not a valid display mode'; | ||
} | ||
@else { | ||
@warn '`display: #{$dm}` is not a valid display mode'; | ||
} | ||
} | ||
|
||
$box-sizes: array-append((auto), $css-default-modes); | ||
|
||
@function is-box-size($s) { | ||
@return is-size($s) or contains($box-sizes, $s); | ||
@return is-size($s) or contains($box-sizes, $s); | ||
} | ||
|
||
$bound-box-sizes: array-append((none), $css-default-modes); | ||
|
||
@function is-bound-box-size($s) { | ||
@return is-size($s) or contains($bound-box-sizes, $s); | ||
@return is-size($s) or contains($bound-box-sizes, $s); | ||
} | ||
|
||
@mixin box-shadow($shadows...) { | ||
-webkit-box-shadow: $shadows; | ||
-moz-box-shadow: $shadows; | ||
box-shadow: $shadows; | ||
} | ||
|
||
@mixin box-size($options, $height-fallback: true) { | ||
$settings: ( | ||
width: null, | ||
height: null, | ||
min-width: null, | ||
min-height: null, | ||
max-width: null, | ||
max-height: null | ||
); | ||
|
||
$settings: ( width: null, height: null, min-width: null, min-height: null, max-width: null, max-height: null ); | ||
@if is-object($options) { | ||
$settings: extend($settings, $options); | ||
} @else { | ||
$settings:extend($settings, $options); | ||
} | ||
@else { | ||
$width: if(length($options) > 0, nth($options, 1), null); | ||
|
||
@if is-defined($width) { | ||
$settings: map-merge($settings, (width: $width)); | ||
} | ||
|
||
$height: if(length($options) > 1, nth($options, 2), null); | ||
|
||
@if is-defined($height) { | ||
$settings: map-merge($settings, (height: $height)); | ||
} | ||
|
||
$min-width: if(length($options) > 2, nth($options, 3), null); | ||
|
||
@if is-defined($min-width) { | ||
$settings: map-merge($settings, (min-width: $min-width)); | ||
} | ||
|
||
$max-width: if(length($options) > 3, nth($options, 4), null); | ||
|
||
@if is-defined($max-width) { | ||
$settings: map-merge($settings, (max-width: $max-width)); | ||
} | ||
|
||
$min-height: if(length($options) > 3, nth($options, 4), null); | ||
|
||
@if is-defined($min-height) { | ||
$settings: map-merge($settings, (min-height: $min-height)); | ||
} | ||
|
||
$max-height: if(length($options) > 4, nth($options, 5), null); | ||
|
||
@if is-defined($max-height) { | ||
$settings: map-merge($settings, (max-height: $max-height)); | ||
} | ||
} | ||
|
||
$width: map-get($settings, width); | ||
|
||
@if is-defined($width) { | ||
@if is-box-size($width) { | ||
@if is-box-size($width){ | ||
width: $width; | ||
} @else { | ||
@warn '`#{$width}` is not a valid size'; | ||
} | ||
@else { | ||
@warn '`width: #{$width}` is not a valid size'; | ||
} | ||
} | ||
|
||
$height: map-get($settings, height); | ||
|
||
@if $height-fallback == true and is-defined($width) and not is-defined($height) { | ||
$height: $width; | ||
} | ||
|
||
@if is-defined($height) { | ||
@if is-box-size($height) { | ||
@if is-box-size($height){ | ||
height: $height; | ||
} @else { | ||
@warn '`#{$width}` is not a valid size'; | ||
} | ||
@else { | ||
@warn '`height: #{$height}` is not a valid size'; | ||
} | ||
} | ||
|
||
$min-width: map-get($settings, min-width); | ||
|
||
@if is-defined($min-width) { | ||
@if is-bound-box-size($min-width) { | ||
@if is-bound-box-size($min-width){ | ||
min-width: $min-width; | ||
} @else { | ||
@warn '`#{$min-width}` is not a valid size'; | ||
} | ||
@else { | ||
@warn '`min-width: #{$min-width}` is not a valid size'; | ||
} | ||
} | ||
|
||
$min-height: map-get($settings, min-height); | ||
|
||
@if is-defined($min-height) { | ||
@if is-bound-box-size($min-height) { | ||
@if is-bound-box-size($min-height){ | ||
min-height: $min-height; | ||
} @else { | ||
@warn '`#{$min-height}` is not a valid size'; | ||
} | ||
@else { | ||
@warn '`min-height: #{$min-height}` is not a valid size'; | ||
} | ||
} | ||
|
||
$max-width: map-get($settings, max-width); | ||
|
||
@if is-defined($max-width) { | ||
@if is-bound-box-size($max-width) { | ||
@if is-bound-box-size($max-width){ | ||
max-width: $max-width; | ||
} @else { | ||
@warn '`max-width: #{$max-width}` is not a valid size'; | ||
} | ||
@else { | ||
@warn '`max-width: #{$max-width}` is not a valid size'; | ||
} | ||
} | ||
|
||
$max-height: map-get($settings, max-height); | ||
|
||
@if is-defined($max-height) { | ||
@if is-bound-box-size($max-height) { | ||
@if is-bound-box-size($max-height){ | ||
max-height: $max-height; | ||
} @else { | ||
@warn '`max-height: #{$max-height}` is not a valid size'; | ||
} | ||
@else { | ||
@warn '`max-height: #{$max-height}` is not a valid size'; | ||
} | ||
} | ||
} | ||
|
||
@mixin box-color($options) { | ||
$settings: ( | ||
color: inherit, | ||
bgcolor: inherit, | ||
); | ||
|
||
$settings: ( color: inherit, bgcolor: inherit, ); | ||
@if is-object($options) { | ||
$settings: extend($settings, $options); | ||
} @else { | ||
$settings:extend($settings, $options); | ||
} | ||
@else { | ||
$color: if(length($options) > 0, nth($options, 1), null); | ||
|
||
@if is-defined($color) { | ||
$settings: map-merge($settings, (color: $color)); | ||
} | ||
|
||
$bgcolor: if(length($options) > 1, nth($options, 2), null); | ||
|
||
@if is-defined($bgcolor) { | ||
$settings: map-merge($settings, (bgcolor: $bgcolor)); | ||
} | ||
} | ||
|
||
$color: map-get($settings, color); | ||
|
||
@if is-css-color($color) { | ||
color: $color; | ||
} @else { | ||
@warn '`color: #{$color}` is not a valid css color'; | ||
} | ||
@else { | ||
@warn '`color: #{$color}` is not a valid css color'; | ||
} | ||
|
||
$bgcolor: map-get($settings, bgcolor); | ||
|
||
@if is-css-color($bgcolor) { | ||
background-color: $bgcolor; | ||
} @else { | ||
@warn '`bgcolor: #{$bgcolor}` is not a valid css color'; | ||
} | ||
@else { | ||
@warn '`background-color: #{$bgcolor}` is not a valid css color'; | ||
} | ||
} | ||
|
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