Skip to content

OpenProject is the leading open source project management software for product, project and portfolio management. A powerful Jira alternative with agile planning, issue tracking, roadmaps, Gantt charts, time tracking, collaboration features, and more. Available on premises or in the cloud. ⭐ Star us on GitHub

Readd "rem-calc" function from Foundation as it is still used

Henriette Darge8fe0fc2a3aba
diff --git a/frontend/src/global_styles/openproject/_functions.sass b/frontend/src/global_styles/openproject/_functions.sass
index cf2ac2dfffe..04b05b9e159 100644
--- a/frontend/src/global_styles/openproject/_functions.sass
+++ b/frontend/src/global_styles/openproject/_functions.sass
@@ -25,6 +25,10 @@
//
// See COPYRIGHT and LICENSE files for more details.
//++
+@use "sass:math"
+
+$rem-base: 16px !default
+
@function rem-concat-list($list-of-pixels)
$result: ''
@@ -90,3 +94,47 @@
$scale: -$scale
@return scale-color($color, $lightness: $scale)
+
+/// Strip Unit
+/// Removes the unit (e.g. px, em, rem) from a value, returning the number only.
+///
+/// @param {number} $num - Number to strip unit from.
+///
+/// @return The same number, sans unit.
+@function strip-unit($num)
+ @return math.div($num, $num * 0 + 1)
+
+
+/// Convert to Rem
+/// Converts a pixel value to matching rem value. *Any* value passed, regardless of unit, is assumed to be a pixel value. By default, the base pixel value used to calculate the rem value is taken from the `$rem-base` variable.
+///
+/// @param {number} $value - Pixel value to convert.
+///
+/// @return A number in rems, calculated based on the given value and the base pixel value.
+@function convert-to-rem($value, $base-value: $rem-base)
+ $value: math.div(strip-unit($value), strip-unit($base-value)) * 1rem
+ @if ($value == 0rem)
+ $value: 0 // Turn 0rem into 0
+ @return $value
+
+
+/// Rem Calculator
+/// Converts one or more pixel values into matching rem values. This function works a lot like `convert-to-rem`, except it can convert more than one value at once, which is useful when setting multiple values on a `margin` or `padding` property.
+///
+/// @param {number|list} $values - One or more values to convert. Be sure to separate them with spaces and not commas. If you need to convert a comma-separated list, wrap the list in parentheses.
+///
+/// @return A list of converted values.
+@function rem-calc($values, $base-value: null)
+ @if $base-value == null
+ $base-value: $rem-base
+
+ $max: length($values)
+
+ @if $max == 1
+ @return convert-to-rem(nth($values, 1), $base-value)
+
+ $remValues: ()
+ @for $i from 1 through $max
+ $remValues: append($remValues, convert-to-rem(nth($values, $i), $base-value))
+
+ @return $remValues