diff --git a/scss/_variables.scss b/scss/_variables.scss index 13432f2f3c..e6cd6a3332 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.