Skip to content

Commit

Permalink
chore: fix size for translation flag
Browse files Browse the repository at this point in the history
  • Loading branch information
suisin-deriv authored and heorhi-deriv committed Jun 21, 2024
1 parent 8832c86 commit 21d99be
Show file tree
Hide file tree
Showing 5 changed files with 35 additions and 29 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ const LanguageRadioButton = ({ is_current_language, id, language_text, name, onC
<label htmlFor={id} className='settings-language__language--center-label'>
<div>
{TranslationFlag[id] ? (
TranslationFlag[id]()
TranslationFlag[id](36, 24)
) : (
<Icon icon={`IcFlag${id}`} className='settings-language__language-flag' />
)}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ const ToggleLanguageSettings = observer(() => {
>
<Popover alignment='top' message={localize('Language')} zIndex='9999'>
{TranslationFlag[currentLang] ? (
TranslationFlag[currentLang]('xs')
TranslationFlag[currentLang](18, 12)
) : (
//TODOs: remove this when Korean flag is included in quill-icons
<Icon icon={`IcFlag${currentLang}`} data_testid='dt_icon' size={18} />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ const MenuTitle = observer(() => {
{!is_mobile_language_menu_open && (
<React.Fragment>
{TranslationFlag[current_language] ? (
TranslationFlag[current_language]('xs')
TranslationFlag[current_language](22, 16)
) : (
//TODOs: remove this when Korean flag is added to quill-icons
<Icon icon={`IcFlag${current_language}`} data_testid='dt_icon' size={18} />
Expand Down
5 changes: 2 additions & 3 deletions packages/core/src/App/Components/Routes/language-link.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,8 @@ import React from 'react';
import classNames from 'classnames';
import { observer, useStore } from '@deriv/stores';
import { Icon } from '@deriv/components';
import { TranslationFlag } from '@deriv/shared';
import { TranslationFlag, UNSUPPORTED_LANGUAGES } from '@deriv/shared';
import { getAllowedLanguages, useTranslations } from '@deriv-com/translations';
import { UNSUPPORTED_LANGUAGES } from '@deriv/shared';

export type TLanguageLink = {
is_clickable?: boolean;
Expand All @@ -21,7 +20,7 @@ const LanguageLink = observer(({ is_clickable = false, lang, toggleModal }: TLan
const link: React.ReactNode = (
<React.Fragment>
{TranslationFlag[lang] ? (
TranslationFlag[lang]()
TranslationFlag[lang](36, 24)
) : (
<Icon icon={`IcFlag${lang}`} className='settings-language__language-flag' />
)}
Expand Down
53 changes: 30 additions & 23 deletions packages/shared/src/utils/constants/translation-flag.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,29 +21,36 @@ import {
FlagVietnamIcon,
} from '@deriv/quill-icons';

type TTranslationFlag = {
[key: string]: (size?: 'sm' | 'md' | 'lg' | 'xs') => React.ReactNode;
const flagComponents = {
AR: FlagArabLeagueIcon,
EN: FlagUnitedKingdomIcon,
ES: FlagSpainIcon,
BN: FlagBangladeshIcon,
DE: FlagGermanyIcon,
FR: FlagFranceIcon,
ID: FlagIndonesiaIcon,
IT: FlagItalyIcon,
// KO: ,
MN: FlagMongoliaIcon,
PL: FlagPolandIcon,
PT: FlagPortugalIcon,
RU: FlagRussiaIcon,
SI: FlagSriLankaIcon,
SW: FlagTanzaniaIcon,
TR: FlagTurkeyIcon,
VI: FlagVietnamIcon,
ZH_CN: FlagChinaSimplifiedIcon,
ZH_TW: FlagChinaTraditionalIcon,
TH: FlagThailandIcon,
};

export const TranslationFlag: TTranslationFlag = {
AR: size => <FlagArabLeagueIcon iconSize={size} />,
EN: size => <FlagUnitedKingdomIcon iconSize={size} />,
ES: size => <FlagSpainIcon iconSize={size} />,
BN: size => <FlagBangladeshIcon iconSize={size} />,
DE: size => <FlagGermanyIcon iconSize={size} />,
FR: size => <FlagFranceIcon iconSize={size} />,
ID: size => <FlagIndonesiaIcon iconSize={size} />,
IT: size => <FlagItalyIcon iconSize={size} />,
// KO: ,
MN: size => <FlagMongoliaIcon iconSize={size} />,
PL: size => <FlagPolandIcon iconSize={size} />,
PT: size => <FlagPortugalIcon iconSize={size} />,
RU: size => <FlagRussiaIcon iconSize={size} />,
SI: size => <FlagSriLankaIcon iconSize={size} />,
SW: size => <FlagTanzaniaIcon iconSize={size} />,
TR: size => <FlagTurkeyIcon iconSize={size} />,
VI: size => <FlagVietnamIcon iconSize={size} />,
ZH_CN: size => <FlagChinaSimplifiedIcon iconSize={size} />,
ZH_TW: size => <FlagChinaTraditionalIcon iconSize={size} />,
TH: size => <FlagThailandIcon iconSize={size} />,
type TTranslationFlag = {
[key: string]: (width?: number, height?: number) => React.ReactNode;
};

export const TranslationFlag: TTranslationFlag = Object.fromEntries(
Object.entries(flagComponents).map(([key, FlagComponent]) => [
key,
(width, height) => <FlagComponent width={width} height={height} />,
])
);

0 comments on commit 21d99be

Please sign in to comment.