Skip to content

Commit

Permalink
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
use list.nth()
Browse files Browse the repository at this point in the history
sacr3dc0w committed Jul 11, 2024
1 parent 8d9ed26 commit 7e2fa31
Showing 3 changed files with 9 additions and 9 deletions.
8 changes: 4 additions & 4 deletions assets/scss/tools/_image.scss
Original file line number Diff line number Diff line change
@@ -8,8 +8,8 @@
@function get-padding($size) {
$list: string.split($size, "x");

$width: to-number(nth($list, 1));
$height: to-number(nth($list, 2));
$width: to-number(list.nth($list, 1));
$height: to-number(list.nth($list, 2));

@return math.percentage($height/$width);
}
@@ -24,7 +24,7 @@
@function get-width($size) {
$list: string.split($size, "x");

@return nth($list, 1) + "px";
@return list.nth($list, 1) + "px";
}

///
@@ -37,5 +37,5 @@
@function get-height($size) {
$list: string.split($size, "x");

@return nth($list, 2) + "px";
@return list.nth($list, 2) + "px";
}
2 changes: 1 addition & 1 deletion assets/scss/tools/_list.scss
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
@function contains($list, $var) {
@return index($list, $var) != null;
@return list.index($list, $var) != null;
}
8 changes: 4 additions & 4 deletions assets/scss/tools/_string.scss
Original file line number Diff line number Diff line change
@@ -41,9 +41,9 @@
/// @return {Number} - The converted Number
///
@function to-number($value) {
@if type-of($value) == "number" {
@if meta.type-of($value) == "number" {
@return $value;
} @else if type-of($value) != "string" {
} @else if meta.type-of($value) != "string" {
$_: log("Value for `to-number` should be a number or a string.");
}

@@ -55,7 +55,7 @@
@for $i from if($minus, 2, 1) through string.length($value) {
$character: string.slice($value, $i, $i);

@if not (index(map.keys($numbers), $character) or $character == ".") {
@if not (list.index(map.keys($numbers), $character) or $character == ".") {
@return to-length(if($minus, -$result, $result), string.slice($value, $i));
}

@@ -84,7 +84,7 @@
@function to-length($value, $unit) {
$units: ("px": 1px, "cm": 1cm, "mm": 1mm, "%": 1%, "ch": 1ch, "pc": 1pc, "in": 1in, "em": 1em, "rem": 1rem, "pt": 1pt, "ex": 1ex, "vw": 1vw, "vh": 1vh, "vmin": 1vmin, "vmax": 1vmax);

@if not index(map.keys($units), $unit) {
@if not list.index(map.keys($units), $unit) {
$_: log("Invalid unit `#{$unit}`.");
}

0 comments on commit 7e2fa31

Please sign in to comment.