zotero/scss/abstracts/_functions.scss

39 lines
943 B
SCSS
Raw Normal View History

2017-05-22 23:10:03 +00:00
//
// Functions
// --------------------------------------------------
2023-10-06 12:08:44 +00:00
@use "sass:string";
2017-05-22 23:10:03 +00:00
2023-10-06 12:08:44 +00:00
@function str-replace($string, $search, $replace: '') {
$index: str-index($string, $search);
@if $index {
2023-11-15 09:07:54 +00:00
@return str-slice($string, 1, $index - 1)+$replace + str-replace(str-slice($string, $index + str-length($search)), $search, $replace);
2023-10-06 12:08:44 +00:00
}
@return $string;
}
@function capitalize($string) {
@return to-upper-case(str-slice($string, 1, 1))+str-slice($string, 2);
}
@function camelCase($string) {
$string: quote(#{$string});
$progress: $string;
$result: "";
@while str-length($progress)>0 {
$char: str-slice($progress, 1, 1);
@if $char =="-" {
$progress: capitalize(str-slice($progress, 2, 2)) + str-slice($progress, 3);
}
@else {
$result: $result + $char;
$progress: str-slice($progress, 2);
}
}
@return $result;
}