Input: support RTL detection on all Inputs, remove from AutosuggestInput

This commit is contained in:
Alex Gleason
2023-10-11 13:33:45 -05:00
parent 39786aa5f2
commit 9036d8a9a0
4 changed files with 9 additions and 14 deletions

View File

@@ -2,21 +2,19 @@ import { getLocale } from 'soapbox/actions/settings';
import { useAppSelector } from './useAppSelector';
import type { CSSProperties } from 'react';
/** Locales which should be presented in right-to-left. */
const RTL_LOCALES = ['ar', 'ckb', 'fa', 'he'];
interface UseLocaleResult {
locale: string;
direction: CSSProperties['direction'];
direction: 'ltr' | 'rtl';
}
/** Get valid locale from settings. */
const useLocale = (fallback = 'en'): UseLocaleResult => {
const locale = useAppSelector((state) => getLocale(state, fallback));
const direction: CSSProperties['direction'] =
const direction: 'ltr' | 'rtl' =
RTL_LOCALES.includes(locale)
? 'rtl'
: 'ltr';