Any suggestion related to code will be appreciated :)
function str-remove-alphabet():- this function takes one string as an argument.and remove any alphabet in that string.and return an int value.
// 3.str-alpha-remove function. removes alphabet from given string.
@function str-remove-alphabet($string) {
// local variables.
// loop alphabets list to index occurence of alphabets in string
@each $i in $list-alphabets {
// if occurence found.
@if(str-index($string, $i)) {
$string: str-replace($string, $i, '');
@return $string; // than replace that character with null.
} @else {
@return $string; // otherwise return string.
}
}
}
function font-size():- this function takes two argument. 1.font-size and 2. unit. and converts font-size (eg 15px) and convert it into (eg 15) using str-remove-alphabet function. after successful return it start calculating font-size into given unit(eg 1.223342rem).
// 1.font-size calculator based on font-size given and unit.
//noinspection CssInvalidFunction
@function font-size($size, $unit: 'em') {
$size: str-remove-alphabet('17px');
$base-font: str-remove-alphabet('15px');
@if($unit == 'em') {
$font-size: ($size / $base-font) em;
@debug $font-size;
@return $font-size; // returns font-size in em format
} @else if($unit == 'per') {
$font-size: ($size / $base-font) * 100%;
@debug $font-size;
@return $font-size; // returns font-size in percentage format
} @else {
$font-size: ($size / $base-font) * 1rem;
@debug $font-size;
@return $font-size; // else return in rem format
}
}
problem :- i am unable to call str-remove-alphabet() inside of font-size().