Comments (11)
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.
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.
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.
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.
If you only use exact and viewport values (as opposed to percentages), then why would calculating
calc(50vw + 5 px)
be any harder than calculating50vw
? 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.
So calc with viewport units is easy, but calc with width/height + percentages is difficult to implement.
from css-to-react-native-transform.
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.
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.
Hey guys, will the css-calc-transform
be added to this repo?
from css-to-react-native-transform.
Hey guys, will the css-calc-transform
be added to this repo? +1
from css-to-react-native-transform.
@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)
- Feature: add support for parsing viewport units HOT 1
- Throw an error when line-height is a multiplier value
- An in-range update of css-to-react-native is breaking the build 🚨 HOT 1
- An in-range update of lint-staged is breaking the build 🚨 HOT 1
- An in-range update of babel7 is breaking the build 🚨 HOT 10
- support multiple class selector? HOT 1
- Update css-to-react-native to version 3
- Failed to parse declaration "boxShadow: none !important" HOT 1
- Add experimental support for CSS media queries HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from css-to-react-native-transform.