Skip to content

RTL for arabic languages 1.14#17767

Merged
Wojdylak merged 2 commits intoSylius:1.14from
bartek-sek:SYL-4537/1_14-rtl
Mar 25, 2025
Merged

RTL for arabic languages 1.14#17767
Wojdylak merged 2 commits intoSylius:1.14from
bartek-sek:SYL-4537/1_14-rtl

Conversation

@bartek-sek
Copy link
Copy Markdown
Contributor

@bartek-sek bartek-sek commented Mar 24, 2025

Q A
Branch? 1.14
Bug fix? no
New feature? yes
BC breaks? no
Deprecations? no
Related tickets
License MIT

Summary by CodeRabbit

  • New Features

    • Enhanced support for right-to-left (RTL) language layouts. The interface now dynamically adapts based on locale settings.
  • Style

    • Updated visual styling across components for improved consistency and display in RTL mode, ensuring a seamless user experience.

@bartek-sek bartek-sek requested review from a team as code owners March 24, 2025 12:46
@probot-autolabeler probot-autolabeler bot added Admin AdminBundle related issues and PRs. Shop ShopBundle related issues and PRs. labels Mar 24, 2025
@coderabbitai
Copy link
Copy Markdown

coderabbitai bot commented Mar 24, 2025

Walkthrough

This pull request adds right-to-left (RTL) layout support. The changes modify twig layout files by importing an RTL macro and updating the <body> tag to conditionally apply RTL attributes based on the application locale. New SCSS/Sass files are introduced to provide RTL-specific styling for various components, with additional import statements to integrate these styles. A new macro in the UI bundle checks the locale against a list of RTL languages.

Changes

File(s) Change Summary
src/Sylius/Bundle/AdminBundle/.../layout.html.twig
src/Sylius/Bundle/ShopBundle/.../layout.html.twig
Added import of RTL macro and updated <body> tag to dynamically apply RTL attributes based on app.locale.
src/Sylius/Bundle/ShopBundle/.../scss/rtl.scss (new)
src/Sylius/Bundle/ShopBundle/.../scss/style.scss (import added)
src/Sylius/Bundle/UiBundle/.../sass/rtl.scss (new)
src/Sylius/Bundle/UiBundle/.../sass/main.scss (import added)
Introduced new RTL SCSS/Sass files with styles for right-to-left layouts and added import statements to include these styles in the main style sheets.
src/Sylius/Bundle/UiBundle/.../Macro/rtl.html.twig Introduced a new macro default that checks the locale against RTL language codes and returns the appropriate RTL attribute.

Sequence Diagram(s)

sequenceDiagram
  participant T as Layout Template
  participant R as RTL Macro
  participant L as App Locale
  T->>R: Call rtl.default(app.locale)
  R->>T: Return RTL attribute if locale is RTL (ar, he, fa, ur, ps, ku)
Loading

Suggested labels

UX

Suggested reviewers

  • Wojdylak
  • mpysiak
  • GSadee

Poem

I’m a rabbit with a joyful pace,
Hopping through code with grace.
RTL styles now guide our way,
Making layouts adapt and sway.
With whiskers twitched and heart so light,
I celebrate these changes in pure delight! 🐰
Happy coding to all this night!


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ 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 generate docstrings to generate docstrings for this 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.

@bartek-sek bartek-sek changed the base branch from 2.1 to 1.14 March 24, 2025 12:46
Copy link
Copy Markdown

@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

🧹 Nitpick comments (2)
src/Sylius/Bundle/UiBundle/Resources/views/Macro/rtl.html.twig (1)

1-9: Twig macro looks good but consider supporting locale variants

The RTL detection macro correctly identifies the main RTL languages (Arabic, Hebrew, Persian, Urdu, Pashto, and Kurdish). The implementation follows good practices by checking if the locale starts with any of these language codes.

One minor improvement would be to consider region-specific locale variants (like 'ar-SA', 'ar-EG', etc.) by using a more robust comparison or documentation to clarify that such variants are already supported by the starts with check.

src/Sylius/Bundle/UiBundle/Resources/private/sass/rtl.scss (1)

4-12: Text direction handling looks good but consider refining input selectors

The input text alignment and direction settings correctly handle different input types, with special cases for numbers, emails, and translation fields.

This approach ensures that content is properly displayed in RTL contexts while preserving LTR for content that needs it (like numbers).

Consider consolidating these selectors for better maintainability:

