Files
ionic-framework/core/src/themes/ionic.functions.string.scss
Brandy Carney a7f1f4daa7 refactor(components): update to use shadow DOM and work with css variables
- updates components to use shadow DOM or scoped if they require css variables
- moves global styles to an external stylesheet that needs to be imported
- adds support for additional colors and removes the Sass loops to generate colors for each component
- several property renames, bug fixes, and test updates

Co-authored-by: Manu Mtz.-Almeida <manu.mtza@gmail.com>
Co-authored-by: Adam Bradley <adambradley25@gmail.com>
Co-authored-by: Cam Wiegert <cam@camwiegert.com>
2018-07-09 12:57:21 -04:00

82 lines
2.0 KiB
SCSS

// String Util Functions
// --------------------------------------------------
// String Replace Function
// --------------------------------------------------
@function str-replace($string, $search, $replace: "") {
$index: str-index($string, $search);
@if $index {
@return str-slice($string, 1, $index - 1) + $replace + str-replace(str-slice($string, $index + str-length($search)), $search, $replace);
}
@return $string;
}
// String Split Function
// --------------------------------------------------
@function str-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, $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 list (the last item)
$split-arr: append($split-arr, $string);
@return $split-arr;
}
// Str Extract Function
// --------------------------------------------------
@function str-extract($string, $start, $end) {
$start-index: str-index($string, $start);
@if $start-index {
$post: str-slice($string, $start-index + str-length($start));
$end-index: str-index($post, $end);
@if $end-index {
@return str-slice($post, 1, $end-index - 1);
}
}
@return null;
}
// Str Contains Function
// --------------------------------------------------
@function str-contains($string, $needle) {
@if (type-of($string) == string) {
@return str-index($string, $needle) != null;
}
@return false;
}
// URL Encode Function
// --------------------------------------------------
@function url-encode($val) {
$spaces: str-replace($val, " ", "%20");
$encoded: str-replace($spaces, "#", "%23");
@return $encoded;
}