diff --git a/packages/wallets/src/components/Base/WalletButton/WalletButton.module.css b/packages/wallets/src/components/Base/WalletButton/WalletButton.module.css index 75bf65e790c8..fde8c975a851 100644 --- a/packages/wallets/src/components/Base/WalletButton/WalletButton.module.css +++ b/packages/wallets/src/components/Base/WalletButton/WalletButton.module.css @@ -72,4 +72,7 @@ background: var(--system-dark-5-active-background, #323738); } } + &-full-width { + width: 100%; + } } diff --git a/packages/wallets/src/components/Base/WalletButton/WalletButton.tsx b/packages/wallets/src/components/Base/WalletButton/WalletButton.tsx index adcadf7a8c00..b0c61fb2b0e9 100644 --- a/packages/wallets/src/components/Base/WalletButton/WalletButton.tsx +++ b/packages/wallets/src/components/Base/WalletButton/WalletButton.tsx @@ -1,35 +1,84 @@ -import React, { ComponentProps, CSSProperties } from 'react'; +import React, { ButtonHTMLAttributes, ReactElement } from 'react'; import classNames from 'classnames'; +import { TGenericSizes } from '../types'; +import { WalletText } from '../WalletText'; import styles from './WalletButton.module.css'; -interface WalletButtonProps extends ComponentProps<'button'> { - children: React.ReactNode; - color?: CSSProperties['color'] | 'primary-light' | 'primary'; +interface WalletButtonProps extends ButtonHTMLAttributes { + color?: 'black' | 'primary-light' | 'primary' | 'white'; + icon?: ReactElement; + isFullWidth?: boolean; isRounded?: boolean; - size?: 'lg' | 'md' | 'sm'; - variant?: 'contained' | 'outlined' | 'text'; + size?: Extract; + text?: React.ReactNode; + variant?: 'contained' | 'ghost' | 'outlined'; } const WalletButton: React.FC = ({ - children, color = 'primary', + icon, + isFullWidth = false, isRounded = false, size = 'md', + text, variant = 'contained', ...rest }) => { const isContained = variant === 'contained'; + const isOutlined = variant === 'outlined'; + const isGhost = variant === 'ghost'; + const hasIcon = !!icon; + const hasText = !!text; + const buttonClassNames = classNames( - styles[`wallets-button`], - (isContained && styles[`wallets-button-color-${color}`]) || '', + styles['wallets-button'], + isContained && styles[`wallets-button-color-${color}`], styles[`wallets-button-size-${size}`], styles[`wallets-button-variant-${variant}`], - isRounded ? styles[`wallets-button-rounded-full`] : styles[`wallets-button-rounded-default`] + isRounded ? styles['wallets-button-rounded-full'] : styles['wallets-button-rounded-default'], + isFullWidth && styles['wallets-button-full-width'] ); + const buttonFontColor = () => { + if (isContained) { + switch (color) { + case 'black': + return 'white'; + case 'primary-light': + return 'error'; + case 'primary': + return 'white'; + case 'white': + return 'general'; + default: + return 'white'; + } + } else if (isOutlined) { + return 'general'; + } else if (isGhost) { + return 'error'; + } + }; + + const buttonFontSizeMapper: Record, TGenericSizes> = { + lg: 'sm', + md: 'sm', + sm: 'xs' as const, + }; + return ( ); }; diff --git a/packages/wallets/src/components/Base/WalletText/WalletText.tsx b/packages/wallets/src/components/Base/WalletText/WalletText.tsx index 054f2d6f58cc..6da1afa32256 100644 --- a/packages/wallets/src/components/Base/WalletText/WalletText.tsx +++ b/packages/wallets/src/components/Base/WalletText/WalletText.tsx @@ -1,5 +1,6 @@ import React, { ComponentProps, CSSProperties, ReactNode } from 'react'; import classNames from 'classnames'; +import { TGenericSizes } from '../types'; import styles from './WalletText.module.css'; interface WalletTextProps extends ComponentProps<'span'> { @@ -7,7 +8,7 @@ interface WalletTextProps extends ComponentProps<'span'> { children: ReactNode; color?: CSSProperties['color'] | 'error' | 'general' | 'primary' | 'success' | 'warning'; lineHeight?: '2xl' | '2xs' | '3xl' | '3xs' | '4xl' | '4xs' | '5xl' | '6xl' | 'lg' | 'md' | 'sm' | 'xl' | 'xs'; - size?: '2xl' | '2xs' | '3xl' | '3xs' | '4xl' | '4xs' | 'lg' | 'md' | 'sm' | 'xl' | 'xs'; + size?: TGenericSizes; weight?: CSSProperties['fontWeight']; } diff --git a/packages/wallets/src/components/Base/type.ts b/packages/wallets/src/components/Base/type.ts new file mode 100644 index 000000000000..e5d7e5f3757c --- /dev/null +++ b/packages/wallets/src/components/Base/type.ts @@ -0,0 +1 @@ +export type TGenericSizes = '2xl' | '2xs' | '3xl' | '3xs' | '4xl' | '4xs' | 'lg' | 'md' | 'sm' | 'xl' | 'xs'; diff --git a/packages/wallets/src/components/Base/types.ts b/packages/wallets/src/components/Base/types.ts new file mode 100644 index 000000000000..e5d7e5f3757c --- /dev/null +++ b/packages/wallets/src/components/Base/types.ts @@ -0,0 +1 @@ +export type TGenericSizes = '2xl' | '2xs' | '3xl' | '3xs' | '4xl' | '4xs' | 'lg' | 'md' | 'sm' | 'xl' | 'xs'; diff --git a/packages/wallets/src/components/OptionsAndMultipliersListing/OptionsAndMultipliersListing.tsx b/packages/wallets/src/components/OptionsAndMultipliersListing/OptionsAndMultipliersListing.tsx index 8d6c2ca1c74e..f1f185913bb8 100644 --- a/packages/wallets/src/components/OptionsAndMultipliersListing/OptionsAndMultipliersListing.tsx +++ b/packages/wallets/src/components/OptionsAndMultipliersListing/OptionsAndMultipliersListing.tsx @@ -69,13 +69,7 @@ const OptionsAndMultipliersListing = () => { leading={() => (
{account.icon}
)} - trailing={() => ( - - - Get - - - )} + trailing={() => } >
diff --git a/packages/wallets/src/components/WalletListCardActions/WalletListCardActions.tsx b/packages/wallets/src/components/WalletListCardActions/WalletListCardActions.tsx index e9f498799cc6..41a29957ad7e 100644 --- a/packages/wallets/src/components/WalletListCardActions/WalletListCardActions.tsx +++ b/packages/wallets/src/components/WalletListCardActions/WalletListCardActions.tsx @@ -81,23 +81,16 @@ const WalletListCardActions: React.FC = ({ isActive, isDemo, loginid })
{getWalletHeaderButtons(isDemo).map(button => ( { switchAccount(loginid); history.push(`/wallets/cashier/${button.name}`); }} + text={isActive ? button.text : undefined} variant='outlined' - > - {button.icon} - - {button.text} - - + /> ))}
); diff --git a/packages/wallets/src/features/cfd/components/CTraderList/CTraderList.tsx b/packages/wallets/src/features/cfd/components/CTraderList/CTraderList.tsx index 72969a9de1a4..8cf7153acc19 100644 --- a/packages/wallets/src/features/cfd/components/CTraderList/CTraderList.tsx +++ b/packages/wallets/src/features/cfd/components/CTraderList/CTraderList.tsx @@ -1,6 +1,6 @@ import React from 'react'; import { TradingAccountCard } from '../../../../components'; -import { WalletButton, WalletText } from '../../../../components/Base'; +import { WalletButton } from '../../../../components/Base'; import CTrader from '../../../../public/images/ctrader.svg'; import './CTraderList.scss'; @@ -24,13 +24,7 @@ const CTraderList: React.FC = () => { {...account} key={`ctrader--${account.title}`} leading={() =>
{account.icon}
} - trailing={() => ( - - - Get - - - )} + trailing={() => } >

{account.title}

diff --git a/packages/wallets/src/features/cfd/flows/MT5/AddedMT5AccountsList/AddedMT5AccountsList.tsx b/packages/wallets/src/features/cfd/flows/MT5/AddedMT5AccountsList/AddedMT5AccountsList.tsx index 9170ff1b02fe..1a199cb619fe 100644 --- a/packages/wallets/src/features/cfd/flows/MT5/AddedMT5AccountsList/AddedMT5AccountsList.tsx +++ b/packages/wallets/src/features/cfd/flows/MT5/AddedMT5AccountsList/AddedMT5AccountsList.tsx @@ -1,6 +1,6 @@ import React from 'react'; import { useMT5AccountsList } from '@deriv/api'; -import { WalletButton, WalletText } from '../../../../../components/Base'; +import { WalletButton } from '../../../../../components/Base'; import { TradingAccountCard } from '../../../../../components/TradingAccountCard'; import DerivedMT5 from '../../../../../public/images/mt5-derived.svg'; import FinancialMT5 from '../../../../../public/images/mt5-financial.svg'; @@ -31,16 +31,8 @@ const AddedMT5AccountsList: React.FC = ({ account }) => { )} trailing={() => (
- - - Transfer - - - - - Open - - + +
)} > diff --git a/packages/wallets/src/features/cfd/flows/MT5/AvailableMT5AccountsList/AvailableMT5AccountsList.tsx b/packages/wallets/src/features/cfd/flows/MT5/AvailableMT5AccountsList/AvailableMT5AccountsList.tsx index 618599251f0b..65387c1d6641 100644 --- a/packages/wallets/src/features/cfd/flows/MT5/AvailableMT5AccountsList/AvailableMT5AccountsList.tsx +++ b/packages/wallets/src/features/cfd/flows/MT5/AvailableMT5AccountsList/AvailableMT5AccountsList.tsx @@ -1,6 +1,6 @@ import React from 'react'; import { useSortedMT5Accounts } from '@deriv/api'; -import { TradingAccountCard, WalletButton, WalletText } from '../../../../../components'; +import { TradingAccountCard, WalletButton } from '../../../../../components'; import { useModal } from '../../../../../components/ModalProvider'; import DerivedMT5 from '../../../../../public/images/mt5-derived.svg'; import FinancialMT5 from '../../../../../public/images/mt5-financial.svg'; @@ -43,11 +43,8 @@ const AvailableMT5AccountsList: React.FC = ({ account }) => { show()} - > - - Get - - + text='Get' + /> )} >
diff --git a/packages/wallets/src/features/cfd/flows/OtherCFDs/Dxtrade/AddedDxtradeAccountsList/AddedDxtradeAccountsList.tsx b/packages/wallets/src/features/cfd/flows/OtherCFDs/Dxtrade/AddedDxtradeAccountsList/AddedDxtradeAccountsList.tsx index e6166ec1f807..a698ab2f6949 100644 --- a/packages/wallets/src/features/cfd/flows/OtherCFDs/Dxtrade/AddedDxtradeAccountsList/AddedDxtradeAccountsList.tsx +++ b/packages/wallets/src/features/cfd/flows/OtherCFDs/Dxtrade/AddedDxtradeAccountsList/AddedDxtradeAccountsList.tsx @@ -1,7 +1,7 @@ import React from 'react'; import { useDxtradeAccountsList } from '@deriv/api'; import { TradingAccountCard } from '../../../../../../components'; -import { WalletButton, WalletText } from '../../../../../../components/Base'; +import { WalletButton } from '../../../../../../components/Base'; import DerivX from '../../../../../../public/images/derivx.svg'; import './AddedDxtradeAccountsList.scss'; @@ -17,16 +17,8 @@ const AddedDxtradeAccountsList: React.FC = () => { )} trailing={() => (
- - - Transfer - - - - - Open - - + +
)} > diff --git a/packages/wallets/src/features/cfd/flows/OtherCFDs/Dxtrade/AvailableDxtradeAccountsList/AvailableDxtradeAccountsList.tsx b/packages/wallets/src/features/cfd/flows/OtherCFDs/Dxtrade/AvailableDxtradeAccountsList/AvailableDxtradeAccountsList.tsx index 5655f7c960fa..b3fb9db1e516 100644 --- a/packages/wallets/src/features/cfd/flows/OtherCFDs/Dxtrade/AvailableDxtradeAccountsList/AvailableDxtradeAccountsList.tsx +++ b/packages/wallets/src/features/cfd/flows/OtherCFDs/Dxtrade/AvailableDxtradeAccountsList/AvailableDxtradeAccountsList.tsx @@ -17,11 +17,7 @@ const AvailableDxtradeAccountsList: React.FC = () => {
)} trailing={() => ( - show()}> - - Get - - + show()} text='Get' /> )} >
diff --git a/packages/wallets/src/features/cfd/modals/MT5AccountTypeModal/MT5AccountTypeModal.tsx b/packages/wallets/src/features/cfd/modals/MT5AccountTypeModal/MT5AccountTypeModal.tsx index 6e7722fc4d4c..2abf08473df2 100644 --- a/packages/wallets/src/features/cfd/modals/MT5AccountTypeModal/MT5AccountTypeModal.tsx +++ b/packages/wallets/src/features/cfd/modals/MT5AccountTypeModal/MT5AccountTypeModal.tsx @@ -1,5 +1,5 @@ import React, { useState } from 'react'; -import { ModalStepWrapper, WalletButton, WalletText } from '../../../../components/Base'; +import { ModalStepWrapper, WalletButton } from '../../../../components/Base'; import { useModal } from '../../../../components/ModalProvider'; import { MT5AccountType } from '../../screens'; import { JurisdictionModal } from '../JurisdictionModal'; @@ -21,11 +21,8 @@ const MT5AccountTypeModal = () => { }); show(); }} - > - - Get - - + text='Get' + /> )} title='Select Deriv MT5’s account type' >