Input: support RTL detection on all Inputs, remove from AutosuggestInput
This commit is contained in:
@@ -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';
|
||||
|
||||
Reference in New Issue
Block a user