-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #21 from 21TORR/on-n-siblings
Add on-n-siblings and type checks
- Loading branch information
Showing
8 changed files
with
56 additions
and
5 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 |
---|---|---|
@@ -0,0 +1,22 @@ | ||
@use "types"; | ||
|
||
/// | ||
/// Applies the rule if the element is one of exact | ||
/// | ||
@mixin on-n-siblings ($number-of-siblings) { | ||
@if (not types.is-integer($number-of-siblings) or $number-of-siblings <= 0) { | ||
@error "Number of siblings must be an integer >= 1, but #{$number-of-siblings} given."; | ||
} | ||
|
||
@if (1 == $number-of-siblings) { | ||
&:first-child:last-child { | ||
@content; | ||
} | ||
} | ||
@else { | ||
&:first-child:nth-last-child(#{$number-of-siblings}), | ||
&:first-child:nth-last-child(#{$number-of-siblings}) ~ * { | ||
@content; | ||
} | ||
} | ||
} |
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,13 @@ | ||
/// | ||
/// Returns whether the given value is a number (int or float) | ||
/// | ||
@function is-number($value) { | ||
@return type-of($value) == 'number'; | ||
} | ||
|
||
/// | ||
/// Returns whether the given value is an integer | ||
/// | ||
@function is-integer($value) { | ||
@return is-number($value) and round($value) == $value; | ||
} |
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