Skip to content

Centralize px ⮕ rem calculation in a function#2595

Draft
anselmbradford wants to merge 1 commit intomainfrom
ans_functions
Draft

Centralize px ⮕ rem calculation in a function#2595
anselmbradford wants to merge 1 commit intomainfrom
ans_functions

Conversation

@anselmbradford
Copy link
Copy Markdown
Member

@anselmbradford anselmbradford commented Apr 2, 2026

We can use a SASS @function to do the px ⮕ rem conversion, with the aim to eventually swap it with the native CSS @function https://developer.mozilla.org/en-US/docs/Web/CSS/Reference/At-rules/@function

Changes

  • Centralize px to rem calc in a function
  • Standardize relative unit in WC on REM

Testing

  1. yarn build && yarn start and compare http://localhost:4000/design-system/components/reference-for-custom-elements to https://cfpb.github.io/design-system/components/reference-for-custom-elements

Note

  • Some calculations used $btn-font-size for the base font size. I think this maybe came from @cfpb/cfpb-design-system/src/elements/cfpb-button/vars before that converted to CSS custom props? At any rate, the only value I saw set for this $base-font-size-px, so I stripped it out in favor of that default.

  • Some calculations used ems. I converted these to rems, but we should scrutinize that this is okay.

  • Do we actually need these calculations? These are very old and we should scrutinize whether they're still best practice.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: No status

Development

Successfully merging this pull request may close these issues.

1 participant