react-native
react-native copied to clipboard
feat: mapped layout props for view component
Summary
This PR adds mapping for layout props, it maps
marginInlineStart: 'marginStart',
marginInlineEnd: 'marginEnd',
marginBlockStart: 'marginTop',
marginBlockEnd: 'marginBottom',
marginBlock: 'marginVertical',
marginInline: 'marginHorizontal',
paddingInlineStart: 'paddingStart',
paddingInlineEnd: 'paddingEnd',
paddingBlockStart: 'paddingTop',
paddingBlockEnd: 'paddingBottom',
paddingBlock: 'paddingVertical',
paddingInline: 'paddingHorizontal',
as requested on https://github.com/facebook/react-native/issues/34425
Changelog
[General][Added] - Added CSS logical properties by mapping layout props.
Test Plan
<View
style={[
{
marginBlockStart: 5, // maps to "marginTop"
borderWidth: 1,
borderRadius: 5,
padding: 5,
}
]}>
<Text style={{fontSize: 11}}>Hello World!</Text>
</View>
What about shorthands? See https://github.com/facebook/react-native/issues/34425#issuecomment-1236664129
Yes let's include those too. Thanks
Please can we add unit tests / examples for this?
Platform | Engine | Arch | Size (bytes) | Diff |
---|---|---|---|---|
android | hermes | arm64-v8a | 7,066,372 | -34,713 |
android | hermes | armeabi-v7a | 6,439,011 | -31,774 |
android | hermes | x86 | 7,482,080 | -36,851 |
android | hermes | x86_64 | 7,341,307 | -36,231 |
android | jsc | arm64-v8a | 8,932,269 | -32,889 |
android | jsc | armeabi-v7a | 7,666,624 | -29,927 |
android | jsc | x86 | 8,992,650 | -35,004 |
android | jsc | x86_64 | 9,471,395 | -34,397 |
Base commit: 5fb67b0fb21b0fa56106dad0bba8cca676451a4e Branch: main
Platform | Engine | Arch | Size (bytes) | Diff |
---|---|---|---|---|
ios | - | universal | n/a | -- |
Base commit: 5fb67b0fb21b0fa56106dad0bba8cca676451a4e Branch: main
There's a lot of shared code that we should consolidate, because more properties will be added over time. It probably should go in the StyleSheet directory
@mayank-96 could you rebase the PR, please?
Hello @cipolleschi, I'm rebasing it.
Hello @cipolleschi, I have rebased the PR and also shifted the shared code to the stylesheet directory by adding a helper function for mapping in View
component as @necolas said. Please check if it is the right way to do so that I can add it for other components as well like Image
, Text
and TextInput
.
There are still a number of issues in this PR that need to be resolved before moving forward: consistency of how the work is done across components, typos in variable names, and unit tests for the processing. It should then be rebased too. Thanks
@mayank-96 please rebase and resolve conflicts again, then @cipolleschi can import it. Thanks!
If you touched the type definitions, remember to update also the typescript types!
@mayank-96 ping
@cipolleschi I think we'll need to rebase this ourselves as the author is no longer responding
Hello @necolas, sorry I couldn't respond you earlier due to some health issues. I'll rebase this PR today itself.
PR build artifact for 1589f7bbfc8f88c5626179e2bd5788ce5606ce9f is ready.
To use, download tarball from "Artifacts" tab in this CircleCI job then run yarn add <path to tarball>
in your React Native project.
PR build artifact for 1589f7bbfc8f88c5626179e2bd5788ce5606ce9f is ready.
To use, download tarball from "Artifacts" tab in this CircleCI job then run yarn add <path to tarball>
in your React Native project.
PR build artifact for 2d46f007d05f67fbbee54f1459d33cbce8e6923d is ready.
To use, download tarball from "Artifacts" tab in this CircleCI job then run yarn add <path to tarball>
in your React Native project.
PR build artifact for 2d46f007d05f67fbbee54f1459d33cbce8e6923d is ready.
To use, download tarball from "Artifacts" tab in this CircleCI job then run yarn add <path to tarball>
in your React Native project.
@necolas has imported this pull request. If you are a Meta employee, you can view this diff on Phabricator.
@necolas has imported this pull request. If you are a Meta employee, you can view this diff on Phabricator.
PR build artifact for 12b028a4e925bf6a3f3bf07d64d84161919725d8 is ready.
To use, download tarball from "Artifacts" tab in this CircleCI job then run yarn add <path to tarball>
in your React Native project.
PR build artifact for 12b028a4e925bf6a3f3bf07d64d84161919725d8 is ready.
To use, download tarball from "Artifacts" tab in this CircleCI job then run yarn add <path to tarball>
in your React Native project.
This pull request was successfully merged by @mayank-96 in cf3747957ab210e31504109bb6b3e34e773a5b9a.
When will my fix make it into a release? | Upcoming Releases
This patched broke text layout internally and needed to be backed out
This pull request has been reverted by 114098d419e2a7a254f81b9eb9f0cc542194a660.
Okay, I'll have a look into this.
This PR can't be imported anymore. I've opened a new PR with fixes and tests #35316
PR build artifact for d47e1ba00b8238fba0e1474f0ea624dfb8accb52 is ready.
To use, download tarball from "Artifacts" tab in this CircleCI job then run yarn add <path to tarball>
in your React Native project.