airbnb / react-sketchapp

render React components to Sketch ⚛️💎
http://airbnb.io/react-sketchapp/
MIT License
14.94k stars 821 forks source link

borderWidth property doesn't accept px values #428

Closed lucaorio closed 5 years ago

lucaorio commented 5 years ago

I'm note sure if this is intentional, but the borderWidth property doesn't get rendered if its value is specified in px.

This works:

const style = {
  borderWidth: 1,
 // ...
};

This doesn't work:

const style = {
  borderWidth: '1px',
 // ...
};
mathieudutour commented 5 years ago

I believe it is intentional because React Native is doing it that way as well and react-sketchapp wants to mimic the RN API as much as possible. If RN doesn't do that tho, we should fix it for sure

macintoshhelper commented 5 years ago

Can confirm that React Native doesn't support px values: in some cases it even crashes React Native, but ignoring the property with a warning would probably be best I think. related issue on react-native repo.

If you want to use px values, it may be worth using styled-components/primitives to better mimic web CSS behaviour, or you could create some kind of StyleSheet.parse() util function converts the px to numbers.