2023-04-20 17:03:43 +00:00
|
|
|
// 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 {
|
2023-08-07 20:28:09 +00:00
|
|
|
const localeDirection =
|
|
|
|
window.SignalContext.getResolvedMessagesLocaleDirection();
|
2023-04-20 17:03:43 +00:00
|
|
|
return logicalArrows[logicalDirection][localeDirection];
|
|
|
|
}
|