Skip to content

Instantly share code, notes, and snippets.

@delphinpro
Created May 1, 2022 07:28
Show Gist options
  • Save delphinpro/e1626fcdfe6ebdd690259c5de284a787 to your computer and use it in GitHub Desktop.
Save delphinpro/e1626fcdfe6ebdd690259c5de284a787 to your computer and use it in GitHub Desktop.
Get last selector
@function str-split($string, $separator: " ") {
$i: str-index($string, $separator);
@if $i != null {
@return append(
str-slice($string, 1, $i - 1),
str-split(str-slice($string, $i + str-length($separator)), $separator)
);
}
@return $string
}
@function nth-last($list) {
@return nth($list, length($list));
}
@function get-last-selector($selector) {
@return nth-last(str-split(#{$selector}));
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment