Skip to content

Support RTL in ResponsiveGrid #51

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 3 commits into from
Dec 5, 2024
Merged

Conversation

forabi
Copy link
Contributor

@forabi forabi commented Dec 4, 2024

Fixes #50

Summary by CodeRabbit

  • New Features

    • Introduced a new direction prop for the ResponsiveGrid component, allowing users to specify layout direction (left-to-right or right-to-left).
  • Documentation

    • Updated the README to include details about the new direction prop and refined descriptions for clarity across grid components.

Copy link

coderabbitai bot commented Dec 4, 2024

Caution

Review failed

The pull request is closed.

Walkthrough

The pull request introduces a new direction prop to the ResponsiveGrid component, allowing it to support both left-to-right (LTR) and right-to-left (RTL) layouts. The layout logic is modified to utilize this prop for positioning items dynamically. Additionally, the ResponsiveGridProps interface is updated to include the new direction property. The changes enhance the component's responsiveness to layout direction while ensuring existing functionalities remain intact.

Changes

File Change Summary
src/responsive-grid/index.tsx Added a direction prop to ResponsiveGrid, modified layout logic to use a computed style function for alignment. Updated effect hook to reset onEndReachedCalled flag.
src/responsive-grid/types.ts Introduced a new optional property `direction?: 'rtl'
README.md Updated documentation to include the new direction prop for ResponsiveGrid, refining existing prop descriptions for clarity.

Assessment against linked issues

Objective Addressed Explanation
Support RTL layout in ResponsiveGrid (#50)

Possibly related PRs

  • implemented autoAdjustItemWidth for FlexGrid & ResponsiveGrid #42: The changes in this PR involve adding a new prop autoAdjustItemWidth to the ResponsiveGrid component, which is directly related to the modifications made in the main PR that also introduced a new prop direction and updated the rendering logic in the same component.

Poem

🐰 In the grid where items play,
Left or right, they find their way.
With a prop to guide their dance,
RTL or LTR, they take a chance.
Responsive hops, a joyful sight,
Layouts twirl, both day and night! 🌟


📜 Recent review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Reviewing files that changed from the base of the PR and between 1fa751c and b4485f1.

📒 Files selected for processing (3)
  • README.md (1 hunks)
  • src/responsive-grid/index.tsx (3 hunks)
  • src/responsive-grid/types.ts (1 hunks)

Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

🧹 Outside diff range and nitpick comments (3)
src/responsive-grid/types.ts (1)

71-72: Add JSDoc documentation for the direction prop

The type definition is correct, but adding documentation would improve developer experience and make the RTL support more discoverable.

+  /** 
+   * Controls the layout direction of the grid.
+   * - 'ltr': Items are laid out from left to right (default)
+   * - 'rtl': Items are laid out from right to left
+   * @default 'ltr'
+   */
   direction?: 'rtl' | 'ltr';
src/responsive-grid/index.tsx (2)

163-163: Consider renaming item.left for better semantics

The property name item.left might be confusing when used in RTL mode. Consider renaming it to item.offset or similar to better represent its purpose in both LTR and RTL contexts.

This would require changes in the calcResponsiveGrid function as well. Would you like me to help with this refactor?


29-31: Consider additional RTL experience improvements

While the basic RTL layout is implemented, consider enhancing the RTL support with:

  1. RTL-aware scroll behavior
  2. RTL-aware gesture handling
  3. RTL-aware animations

This would provide a more complete RTL experience for users.

Would you like guidance on implementing any of these enhancements?

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Reviewing files that changed from the base of the PR and between 16fde69 and 1fa751c.

📒 Files selected for processing (2)
  • src/responsive-grid/index.tsx (2 hunks)
  • src/responsive-grid/types.ts (1 hunks)
🔇 Additional comments (2)
src/responsive-grid/index.tsx (2)

29-31: LGTM! Clean implementation of direction support

The direction prop with default 'ltr' and the dynamic start position computation is well implemented.


31-31: Verify RTL implementation with various scenarios

Let's verify the RTL implementation works correctly in different scenarios.

Also applies to: 163-163

@iNerdStack
Copy link
Owner

Hello @forabi
Thank you for raising the issue and addressing it.
I will review it in some hours from now & merge

@iNerdStack
Copy link
Owner

@forabi
I have added documentation for your implementation and will merge and publish a new version now
Thank you for your contribution

@iNerdStack iNerdStack merged commit 597be88 into iNerdStack:main Dec 5, 2024
5 of 6 checks passed
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.

RTL support
2 participants