signal-desktop/ts/util/keyboard.ts
Jamie Kyle 0e490542a7
RTL
2023-04-20 10:03:43 -07:00

20 lines
666 B
TypeScript

// Copyright 2021 Signal Messenger, LLC
// SPDX-License-Identifier: AGPL-3.0-only
import type { LocaleDirection } from '../../app/locale';
export type LogicalDirection = 'start' | 'end';
export type HorizontalArrowKey = 'ArrowLeft' | 'ArrowRight';
const logicalArrows: Record<
LogicalDirection,
Record<LocaleDirection, HorizontalArrowKey>
> = {
start: { ltr: 'ArrowLeft', rtl: 'ArrowRight' },
end: { ltr: 'ArrowRight', rtl: 'ArrowLeft' },
};
export function arrow(logicalDirection: LogicalDirection): HorizontalArrowKey {
const localeDirection = window.getResolvedMessagesLocaleDirection();
return logicalArrows[logicalDirection][localeDirection];
}