Skip to content

Add support for rem values in gap and peek#599

Open
krmax44 wants to merge 1 commit intoglidejs:masterfrom
krmax44:relative-sizes
Open

Add support for rem values in gap and peek#599
krmax44 wants to merge 1 commit intoglidejs:masterfrom
krmax44:relative-sizes

Conversation

@krmax44
Copy link
Copy Markdown

@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
Copy Markdown
Author

krmax44 commented Mar 28, 2022

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

Comment thread src/utils/unit.js
* @param {Glide} glide
* @returns {Number}
*/
export function toPx (value) {
Copy link
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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