Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: move paddingHorizontal out from content style #1078

Merged
merged 3 commits into from
May 30, 2019

Conversation

jose96043
Copy link
Contributor

@jose96043 jose96043 commented May 20, 2019

Motivation

The ability of overriding style properties makes things more flexible. In order to achieve this within DataTableRow, we have moved paddingHorizontal out from content style which can't be overridden, and put it in container style which can be overridden with the style class property.

Test plan

The current implementation enforces a paddingHorizontal of 16 as default for the content style. This style is inherited by both TouchableRipple and its child view. TouchableRipple container values can be overridden by passing the style property value when creating a DataTableRow, but the child view will always have the paddingHorizontal value of 16. As part of this commit we will allow the style class property to override the child view as well.
@callstack-bot
Copy link

callstack-bot commented May 20, 2019

Hey @jose96043, thank you for your pull request 🤗. The documentation from this branch can be viewed here. Please remember to update Typescript types if you changed API.

@@ -40,7 +40,7 @@ class DataTableRow extends React.Component<Props> {
onPress={onPress}
style={[styles.container, { borderBottomColor }, style]}
>
<View style={styles.content}>{this.props.children}</View>
<View style={[styles.content, style]}>{this.props.children}</View>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think we want to duplicate style like this, you apply some padding and now it'll get applied 2 times

Copy link
Contributor Author

@jose96043 jose96043 May 20, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sorry good point can we have a content field exposed as part of the class? Or can we remove the hard coded padding of 16? This limits how customizable the class can be.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't remember why the inner view is needed at all. Can we remove it? cc @jaulz

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think I put it there because a TouchableRipple can only have a single child.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jaulz Is there a reason why there needs to be a horizontalPadding of 16?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How about moving the padding to the TouchableRipple styles so it can be overriden by user's passed style?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yep, that should be fine. The padding is part of the specs.

Copy link
Contributor Author

@jose96043 jose96043 May 21, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@satya164 I have updated the commit with your suggestion. I tested it and it works as expected. Please take a look. Thanks! cc @jaulz

jose96043 added 2 commits May 21, 2019 11:59
The ability of overriding style properties makes things more flexible. In order to achieve this within DataTableRow,  we have moved paddingHorizontal out from content style which can't be overridden, and put it in container style which can be overridden with the style class property.
@jose96043 jose96043 changed the title feat: add style for internal DataTableRow view fix: move paddingHorizontal out from content style May 21, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants