Skip to content

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