Skip to content

Commit

Permalink
fixed is-url & is-background-image issue
Browse files Browse the repository at this point in the history
  • Loading branch information
Black Mirror committed Feb 19, 2018
1 parent 451c9c2 commit c2b5bde
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 6 deletions.
2 changes: 1 addition & 1 deletion scss/mixins/_background.scss
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
$background-image-modes: array-append((none), $css-default-modes);

@function is-background-image($bi) {
@return contains($background-image-modes, $bi) or is-url($bi);
@return is-url($bi) or contains($background-image-modes, $bi);
}

$background-position-horizontal-modes: (left, center, right);
Expand Down
14 changes: 9 additions & 5 deletions scss/mixins/_functions.scss
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ $color-modes: array-append((transparent), $css-default-modes);
$h-length: str-length($h);
$n-length: str-length($n);

@return str-slice($h, $h-length - $n-length, $n-length)==$n;
@return str-slice($h, $h-length - $n-length + 1)==$n;
}

@warn '`haystack: #{$h}` and `needle: #{$n}` are not valid strings';
Expand All @@ -83,15 +83,19 @@ $color-modes: array-append((transparent), $css-default-modes);
@if is-string($u) {
$url: $u;

@if string-starts-with($u, 'url(') and string-ends-with($u, ')') {
// $url: str-slice($u, 5, str-length($u) - 1);
// }
$urlStartsWith: string-starts-with($url, 'url("');
$urlEndsWith: string-ends-with($url, '")');

// @if string-starts-with($url, '../') or string-starts-with($url, '/') or string-starts-with($url, 'http') {
@if (string-starts-with($url, 'url("') and string-ends-with($url, '")')) or (string-starts-with($url, 'url(\'') and string-ends-with($url, '\')')) {
$url: str-slice($u, 6, str-length($u) - 2);
}

@if string-starts-with($url, '../') or string-starts-with($url, '/') or string-starts-with($url, 'http') {
@return true;
}
}

@warn '`url: #{$u}` is not a valid string';
@return false;
}

Expand Down

0 comments on commit c2b5bde

Please sign in to comment.