From b74610ee3778c648b952b57fe61318f35a795605 Mon Sep 17 00:00:00 2001 From: Ryan Dee Date: Tue, 24 Mar 2026 15:10:59 -0500 Subject: [PATCH 1/3] Add strip unit function --- scss/functions/_index.scss | 3 ++- scss/functions/_strip-unit.scss | 16 ++++++++++++++++ 2 files changed, 18 insertions(+), 1 deletion(-) create mode 100644 scss/functions/_strip-unit.scss diff --git a/scss/functions/_index.scss b/scss/functions/_index.scss index dfe81af7..9e55f7ff 100644 --- a/scss/functions/_index.scss +++ b/scss/functions/_index.scss @@ -1,3 +1,4 @@ @forward "./encode-color"; @forward "./media-queries"; -@forward "./to-number"; \ No newline at end of file +@forward "./strip-unit"; +@forward "./to-number"; diff --git a/scss/functions/_strip-unit.scss b/scss/functions/_strip-unit.scss new file mode 100644 index 00000000..fcb23922 --- /dev/null +++ b/scss/functions/_strip-unit.scss @@ -0,0 +1,16 @@ +//////////////////////////////// +// CORE / FUNCTIONS / STRIP UNIT +//////////////////////////////// + + +/// https://css-tricks.com/snippets/sass/strip-unit-function/ +/// Remove the unit of a length +/// @param {Number} $number - Number to remove unit from +/// @return {Number} - Unitless number +@function strip-unit($number) { + @if type-of($number) == 'number' and not unitless($number) { + @return $number / ($number * 0 + 1); + } + + @return $number; +} From 5276e25c2f964b29f92812f46f62c6799538dd5e Mon Sep 17 00:00:00 2001 From: Ryan Dee Date: Wed, 25 Mar 2026 16:42:40 -0500 Subject: [PATCH 2/3] Add Sass math and meta modules to strip-unit fn --- scss/functions/_strip-unit.scss | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/scss/functions/_strip-unit.scss b/scss/functions/_strip-unit.scss index fcb23922..e71a6ace 100644 --- a/scss/functions/_strip-unit.scss +++ b/scss/functions/_strip-unit.scss @@ -3,12 +3,16 @@ //////////////////////////////// +@use 'sass:math'; +@use 'sass:meta'; + + /// https://css-tricks.com/snippets/sass/strip-unit-function/ /// Remove the unit of a length /// @param {Number} $number - Number to remove unit from /// @return {Number} - Unitless number @function strip-unit($number) { - @if type-of($number) == 'number' and not unitless($number) { + @if meta.type-of($number) == 'number' and not math.unitless($number) { @return $number / ($number * 0 + 1); } From f4cbb1fbd9ca6c8882455e9cdca8e704079f72ca Mon Sep 17 00:00:00 2001 From: Ryan Dee Date: Wed, 25 Mar 2026 17:00:59 -0500 Subject: [PATCH 3/3] Update strip-unit math syntax --- scss/functions/_strip-unit.scss | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/scss/functions/_strip-unit.scss b/scss/functions/_strip-unit.scss index e71a6ace..cc86560d 100644 --- a/scss/functions/_strip-unit.scss +++ b/scss/functions/_strip-unit.scss @@ -13,8 +13,7 @@ /// @return {Number} - Unitless number @function strip-unit($number) { @if meta.type-of($number) == 'number' and not math.unitless($number) { - @return $number / ($number * 0 + 1); + @return math.div($number, $number * 0 + 1); } - @return $number; }