From dd5f3c463fab336d694f426dcad11a1783590fc9 Mon Sep 17 00:00:00 2001 From: Volpeon Date: Sat, 5 Feb 2022 07:52:13 +0100 Subject: Ported from import syntax to modules --- src/_functions.scss | 49 +++++++++++++++++++++++++------------------------ 1 file changed, 25 insertions(+), 24 deletions(-) (limited to 'src/_functions.scss') diff --git a/src/_functions.scss b/src/_functions.scss index 92ee262..d091afa 100644 --- a/src/_functions.scss +++ b/src/_functions.scss @@ -10,6 +10,7 @@ //// @use 'sass:math'; +@use './vars'; /// /// Replace a substring with a new string. @@ -20,11 +21,11 @@ /// /// @return {string} A string with all instances of $search replaced with $replace /// -@function iro-str-replace($string, $search, $replace) { +@function str-replace($string, $search, $replace) { $index: str-index($string, $search); @if $index { - @return str-slice($string, 1, $index - 1) + $replace + iro-str-replace(str-slice($string, $index + str-length($search)), $search, $replace); + @return str-slice($string, 1, $index - 1) + $replace + str-replace(str-slice($string, $index + str-length($search)), $search, $replace); } @return $string; @@ -38,11 +39,11 @@ /// /// @return {string} /// -@function iro-str-implode($list, $glue: '') { +@function str-implode($list, $glue: '') { $result: ''; @each $item in $list { - $result: $result + if(length($item) > 1, iro-str-implode($item, $glue), $item); + $result: $result + if(length($item) > 1, str-implode($item, $glue), $item); @if $item != nth($list, length($list)) { $result: $result + $glue; @@ -61,7 +62,7 @@ /// /// @return {list} A slice of the list /// -@function iro-list-slice($list, $start: 1, $end: length($list)) { +@function list-slice($list, $start: 1, $end: length($list)) { $result: (); @for $i from $start through $end { @@ -81,7 +82,7 @@ /// /// @return {list} A list with $value at the beginning, followed by the other items /// -@function iro-list-prepend($list, $value) { +@function list-prepend($list, $value) { $result: append((), $value, list-separator($list)); @if length($list) > 0 { @@ -103,13 +104,13 @@ /// /// @return {list} Sorted list /// -@function iro-quicksort($l, $left: 1, $right: length($l)) { +@function quicksort($l, $left: 1, $right: length($l)) { @if $left < $right { - $pvr: iro-quicksort-partition($l, $left, $right); + $pvr: quicksort-partition($l, $left, $right); $pivot: nth($pvr, 1); $l: nth($pvr, 2); - $l: iro-quicksort($l, $left, $pivot); - $l: iro-quicksort($l, $pivot + 1, $right); + $l: quicksort($l, $left, $pivot); + $l: quicksort($l, $pivot + 1, $right); } @return $l; @@ -118,7 +119,7 @@ /// /// @access private /// -@function iro-quicksort-partition($l, $left, $right) { +@function quicksort-partition($l, $left, $right) { $start: true; $i: $left; $j: $right - 1; @@ -161,7 +162,7 @@ /// /// @return {any} Either the value assigned to $key or $default /// -@function iro-map-get-default($map, $key, $default) { +@function map-get-default($map, $key, $default) { @return if(map-has-key($map, $key), map-get($map, $key), $default); } @@ -174,7 +175,7 @@ /// /// @return {any} Either the value assigned to $key or $default /// -@function iro-map-get-deep($map, $key, $default: null) { +@function map-get-deep($map, $key, $default: null) { $value: null; @if type-of($key) == list { @@ -206,7 +207,7 @@ /// /// @return {map} The result of a recursive merge of $map1 and $map2 /// -@function iro-map-merge-recursive($map1, $map2) { +@function map-merge-recursive($map1, $map2) { @if type-of($map1) != map or type-of($map2) != map { @error 'Two maps expected.'; } @@ -215,7 +216,7 @@ @each $key, $value in $map2 { @if type-of(map-get($result, $key)) == map and type-of($value) == map { - $result: map-merge($result, ($key: iro-map-merge-recursive(map-get($result, $key), $value))); + $result: map-merge($result, ($key: map-merge-recursive(map-get($result, $key), $value))); } @else { $result: map-merge($result, ($key: $value)); } @@ -231,16 +232,16 @@ /// /// @return {string} /// -@function iro-map-print($map) { +@function map-print($map) { $output: ''; @each $key, $value in $map { $value-str: ''; @if type-of($value) == map { - $value-str: '[ ' + iro-map-print($value) + ' ]'; + $value-str: '[ ' + map-print($value) + ' ]'; } @else if type-of($value) == list { - $value-str: '[ ' + iro-str-implode($value, ', ') + ' ]'; + $value-str: '[ ' + str-implode($value, ', ') + ' ]'; } @else if type-of($value) == string { $value-str: '\'' + $value + '\''; } @else { @@ -265,7 +266,7 @@ /// /// @return {bool} `true` if the selector matches at least one suffix, otherwise `false`. /// -@function iro-selector-suffix-match($selector, $suffixes) { +@function selector-suffix-match($selector, $suffixes) { $match: true; @each $sel in $selector { @@ -304,19 +305,19 @@ /// /// @return {number} Unit-less variable /// -@function iro-strip-unit($n) { +@function strip-unit($n) { @return math.div($n, $n * 0 + 1); } /// /// Convert a pixel value to a rem value. /// -/// @param {number} $size - Pixel value to convert -/// @param {number} $base [$iro-root-size] - Reference base font size used for conversion +/// @param {number} $size - Pixel value to convert +/// @param {number} $base [vars.$root-size] - Reference base font size used for conversion /// /// @return {number} Pixel value converted to rem /// -@function iro-px-to-rem($size, $base: $iro-root-size) { +@function px-to-rem($size, $base: vars.$root-size) { @return math.div($size, $base) * 1rem; } @@ -325,6 +326,6 @@ /// /// @content /// -@mixin iro-execute { +@mixin execute { @content; } -- cgit v1.2.3-54-g00ecf