Skip to content

GridListItem - horizontal alignment support #3001

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

Merged
merged 10 commits into from
Apr 9, 2024

Conversation

adids1221
Copy link
Contributor

@adids1221 adids1221 commented Mar 27, 2024

Description

Grid List Item support in horizontal alignment.
New horizontalAlignment prop to control the horizontal alignment of grid list item in all aspects - text, custom element, image and etc.

Changelog

Grid List Item support in horizontal alignment

Additional info

ticket 4082

@adids1221 adids1221 marked this pull request as ready for review March 28, 2024 09:02
@adids1221 adids1221 requested a review from Inbal-Tish March 28, 2024 09:02
right = 'right'
}

export type ItemHorizontalAlignmentProp = ItemHorizontalAlignment | `${ItemHorizontalAlignment}`;
Copy link
Collaborator

Choose a reason for hiding this comment

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

This is not a good name...

Copy link
Collaborator

Choose a reason for hiding this comment

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

Also, I don't see why we need to declare this type

/**
* Content horizontal alignment (default is center)
*/
horizontalAlignment?: ItemHorizontalAlignmentProp;
Copy link
Collaborator

@Inbal-Tish Inbal-Tish Mar 31, 2024

Choose a reason for hiding this comment

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

Why do we need this prop? Why the user can't just pass 'alignItems' in the containerStyle prop, and 'textAlign' in the style prop?

@adids1221
Copy link
Contributor Author

@Inbal-Tish
I did few changes:

  1. Fixed the overlay use case to support the horizontal alignment
  2. Changed the children type to solve ts error
  3. Changed the prop name as we discussed
  4. I spoke with Ethan for now we won't add any textStyle prop

@adids1221 adids1221 requested a review from Inbal-Tish March 31, 2024 13:23
@Inbal-Tish Inbal-Tish changed the title horizontal alignment support GridListItem - horizontal alignment support Apr 4, 2024
@@ -101,7 +112,7 @@ export interface GridListItemProps {
* Test ID for component
*/
testID?: string;
children?: React.ReactNode;
children?: React.ReactElement;
Copy link
Collaborator

Choose a reason for hiding this comment

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

Can be an array

@@ -73,7 +73,7 @@ export type ImageProps = Omit<RNImageProps, 'source'> &
/**
* Render an overlay with custom content
*/
customOverlayContent?: JSX.Element;
customOverlayContent?: React.ReactElement;
Copy link
Collaborator

Choose a reason for hiding this comment

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

Why the children type change is relevant to this PR?

@adids1221 adids1221 requested a review from Inbal-Tish April 4, 2024 07:36
Typography[typography],
color && {color},
alignToStart && styles.contentAlignedToStart,
horizontalAlignmentStyle?.contentStyle
Copy link
Collaborator

Choose a reason for hiding this comment

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

{textAlign: HorizontalAlignment} - can replace this object, just place it before this line:
alignToStart && styles.contentAlignedToStart, to avoid overriding it

@Inbal-Tish
Copy link
Collaborator

@adids1221 The code is very messy and unclear IMO.
I would suggest to clean the code by:

  1. in the Text pass:
    {textAlign: alignToStart ? 'left' : horizontalAlignment}
  2. in the container pass:
    {alignItems: alignToStart ? 'flex-start' : this.getContainerHorizontalAlignment(horizontalAlignment)},
  3. make getContainerHorizontalAlignment function map to horizontalAlignment prop to alignItems values i.e. 'left' to 'flex-start'

@adids1221 adids1221 requested a review from Inbal-Tish April 7, 2024 13:17
{hasOverlay && <View style={[styles.overlay, this.getItemSizeObj()]}>{renderOverlay?.()}</View>}
<TextContainer {...textContainerStyle}>
{renderOverlay && <View style={[styles.overlay, itemSize]}>{renderOverlay()}</View>}
<View {...textContainerStyle}>
Copy link
Collaborator

Choose a reason for hiding this comment

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

You changed the TextContainer from View or Fragment to View. This can result in alignment issues (if you remember the Icon bug...). Why did you make this change?

style={[styles.container, alignToStart && styles.containerAlignedToStart, {width}, containerStyle]}
style={[
styles.container,
{alignItems: alignToStart ? 'flex-start' : this.getContainerHorizontalAlignment(horizontalAlignment)},
Copy link
Collaborator

Choose a reason for hiding this comment

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

I would move the function call outside of the style

@@ -73,7 +73,7 @@ export type ImageProps = Omit<RNImageProps, 'source'> &
/**
* Render an overlay with custom content
*/
customOverlayContent?: JSX.Element;
customOverlayContent?: React.ReactElement | React.ReactElement[];
Copy link
Collaborator

Choose a reason for hiding this comment

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

What these changes have to do with this PR?

@adids1221 adids1221 added the Important for Next Release PR that must be included in the release version label Apr 8, 2024
@adids1221 adids1221 requested a review from Inbal-Tish April 8, 2024 16:42
@Inbal-Tish Inbal-Tish merged commit 8a7a304 into master Apr 9, 2024
@Inbal-Tish Inbal-Tish deleted the feat/GridListItem_horizontal_alignment branch April 9, 2024 05:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Important for Next Release PR that must be included in the release version
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants