forked from binary-com/deriv-app
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #36 from hamza-deriv/hamza/wall-580/icon-reusable-…
…component feat: icon reusable component v1.0
- Loading branch information
Showing
16 changed files
with
241 additions
and
7 deletions.
There are no files selected for viewing
12 changes: 12 additions & 0 deletions
12
packages/cfd/src/Assets/svgs/trading-instruments/ic-appstore-basket-indices.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions
1
packages/cfd/src/Assets/svgs/trading-instruments/ic-appstore-commodities.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions
1
packages/cfd/src/Assets/svgs/trading-instruments/ic-appstore-cryptocurrencies.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
7 changes: 7 additions & 0 deletions
7
packages/cfd/src/Assets/svgs/trading-instruments/ic-appstore-derived-fx.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions
1
packages/cfd/src/Assets/svgs/trading-instruments/ic-appstore-etf.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions
1
packages/cfd/src/Assets/svgs/trading-instruments/ic-appstore-forex.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions
1
packages/cfd/src/Assets/svgs/trading-instruments/ic-appstore-stock-indices.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions
1
packages/cfd/src/Assets/svgs/trading-instruments/ic-appstore-stocks.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
7 changes: 7 additions & 0 deletions
7
packages/cfd/src/Assets/svgs/trading-instruments/ic-appstore-synthetics.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
39 changes: 39 additions & 0 deletions
39
packages/cfd/src/Assets/svgs/trading-instruments/index.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
import React from 'react'; | ||
import DerivedFX from './ic-appstore-derived-fx.svg'; | ||
import Synthetics from './ic-appstore-synthetics.svg'; | ||
import BasketIndices from './ic-appstore-basket-indices.svg'; | ||
import Stocks from './ic-appstore-stocks.svg'; | ||
import StockIndices from './ic-appstore-stock-indices.svg'; | ||
import Commodities from './ic-appstore-commodities.svg'; | ||
import Forex from './ic-appstore-forex.svg'; | ||
import Cryptocurrencies from './ic-appstore-cryptocurrencies.svg'; | ||
import ETF from './ic-appstore-etf.svg'; | ||
|
||
export type IconProps<T> = { | ||
icon: T; | ||
className?: string; | ||
size?: number; | ||
onClick?: () => void; | ||
}; | ||
|
||
export const InstrumentsIcons = { | ||
DerivedFX, | ||
Synthetics, | ||
BasketIndices, | ||
Stocks, | ||
StockIndices, | ||
Commodities, | ||
Forex, | ||
Cryptocurrencies, | ||
ETF, | ||
}; | ||
|
||
const TradingInstrumentsIcon = ({ icon, className, size, onClick }: IconProps<keyof typeof InstrumentsIcons>) => { | ||
const InstrumentIcon = InstrumentsIcons[icon] as React.ElementType; | ||
|
||
return InstrumentIcon ? ( | ||
<InstrumentIcon className={className} style={{ width: size, height: size }} onClick={onClick} /> | ||
) : null; | ||
}; | ||
|
||
export default TradingInstrumentsIcon; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
22 changes: 22 additions & 0 deletions
22
packages/cfd/src/Containers/cfd-compare-accounts/cfd-instruments-label-highlighted.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
import React from 'react'; | ||
import InstumentsIconWithLabel from './instruments-icon-with-label'; | ||
import { TTradingPlatformAvailableAccount, TIconData } from 'Components/props.types'; | ||
import { getHighlightedIconLabel } from '../../Helpers/compare-accounts-config'; | ||
|
||
type TCFDInstrumentsLabelHighlightedProps = { | ||
trading_platforms: TTradingPlatformAvailableAccount; | ||
}; | ||
|
||
const CFDInstrumentsLabelHighlighted: React.FC<TCFDInstrumentsLabelHighlightedProps> = ({ trading_platforms }) => { | ||
const iconData: TIconData[] = [...getHighlightedIconLabel(trading_platforms)]; | ||
|
||
return ( | ||
<div className={'compare-cfd-account-outline'}> | ||
{iconData.map(item => ( | ||
<InstumentsIconWithLabel key={item.text} {...item} /> | ||
))} | ||
</div> | ||
); | ||
}; | ||
|
||
export default CFDInstrumentsLabelHighlighted; |
47 changes: 47 additions & 0 deletions
47
packages/cfd/src/Containers/cfd-compare-accounts/instruments-icon-with-label.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
import React from 'react'; | ||
import TradingInstrumentsIcon from '../../Assets/svgs/trading-instruments'; | ||
|
||
type TIconProps = { | ||
icon: | ||
| 'DerivedFX' | ||
| 'Synthetics' | ||
| 'BasketIndices' | ||
| 'Stocks' | ||
| 'StockIndices' | ||
| 'Commodities' | ||
| 'Forex' | ||
| 'Cryptocurrencies' | ||
| 'ETF'; | ||
text: string; | ||
highlighted: boolean; | ||
className?: string; | ||
}; | ||
|
||
const InstumentsIconWithLabel = ({ icon, text, highlighted, className }: TIconProps) => { | ||
let size = 24; | ||
const dummyFunc = () => { | ||
size = 24; | ||
}; | ||
return ( | ||
<div | ||
style={{ | ||
display: 'flex', | ||
alignItems: 'center', | ||
margin: '3px', | ||
opacity: highlighted ? '' : '0.2', | ||
}} | ||
className={className} | ||
> | ||
<TradingInstrumentsIcon icon={icon} size={size} className='trading-instruments__icon' onClick={dummyFunc} /> | ||
<span | ||
style={{ | ||
marginLeft: '0.5rem', | ||
}} | ||
> | ||
{text} | ||
</span> | ||
</div> | ||
); | ||
}; | ||
|
||
export default InstumentsIconWithLabel; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
import { TTradingPlatformAvailableAccount, TIconData } from '../Components/props.types'; | ||
|
||
const getHighlightedIconLabel = (trading_platforms: TTradingPlatformAvailableAccount): TIconData[] => { | ||
switch (trading_platforms.market_type) { | ||
case 'gaming': | ||
return [ | ||
{ icon: 'Synthetics', text: 'Synthetics', highlighted: true }, | ||
{ icon: 'BasketIndices', text: 'Basket Indices', highlighted: true }, | ||
{ icon: 'DerivedFX', text: 'Derived FX', highlighted: true }, | ||
{ icon: 'Stocks', text: 'Stock', highlighted: false }, | ||
{ icon: 'StockIndices', text: 'Stock Indices', highlighted: false }, | ||
{ icon: 'Commodities', text: 'Commodities', highlighted: false }, | ||
{ icon: 'Forex', text: 'Forex', highlighted: false }, | ||
{ icon: 'Cryptocurrencies', text: 'Cryptocurrencies', highlighted: false }, | ||
{ icon: 'ETF', text: 'ETF', highlighted: false }, | ||
]; | ||
break; | ||
case 'financial': | ||
return [ | ||
{ icon: 'Synthetics', text: 'Synthetics', highlighted: false }, | ||
{ icon: 'BasketIndices', text: 'Basket Indices', highlighted: false }, | ||
{ icon: 'DerivedFX', text: 'Derived FX', highlighted: false }, | ||
{ icon: 'Stocks', text: 'Stock', highlighted: true }, | ||
{ icon: 'StockIndices', text: 'Stock Indices', highlighted: true }, | ||
{ icon: 'Commodities', text: 'Commodities', highlighted: true }, | ||
{ icon: 'Forex', text: 'Forex', highlighted: true }, | ||
{ icon: 'Cryptocurrencies', text: 'Cryptocurrencies', highlighted: true }, | ||
{ icon: 'ETF', text: 'ETF', highlighted: true }, | ||
]; | ||
break; | ||
case 'all': | ||
default: | ||
return [ | ||
{ icon: 'Synthetics', text: 'Synthetics', highlighted: true }, | ||
{ icon: 'BasketIndices', text: 'Basket Indices', highlighted: true }, | ||
{ icon: 'DerivedFX', text: 'Derived FX', highlighted: true }, | ||
{ icon: 'Stocks', text: 'Stock', highlighted: true }, | ||
{ icon: 'StockIndices', text: 'Stock Indices', highlighted: true }, | ||
{ icon: 'Commodities', text: 'Commodities', highlighted: true }, | ||
{ icon: 'Forex', text: 'Forex', highlighted: true }, | ||
{ icon: 'Cryptocurrencies', text: 'Cryptocurrencies', highlighted: true }, | ||
{ icon: 'ETF', text: 'ETF', highlighted: true }, | ||
]; | ||
break; | ||
} | ||
}; | ||
|
||
export { getHighlightedIconLabel }; |