Skip to content

Commit

Permalink
updated warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
Black Mirror committed Feb 15, 2018
1 parent 42d41f1 commit 0e891b8
Show file tree
Hide file tree
Showing 4 changed files with 52 additions and 76 deletions.
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "flavor-scss",
"version": "0.1.0",
"description": "FlavorJS the definitive JS natives chainable extensions methods (based on lodash & ES6)",
"description": "Flavor SCSS, bourbon.io based mixins & helpers",
"main": "scss/flavor.scss",
"scripts": {
"readme": "pkg-2-readme package.json > README.md -t \"./pkg-2-readme.template.md\" && echo 'README.md file built'",
Expand Down Expand Up @@ -30,4 +30,4 @@
"bourbon": "^5.0.0",
"sass-lint": "^1.12.1"
}
}
}
2 changes: 1 addition & 1 deletion scss/mixins/_border.scss
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ $border-modes: array-append((none), $css-default-modes);
@if is-border-style($border-style) {
$border: append($border, $border-style);
} @else {
@warn '`border-style: #{$border-style}` is not a valid border style value';
@warn '`border-style: #{$border-style}` is not a valid border-style value';
}

$border-color: map-get($settings, color);
Expand Down
116 changes: 45 additions & 71 deletions scss/mixins/_box.scss
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';
}
}

6 changes: 4 additions & 2 deletions scss/mixins/mixins.scss
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
@import 'border';
@import 'media';
@import 'transform';

//outline
@mixin outline($outline) {
outline: $outline;

Expand All @@ -14,8 +16,9 @@
outline: $outline;
}
}

// aspect-ratio
@mixin aspect-ratio($width, $height, $content-selector: '.content') {
// @mixin aspect-ratio($width, $height) {
display: block;
position: relative;

Expand All @@ -26,7 +29,6 @@
width: 100%;
}

> .item,
> #{$content-selector} {
@include position(absolute, 0 0 0 0);
}
Expand Down

0 comments on commit 0e891b8

Please sign in to comment.