Skip to content
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

Add support for rem values in gap and peek #599

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

krmax44
Copy link

@krmax44 krmax44 commented Jan 31, 2022

This allows the use of relative sizes with rem in peek and gap instead of just pixel units.

@krmax44
Copy link
Author

krmax44 commented Mar 28, 2022

hey @jedrzejchalubek, do you have some time to review/merge this?

* @param {Glide} glide
* @returns {Number}
*/
export function toPx (value) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this logic here can be simplified following way:

export function toPx (value) {
  if (value.endsWith('rem')) {
    const { fontSize } = window.getComputedStyle(document.documentElement)
    return toInt(int * toFloat(fontSize))
  }

  return toInt(value)
}

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Other than that looks LGTM :)

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jedrzejchalubek Sorry for getting back so late! This would unfortunately cause an error whenever value is not a string, though.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants