react-native icon indicating copy to clipboard operation
react-native copied to clipboard

feat: mapped layout props for view component

Open mayank-96 opened this issue 2 years ago • 24 comments

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>

mayank-96 avatar Sep 05 '22 07:09 mayank-96

What about shorthands? See https://github.com/facebook/react-native/issues/34425#issuecomment-1236664129

efoken avatar Sep 05 '22 07:09 efoken

What about shorthands? See #34425 (comment)

Hello @necolas, Should we include this props as well?

mayank-96 avatar Sep 05 '22 08:09 mayank-96

Yes let's include those too. Thanks

necolas avatar Sep 05 '22 15:09 necolas

Please can we add unit tests / examples for this?

necolas avatar Sep 06 '22 04:09 necolas

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

analysis-bot avatar Sep 06 '22 12:09 analysis-bot

Platform Engine Arch Size (bytes) Diff
ios - universal n/a --

Base commit: 5fb67b0fb21b0fa56106dad0bba8cca676451a4e Branch: main

analysis-bot avatar Sep 06 '22 13:09 analysis-bot

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

necolas avatar Sep 06 '22 16:09 necolas

@mayank-96 could you rebase the PR, please?

cipolleschi avatar Sep 09 '22 10:09 cipolleschi

Hello @cipolleschi, I'm rebasing it.

mayank-96 avatar Sep 09 '22 10:09 mayank-96

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.

mayank-96 avatar Sep 09 '22 13:09 mayank-96

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

necolas avatar Sep 12 '22 20:09 necolas

@mayank-96 please rebase and resolve conflicts again, then @cipolleschi can import it. Thanks!

necolas avatar Oct 06 '22 18:10 necolas

If you touched the type definitions, remember to update also the typescript types!

cipolleschi avatar Oct 07 '22 11:10 cipolleschi

@mayank-96 ping

necolas avatar Oct 12 '22 18:10 necolas

@cipolleschi I think we'll need to rebase this ourselves as the author is no longer responding

necolas avatar Oct 18 '22 16:10 necolas

Hello @necolas, sorry I couldn't respond you earlier due to some health issues. I'll rebase this PR today itself.

mayank-96 avatar Oct 21 '22 13:10 mayank-96

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.

pull-bot avatar Nov 08 '22 00:11 pull-bot

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.

pull-bot avatar Nov 08 '22 00:11 pull-bot

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.

pull-bot avatar Nov 08 '22 01:11 pull-bot

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.

pull-bot avatar Nov 08 '22 01:11 pull-bot

@necolas has imported this pull request. If you are a Meta employee, you can view this diff on Phabricator.

facebook-github-bot avatar Nov 08 '22 02:11 facebook-github-bot

@necolas has imported this pull request. If you are a Meta employee, you can view this diff on Phabricator.

facebook-github-bot avatar Nov 08 '22 04:11 facebook-github-bot

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.

pull-bot avatar Nov 08 '22 04:11 pull-bot

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.

pull-bot avatar Nov 08 '22 04:11 pull-bot

This pull request was successfully merged by @mayank-96 in cf3747957ab210e31504109bb6b3e34e773a5b9a.

When will my fix make it into a release? | Upcoming Releases

react-native-bot avatar Nov 08 '22 21:11 react-native-bot

This patched broke text layout internally and needed to be backed out

necolas avatar Nov 09 '22 01:11 necolas

This pull request has been reverted by 114098d419e2a7a254f81b9eb9f0cc542194a660.

facebook-github-bot avatar Nov 09 '22 04:11 facebook-github-bot

Okay, I'll have a look into this.

mayank-96 avatar Nov 09 '22 09:11 mayank-96

This PR can't be imported anymore. I've opened a new PR with fixes and tests #35316

necolas avatar Nov 11 '22 20:11 necolas

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.

pull-bot avatar Nov 11 '22 20:11 pull-bot