-
Notifications
You must be signed in to change notification settings - Fork 13
fix: return typed values from scss functions instead of strings #5570
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
🦋 Changeset detectedLatest commit: 46027e9 The changes in this PR will be included in the next version bump. This PR includes changesets to release 9 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
…trings Co-authored-by: mfranzke <787658+mfranzke@users.noreply.github.com>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
This PR fixes a bug in the px-to-rem() and px-to-em() SCSS helper functions that returned string values instead of properly typed Sass values, preventing arithmetic operations on their output. The fix changes from string interpolation (#{...}rem) to proper type multiplication (* 1rem), enabling calculations while maintaining backward compatibility.
Key changes:
- Modified
px-to-rem()to return typed rem values by multiplying the result by1rem - Modified
px-to-em()to return typed em values by multiplying the result by1em - Added changeset documenting the bug fix
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
packages/foundations/scss/helpers/_functions.scss |
Fixed px-to-rem() and px-to-em() functions to return typed values instead of strings by replacing string interpolation with proper multiplication |
.changeset/heavy-spiders-check.md |
Added changeset file to document the bug fix for the affected packages |
Proposed changes
The
px-to-rem()andpx-to-em()functions returned strings via interpolation (#{...}rem), preventing calculations with their output. Changed to return properly typed values by multiplying the numeric result by1rem/1em.Before:
After:
String interpolation (
#{px-to-rem(24)}) continues to work unchanged.Types of changes
Further comments
Both functions now return SASS typed values compatible with arithmetic operations while maintaining backward compatibility with existing string interpolation usage throughout the codebase.
Original prompt
✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.
🔭🐙🐈 Test this branch here: https://design-system.deutschebahn.com/core-web/review/copilot/fix-px-to-rem-function