aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--scss/_variables.scss16
1 files changed, 16 insertions, 0 deletions
diff --git a/scss/_variables.scss b/scss/_variables.scss
index 13432f2f3..e6cd6a333 100644
--- a/scss/_variables.scss
+++ b/scss/_variables.scss
@@ -33,6 +33,22 @@
}
}
+/// Replace `$search` with `$replace` in `$string`
+/// @author Hugo Giraudel
+/// @param {String} $string - Initial string
+/// @param {String} $search - Substring to replace
+/// @param {String} $replace ('') - New value
+/// @return {String} - Updated string
+@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;
+}
+
// General variable structure
//
// Variable format should follow the `$component-modifier-state-property` order.