Skip to content

Commit

Permalink
refactor(enhance): ♻️ Refactor string list related functions to use s…
Browse files Browse the repository at this point in the history
…tring module

Replace `unquote` and `unit` functions with `string.unquote` and `math.unit` for consistency and better encapsulation. This change ensures uniformity and improved maintainability across math-related functions. It also enhances code readability and reduces potential errors.
  • Loading branch information
krypton225 committed Jan 1, 2024
1 parent 73dd8f3 commit b32e97c
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 11 deletions.
3 changes: 2 additions & 1 deletion src/functions/global/_get-half-number.scss
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@

@use "sass:meta";
@use "sass:math";
@use "sass:string";
@use "cut-unit" as LibFunc;
@use "../../development-utils/toggle-error-message" as Error;

Expand All @@ -68,7 +69,7 @@
$num-after-cut-unit: LibFunc.cut-unit($number);
$unit-of-number: math.unit($number);

@return unquote("#{calc($num-after-cut-unit / 2)}#{$unit-of-number}");
@return string.unquote("#{calc($num-after-cut-unit / 2)}#{$unit-of-number}");
}

@return calc($number / 2);
Expand Down
16 changes: 8 additions & 8 deletions src/mixins/general/_box-shadow.scss
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@

@if list.length($one-list) == 1 {
@if meta.type-of($first-item-val) == string {
@if not index($box-shadow-values, $first-item-val) {
@if not list.index($box-shadow-values, $first-item-val) {
@error "The value of box shadow must has one of these values: (#{$box-shadow-values})";
}

Expand All @@ -102,11 +102,11 @@
$second-item-val: list.nth($one-list, 2);

@if meta.type-of($first-item-val) == number and meta.type-of($second-item-val) == number {
@if not index(var.$main-units, math.unit($first-item-val)) {
@if not list.index(var.$main-units, math.unit($first-item-val)) {
@error "First value of the box shadow must has one of these units: (#{var.$main-units})";
}

@if not index(var.$main-units, math.unit($second-item-val)) {
@if not list.index(var.$main-units, math.unit($second-item-val)) {
@error "Second value of the box shadow must has one of these units: (#{var.$main-units})";
}
} @else {
Expand All @@ -129,7 +129,7 @@
$third-item-val: list.nth($one-list, 3);
$fourth-item-val: list.nth($one-list, 4);

@if not index(var.$main-units, math.unit($third-item-val)) {
@if not list.index(var.$main-units, math.unit($third-item-val)) {
@error "Third value of the box shadow must has one of these units: (#{var.$main-units})";
}

Expand All @@ -147,11 +147,11 @@
$fourth-item-val: list.nth($one-list, 4);
$fifth-item-val: list.nth($one-list, 5);

@if not index(var.$main-units, math.unit($third-item-val)) {
@if not list.index(var.$main-units, math.unit($third-item-val)) {
@error "Third value of the box shadow must has one of these units: (#{var.$main-units})";
}

@if not index(var.$main-units, math.unit($fourth-item-val)) {
@if not list.index(var.$main-units, math.unit($fourth-item-val)) {
@error "Fourth value of the box shadow must has one of these units: (#{var.$main-units})";
}

Expand All @@ -170,11 +170,11 @@
$fifth-item-val: list.nth($one-list, 5);
$sixth-item-val: list.nth($one-list, 6);

@if not index(var.$main-units, math.unit($third-item-val)) {
@if not list.index(var.$main-units, math.unit($third-item-val)) {
@error "Third value of the box shadow must has one of these units: (#{var.$main-units})";
}

@if not index(var.$main-units, math.unit($fourth-item-val)) {
@if not list.index(var.$main-units, math.unit($fourth-item-val)) {
@error "Fourth value of the box shadow must has one of these units: (#{var.$main-units})";
}

Expand Down
5 changes: 3 additions & 2 deletions src/mixins/general/_color-generator-vars.scss
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@

@use "sass:meta";
@use "sass:list";
@use "sass:string";
@use "../../abstract/config" as Config;

@mixin generate-colors($brand-name: Config.$brand-lib-name, $color-map: ()) {
Expand All @@ -102,9 +103,9 @@
}

@if $brand-name == "" or $brand-name == def {
--#{Config.$brand-lib-name}-#{to-lower-case($clr)}-clr: #{$val};
--#{Config.$brand-lib-name}-#{string.to-lower-case($clr)}-clr: #{$val};
} @else {
--#{to-lower-case($brand-name)}-#{to-lower-case($clr)}-clr: #{$val};
--#{string.to-lower-case($brand-name)}-#{string.to-lower-case($clr)}-clr: #{$val};
}
}
}
Expand Down

0 comments on commit b32e97c

Please sign in to comment.