2024-07-17 16:08:13 +02:00
|
|
|
import React from 'react';
|
|
|
|
|
import { useRecoilState } from 'recoil';
|
|
|
|
|
import { useLocalize } from '~/hooks';
|
2024-09-22 04:45:50 +02:00
|
|
|
import { Button } from '~/components';
|
2024-07-17 16:08:13 +02:00
|
|
|
import store from '~/store';
|
|
|
|
|
|
|
|
|
|
const ChatDirection = () => {
|
|
|
|
|
const [direction, setDirection] = useRecoilState(store.chatDirection);
|
|
|
|
|
const localize = useLocalize();
|
|
|
|
|
|
|
|
|
|
const toggleChatDirection = () => {
|
|
|
|
|
setDirection((prev) => (prev === 'LTR' ? 'RTL' : 'LTR'));
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
return (
|
|
|
|
|
<div className="flex items-center justify-between">
|
|
|
|
|
<div className="flex items-center space-x-2">
|
2024-09-10 10:11:39 -09:00
|
|
|
<span id="chat-direction-label">{localize('com_nav_chat_direction')}</span>
|
2024-07-17 16:08:13 +02:00
|
|
|
</div>
|
2024-09-22 04:45:50 +02:00
|
|
|
<Button
|
|
|
|
|
variant="outline"
|
|
|
|
|
aria-label="Toggle chat direction"
|
2024-07-17 16:08:13 +02:00
|
|
|
onClick={toggleChatDirection}
|
|
|
|
|
data-testid="chatDirection"
|
|
|
|
|
>
|
2024-09-10 10:11:39 -09:00
|
|
|
<span aria-hidden="true">{direction.toLowerCase()}</span>
|
|
|
|
|
<span id="chat-direction-status" className="sr-only">
|
|
|
|
|
{direction === 'LTR'
|
|
|
|
|
? localize('chat_direction_left_to_right')
|
|
|
|
|
: localize('chat_direction_right_to_left')}
|
|
|
|
|
</span>
|
2024-09-22 04:45:50 +02:00
|
|
|
</Button>
|
2024-07-17 16:08:13 +02:00
|
|
|
</div>
|
|
|
|
|
);
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
export default ChatDirection;
|