Skip to content

Commit

Permalink
refactor(enhance): ♻️ Refactor functions & mixins to use unitless h…
Browse files Browse the repository at this point in the history
…elper

This change updates SCSS functions and mixins to utilize the `unitless()` helper instead of `math.unitless()` for improved code readability and reusability. The `unitless()` helper simplifies conditional checks for unitless values, enhancing maintainability and reducing potential errors.
  • Loading branch information
krypton225 committed Jan 1, 2024
1 parent b32e97c commit bc9fce5
Show file tree
Hide file tree
Showing 5 changed files with 6 additions and 6 deletions.
2 changes: 1 addition & 1 deletion src/development-utils/_approximation-numbers.scss
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@
@return Error.toggle("The mode parameter of approx function must be in a string type.");
}

@if not math.unitless($num) {
@if not unitless($num) {
$num-unit: math.unit($num);
}

Expand Down
4 changes: 2 additions & 2 deletions src/functions/global/_cut-unit.scss
Original file line number Diff line number Diff line change
Expand Up @@ -55,11 +55,11 @@
}

// stylelint-disable-next-line length-zero-no-unit
@if math.unit($num) == "" and not math.unitless($num) {
@if math.unit($num) == "" and not unitless($num) {
@return Error.toggle("The parameter dose not need a unit if it equals to zero.");
}

@if meta.type-of($num) == number and not math.unitless($num) {
@if meta.type-of($num) == number and not unitless($num) {
@return math.div($num, ($num * 0 + 1));
}

Expand Down
2 changes: 1 addition & 1 deletion src/functions/global/_get-half-number.scss
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@
@return 0;
}

@if not math.unitless($number) {
@if not unitless($number) {
$num-after-cut-unit: LibFunc.cut-unit($number);
$unit-of-number: math.unit($number);

Expand Down
2 changes: 1 addition & 1 deletion src/mixins/flex-props/main-props/_flex-basis.scss
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@
}

@if meta.type-of($value) == number and LibFunc.cut-unit($value) != 0 {
@if math.unitless($value) {
@if unitless($value) {
@error "Please, Enter the unit of $value argument. It must be one of these units (#{$flex-basis-values})";
}

Expand Down
2 changes: 1 addition & 1 deletion src/mixins/general/_square.scss
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@
) !default;

@if meta.type-of($one-side) == number {
@if not math.unitless($one-side) {
@if not unitless($one-side) {
@if func.is-in-list($all-units, math.unit($one-side)) {
width: $one-side;
height: $one-side;
Expand Down

0 comments on commit bc9fce5

Please sign in to comment.