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

Allow cell height in cm and mm units #2574

Merged
merged 1 commit into from
Dec 14, 2023
Merged

Conversation

joostme
Copy link

@joostme joostme commented Dec 13, 2023

Description

Allow cm and mm units for cell height. I am using this to create a printable layout that's consistent across devices when printing on paper. The only way to achieve that is by using cm and mm units. This small PR allows the two additional CSS units.

Checklist

  • Created tests which fail without the change (if possible)
  • All tests passing (yarn test)
  • Extended the README / documentation, if necessary

@@ -219,7 +219,7 @@ export class Utils {
if (typeof val === 'string') {
if (val === 'auto' || val === '') h = 0;
else {
let match = val.match(/^(-[0-9]+\.[0-9]+|[0-9]*\.[0-9]+|-[0-9]+|[0-9]+)(px|em|rem|vh|vw|%)?$/);
let match = val.match(/^(-[0-9]+\.[0-9]+|[0-9]*\.[0-9]+|-[0-9]+|[0-9]+)(px|em|rem|vh|vw|%|cm|mm)?$/);
Copy link
Member

Choose a reason for hiding this comment

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

do browser support cm ? and how would I convert this to px to do match (which I do for rem/em)

Copy link
Author

Choose a reason for hiding this comment

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

Browsers do support cm/mm. You can see the spec here: https://www.w3.org/TR/css-values-3/#absolute-lengths
There's also a conversion rate given for cm to px. I updated the getCellHeight method to accommodate for cm/mm units

@joostme joostme force-pushed the patch-1 branch 2 times, most recently from 4bcff85 to 2ffb301 Compare December 14, 2023 10:02
@adumesny
Copy link
Member

thanks!

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