-input:not(input[type="number"], input[type="email"], input[name*="translations"]), textarea {
+input:not([type="number"]):not([type="email"]):not([name*="translations"]), 
+textarea:not([name*="translations"]) {
   unicode-bidi: bidi-override;
   text-align: right;
}
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 38b4c5d and 64af3c9.

📒 Files selected for processing (7)
  • src/Sylius/Bundle/AdminBundle/Resources/views/Layout/layout.html.twig (2 hunks)
  • src/Sylius/Bundle/ShopBundle/Resources/private/scss/rtl.scss (1 hunks)
  • src/Sylius/Bundle/ShopBundle/Resources/private/scss/style.scss (1 hunks)
  • src/Sylius/Bundle/ShopBundle/Resources/views/layout.html.twig (2 hunks)
  • src/Sylius/Bundle/UiBundle/Resources/private/sass/main.scss (1 hunks)
  • src/Sylius/Bundle/UiBundle/Resources/private/sass/rtl.scss (1 hunks)
  • src/Sylius/Bundle/UiBundle/Resources/views/Macro/rtl.html.twig (1 hunks)
🔇 Additional comments (19)
src/Sylius/Bundle/UiBundle/Resources/private/sass/main.scss (1)

3-3: Implementation of RTL support looks good.

The addition of the RTL stylesheet import is well-placed after the variables and filters imports, ensuring that RTL styles can properly override or extend the base styles.

src/Sylius/Bundle/ShopBundle/Resources/private/scss/style.scss (1)

2-2: RTL stylesheet import is correctly placed.

The import is positioned after the theme import, which is appropriate as RTL styles should override base theme styles.

src/Sylius/Bundle/ShopBundle/Resources/views/layout.html.twig (2)

1-2: RTL macro import is well-structured.

Importing the RTL macro at the top of the template follows best practices for template organization.


27-27: RTL attribute application looks good.

Applying the RTL attribute conditionally based on the application locale is the correct approach for implementing RTL layout support.

src/Sylius/Bundle/AdminBundle/Resources/views/Layout/layout.html.twig (2)

1-2: RTL macro import follows template best practices.

The import statement is appropriately placed at the top of the template file.


24-24: RTL attribute application for admin layout.

The implementation correctly applies RTL attributes conditionally based on the application locale, maintaining consistency with the shop layout implementation.

src/Sylius/Bundle/UiBundle/Resources/private/sass/rtl.scss (7)

1-3: Well-structured RTL styles with appropriate selector

Using the [dir="rtl"] attribute selector is the correct approach for targeting RTL layout styles, as it works with the HTML attribute set by the Twig macro.


14-20: Admin navigation menu padding correctly adjusted

The padding adjustment for the admin menu headers is appropriate for RTL layout.


22-24: Header icon spacing properly adjusted

Setting padding-right for icon content in headers ensures proper spacing in RTL mode.


26-29: Table and dropdown text alignment is appropriate

Setting text-align to right for tables and dropdowns is necessary for consistent RTL layout.


31-33: Filter group border fix is appropriate

Ensuring border-right-width is set correctly for filter group inputs and selects addresses potential rendering issues in RTL layouts.


35-39: Float and margin adjustments for buttons are correct

The right-floated buttons are properly adjusted to float left in RTL mode, with appropriate margin adjustments.


41-88: Comprehensive RTL adjustments for UI components

The adjustments for icons, messages, menus, avatar images, labels, grid alignments, and filters are comprehensive and appropriate for RTL layout. The transformations mirror the layout correctly for right-to-left reading direction.

I particularly appreciate:

  • Use of unset for properties that need to be removed
  • Adjusting background-position for select elements to show dropdown arrows in correct position
  • Proper margin adjustments for icons and UI elements

These changes will ensure a consistent RTL experience across the Sylius UI components.

src/Sylius/Bundle/ShopBundle/Resources/private/scss/rtl.scss (6)

1-4: Filter background position correctly adjusted

The select dropdown background position is properly adjusted for RTL layout, ensuring the arrow appears in the correct position.


6-18: Responsive product detail layout properly handled

The media queries for product detail page layouts correctly adjust padding for different screen sizes in RTL context. The use of !important is justified here to override any existing styles.


20-26: Grid column shadows correctly handled

Box-shadow adjustments for divided grid columns ensure the visual separator appears on the correct side in RTL layouts, with special handling for the first column.


28-36: Step component transformation is impressive

The step component is properly transformed for RTL layout, with the connector arrow positioning and rotation correctly adjusted. Icon margin is also appropriately set.


38-54: Homepage banner positioning handled well

The header styling and banner content positioning are correctly adjusted for RTL layout across different screen sizes. The use of unset and repositioning is appropriate.


56-71: Horizontal list and address card styling properly adjusted

Border and padding adjustments for horizontal list items and address card buttons are correctly implemented for RTL layout. The separate handling of first/last items ensures consistent spacing.

@bartek-sek bartek-sek changed the title Syl 4537/1 14 rtl RTL for arabic languages 1.14 Mar 24, 2025
@GSadee GSadee added the Enhancement Minor issues and PRs improving the current solutions (optimizations, typo fixes, etc.). label Mar 25, 2025
@Wojdylak Wojdylak merged commit ba4834e into Sylius:1.14 Mar 25, 2025
2 checks passed
GSadee added a commit that referenced this pull request Mar 26, 2025
| Q               | A
|-----------------|-----
| Branch?         | 1.14
| Bug fix?        | yes
| New feature?    | no
| BC breaks?      | no
| Deprecations?   | no
| Related tickets | #17767 
| License         | MIT

<!--
 - Bug fixes must be submitted against the 1.13 branch
 - Features and deprecations must be submitted against the 1.14 branch
- Features, removing deprecations and BC breaks must be submitted
against the 2.0 branch
 - Make sure that the correct base branch is set

To be sure you are not breaking any Backward Compatibilities, check the
documentation:

https://docs.sylius.com/en/latest/book/organization/backward-compatibility-promise.html
-->
@coderabbitai coderabbitai bot mentioned this pull request Mar 27, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Admin AdminBundle related issues and PRs. Enhancement Minor issues and PRs improving the current solutions (optimizations, typo fixes, etc.). Shop ShopBundle related issues and PRs.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants