@use "sass:math";

// Global settings

// Creates: "my-class--c > *" to target inner elements
$child-selector-extension: "--c > *";

@function px($value){
  @if $value != 0 {
    $value: $value + 0px;
  }
  @return $value;
}

@function em($value){
  @if $value != 0 {
    $value: $value + 0em;
  }
  @return $value;
}

@function px-split($string, $separator) {
  // empty array/list
  $split-arr: ();
  // first index of separator in string
  $index : str-index($string, $separator);
  // loop through string
  @while $index != null {
    // get the substring from the first character to the separator
    $item: str-slice($string, 1, $index - 1);
    // push item to array
    $split-arr: append($split-arr, px($item));
    // remove item and separator from string
    $string: str-slice($string, $index + 1);
    // find new index of separator
    $index : str-index($string, $separator);
  }
  // add the remaining string to array/list (the last item)
  $split-arr: append($split-arr,px($string));
  @return $split-arr;
}