Giter Club home page Giter Club logo

Comments (11)

c-harding avatar c-harding commented on June 14, 2024

Actually I think I misunderstood the form the output takes, as viewport widths are not converted to function calls by this module. I guess I'll have to go without.

from css-to-react-native-transform.

c-harding avatar c-harding commented on June 14, 2024

How did you get viewport widths to work in the first place? I'm now getting the error "JSON value '30vw' of type NSString cannot be converted to a ABI33_0_0YGValue. Did you forget the % or pt suffix?".

from css-to-react-native-transform.

kristerkari avatar kristerkari commented on June 14, 2024

Hey @xsanda.

So let me explain a bit about calc and the viewport units.

Both of them need to be calculated at runtime. The viewport units work because they run through a special function that uses the Dimensions module of React Native to check what the viewport width and height is.

calc is a bit trickier to handle, because when you use width or height inside of calc, the size of the elements needs to be known. In React Native it's only possible to get the size of an element asynchronously, which means that you need to first get the value, and then re-render the component.

from css-to-react-native-transform.

c-harding avatar c-harding commented on June 14, 2024

If you only use exact and viewport values (as opposed to percentages), then why would calculating calc(50vw + 5 px) be any harder than calculating 50vw? The output is in pixels anyway.

from css-to-react-native-transform.

kristerkari avatar kristerkari commented on June 14, 2024

If you only use exact and viewport values (as opposed to percentages), then why would calculating calc(50vw + 5 px) be any harder than calculating 50vw? The output is in pixels anyway.

That's easy to handle, the problem is that calc is really useful when used with width and height (e.g. https://css-tricks.com/a-couple-of-use-cases-for-calc/).

I really would not like to add support for CSS features that are only partially implemented.

from css-to-react-native-transform.

kristerkari avatar kristerkari commented on June 14, 2024

So calc with viewport units is easy, but calc with width/height + percentages is difficult to implement.

from css-to-react-native-transform.

kristerkari avatar kristerkari commented on June 14, 2024

Also, I have made a proof of concept of using percentages and calc. I would just need to finish writing a babel plugin for it.

Here's an example:
https://github.com/kristerkari/css-calc-proof-of-concept/blob/master/App.js#L47-L61

from css-to-react-native-transform.

kristerkari avatar kristerkari commented on June 14, 2024

I have also created a library that turns calc values to pixels based on the viewport/element size:
https://github.com/kristerkari/css-calc-transform/blob/master/__tests__/index.spec.js

from css-to-react-native-transform.

NE-SmallTown avatar NE-SmallTown commented on June 14, 2024

Hey guys, will the css-calc-transform be added to this repo?

from css-to-react-native-transform.

iambool avatar iambool commented on June 14, 2024

Hey guys, will the css-calc-transform be added to this repo? +1

from css-to-react-native-transform.

kristerkari avatar kristerkari commented on June 14, 2024

@NE-SmallTown @iambool Look at my comment above. It can not just be added, calc() needs values that can only be known at runtime.

from css-to-react-native-transform.

Related Issues (10)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.