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

The sidebar component does not support RTL #551

Open
aligjahed opened this issue Jan 14, 2025 · 1 comment
Open

The sidebar component does not support RTL #551

aligjahed opened this issue Jan 14, 2025 · 1 comment

Comments

@aligjahed
Copy link

aligjahed commented Jan 14, 2025

Summary

Having direction: rtl; in the body breaks sidebar animation

Steps to Reproduce

  1. Copy "content push" side bar from preline ui docs
  2. Paste it in a html
  3. add dir="rtl" to the html or direction:rtl; to the body style

Demo Link

https://stackblitz.com/edit/vitejs-vite-umxbmzea?file=index.html

Expected Behavior

When adding direction: rtl; to the body or dir='rtl' to the html tag it's expected that the animation also follows the other parts of the side bar and become RTL.

Actual Behavior

Instead the animation breaks when opening the menu on mobile devices. it first snaps to the left and then gradually moves right

Screenshots

No response

@aligjahed
Copy link
Author

aligjahed commented Jan 14, 2025

The solution to this problem was fairly simple. i tried to create a PR for a fix but realized this is not the repo for components! anyway, in the sidebar class we have this:

hs-overlay-open:translate-x-0 -translate-x-full

which works just fine for LTR but not for RTL. to fix it we have to invert translate for respective mode. we have to invert the -translate-x-full.

so this part of the class should be replaced with this ( at least this is what i came up with and it worked just fine ):

hs-overlay-open:translate-x-0 ltr:-translate-x-full rtl:translate-x-full

the final class for div with id "hs-sidebar-content-push" in the docs will look like this:
hs-overlay [--auto-close:lg] lg:block lg:translate-x-0 lg:start-auto lg:bottom-0 w-64 hs-overlay-open:-translate-x-0 translate-x-full transition-all duration-300 transform h-full hidden fixed top-0 start-0 bottom-0 z-[60] bg-white border-e border-gray-200

here's the screenshot of the modified component ( only the sidebar ):
image

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

No branches or pull requests

1 participant