Skip to content

Commit

Permalink
[TRAH] Sergei / TRAH - 3699 / 'Compare CFDs accounts' page does not h…
Browse files Browse the repository at this point in the history
…ave side arrow options for navigation for Arabic language (#15670)

* feat: add isRtl for carousel in cfd compare accounts

* feat: implement review suggestions
  • Loading branch information
sergei-deriv authored Jun 25, 2024
1 parent 22b764d commit 23354ea
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import { Text, Icon, PageOverlay, DesktopWrapper, MobileWrapper, CFDCompareAccou
import { routes } from '@deriv/shared';
import { Localize, localize } from '@deriv/translations';
import { observer, useStore } from '@deriv/stores';
import { useIsRtl } from '@deriv/hooks';
import CFDCompareAccountsCard from './cfd-compare-accounts-card';
import {
getSortedCFDAvailableAccounts,
Expand All @@ -18,6 +19,7 @@ import {
import { REGION } from '../../Helpers/cfd-config';

const CompareCFDs = observer(() => {
const is_rtl = useIsRtl();
const history = useHistory();
const store = useStore();
const { client, traders_hub } = store;
Expand Down Expand Up @@ -106,7 +108,7 @@ const CompareCFDs = observer(() => {
})}
>
<div className='card-list'>
<CFDCompareAccountsCarousel>
<CFDCompareAccountsCarousel isRtl={is_rtl}>
{all_cfd_available_accounts.map(item => (
<CFDCompareAccountsCard
trading_platforms={item}
Expand Down Expand Up @@ -148,7 +150,7 @@ const CompareCFDs = observer(() => {
'compare-cfd-account-container__card-count--mobile': card_count < 2,
})}
>
<CFDCompareAccountsCarousel>
<CFDCompareAccountsCarousel isRtl={is_rtl}>
{all_cfd_available_accounts.map(item => (
<CFDCompareAccountsCard
trading_platforms={item}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,15 @@ import Icon from '../icon';
type TPrevNextButtonProps = {
enabled: boolean;
onClick: () => void;
isNext: boolean;
isNext?: boolean;
isRtl?: boolean;
};

const CFDCompareAccountsCarouselButton = (props: TPrevNextButtonProps) => {
const { enabled, onClick, isNext } = props;
const { enabled, onClick, isNext = false, isRtl = false } = props;

const nextButtonName = isRtl ? 'IcChevronLeftBold' : 'IcChevronRightBold';
const prevButtonName = isRtl ? 'IcChevronRightBold' : 'IcChevronLeftBold';

return (
<button
Expand All @@ -21,7 +25,7 @@ const CFDCompareAccountsCarouselButton = (props: TPrevNextButtonProps) => {
disabled={!enabled}
>
<Icon
icon={isNext ? 'IcChevronRightBold' : 'IcChevronLeftBold'}
icon={isNext ? nextButtonName : prevButtonName}
className='cfd-compare-accounts-carousel__button__svg'
/>
</button>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,14 @@ import CFDCompareAccountsCarouselButton from './cfd-compare-accounts-carousel-bu

type TCFDCompareAccountsCarousel = {
children: React.ReactNode;
isRtl?: boolean;
};

const CFDCompareAccountsCarousel = (props: TCFDCompareAccountsCarousel) => {
const CFDCompareAccountsCarousel = ({ children, isRtl = false }: TCFDCompareAccountsCarousel) => {
const options: EmblaOptionsType = {
align: 0,
containScroll: 'trimSnaps',
direction: isRtl ? 'rtl' : 'ltr',
};
const [emblaRef, emblaApi] = useEmblaCarousel(options);
const [prev_btn_enabled, setPrevBtnEnabled] = React.useState(false);
Expand All @@ -34,10 +36,10 @@ const CFDCompareAccountsCarousel = (props: TCFDCompareAccountsCarousel) => {
return (
<div className='cfd-compare-accounts-carousel'>
<div className='cfd-compare-accounts-carousel__viewport' ref={emblaRef}>
<div className='cfd-compare-accounts-carousel__container'>{props.children}</div>
<div className='cfd-compare-accounts-carousel__container'>{children}</div>
</div>
<CFDCompareAccountsCarouselButton onClick={scrollPrev} isNext={false} enabled={prev_btn_enabled} />
<CFDCompareAccountsCarouselButton onClick={scrollNext} isNext={true} enabled={next_btn_enabled} />
<CFDCompareAccountsCarouselButton onClick={scrollPrev} enabled={prev_btn_enabled} isRtl={isRtl} />
<CFDCompareAccountsCarouselButton onClick={scrollNext} isNext enabled={next_btn_enabled} isRtl={isRtl} />
</div>
);
};
Expand Down

0 comments on commit 23354ea

Please sign in to comment.