Skip to content

Commit

Permalink
fix: rtl support for registration screen too
Browse files Browse the repository at this point in the history
  • Loading branch information
Bilb committed Aug 21, 2023
1 parent bee0015 commit ada5497
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 9 deletions.
7 changes: 0 additions & 7 deletions stylesheets/_session_signin.scss
Original file line number Diff line number Diff line change
Expand Up @@ -145,13 +145,6 @@
position: absolute;
bottom: 0px;
}

.session-icon-button {
position: absolute;
top: 50%;
transform: translateY(-50%);
right: 0px;
}
}

&-terms-conditions-agreement {
Expand Down
13 changes: 12 additions & 1 deletion ts/components/basic/SessionInput.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import React, { useState } from 'react';
import classNames from 'classnames';
import { SessionIconButton } from '../icon';
import { Noop } from '../../types/Util';
import { useHTMLDirection } from '../../util/i18n';

type Props = {
label?: string;
Expand Down Expand Up @@ -46,7 +47,17 @@ const ErrorItem = (props: { error: string | undefined }) => {
};

const ShowHideButton = (props: { toggleForceShow: Noop }) => {
return <SessionIconButton iconType="eye" iconSize="medium" onClick={props.toggleForceShow} />;
const htmlDirection = useHTMLDirection();
const position = htmlDirection === 'ltr' ? { right: '0px' } : { left: '0px' };

return (
<SessionIconButton
iconType="eye"
iconSize="medium"
onClick={props.toggleForceShow}
style={{ position: 'absolute', top: '50%', transform: 'translateY(-50%)', ...position }}
/>
);
};

export const SessionInput = (props: Props) => {
Expand Down
7 changes: 6 additions & 1 deletion ts/mains/main_renderer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -267,13 +267,17 @@ async function start() {
await connect();
});

function openInbox() {
function switchBodyToRtlIfNeeded() {
const rtlLocales = ['fa', 'ar', 'he'];

const loc = (window.i18n as any).getLocale();
if (rtlLocales.includes(loc) && !document.getElementById('body')?.classList.contains('rtl')) {
document.getElementById('body')?.classList.add('rtl');
}
}

function openInbox() {
switchBodyToRtlIfNeeded();
const hideMenuBar = Storage.get('hide-menu-bar', true) as boolean;
window.setAutoHideMenuBar(hideMenuBar);
window.setMenuBarVisibility(!hideMenuBar);
Expand All @@ -287,6 +291,7 @@ async function start() {

function showRegistrationView() {
ReactDOM.render(<SessionRegistrationView />, document.getElementById('root'));
switchBodyToRtlIfNeeded();
}
ExpirationTimerOptions.initExpiringMessageListener();

Expand Down

0 comments on commit ada5497

Please sign in to comment.