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

calc in SizeUnit #28

Open
ghivert opened this issue Jan 31, 2020 · 1 comment
Open

calc in SizeUnit #28

ghivert opened this issue Jan 31, 2020 · 1 comment

Comments

@ghivert
Copy link
Contributor

ghivert commented Jan 31, 2020

I think we should be able to access calc in SizeUnit. It is as much legit than any other thing, and avoid costly computation in JS when wanting to compute a layout for example. And it allows to mix and match different values.

An idea:

myStyle =
  [ width 
    (Sizes.calc 
      (Sizes.div 
        (Sizes.sub (px 50) (px 104)) 
        (vw 100)
      ) 
    )
  ]

This would results in:

.myStyle {
  width: calc((50px - 104px) / 100vw);
}

Because all the CSS is computed directly by the browser with a C++ engine, we would gain in performance instead of subscribing to the size of the window to do the same computation in Elm.

@tibastral
Copy link
Contributor

tibastral commented Jan 31, 2020 via email

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

No branches or pull requests

2 participants