import React, { useContext } from 'react'; import { useSelector } from 'react-redux'; import PropTypes from 'prop-types'; import { I18nContext } from '../../../contexts/i18n'; import Box from '../../ui/box'; import Typography from '../../ui/typography'; import { ALIGN_ITEMS, BLOCK_SIZES, COLORS, DISPLAY, FLEX_DIRECTION, FONT_WEIGHT, TYPOGRAPHY, JUSTIFY_CONTENT, } from '../../../helpers/constants/design-system'; import Button from '../../ui/button'; import IconCaretLeft from '../../ui/icon/icon-caret-left'; import Tooltip from '../../ui/tooltip'; import IconWithFallback from '../../ui/icon-with-fallback'; import IconBorder from '../../ui/icon-border'; import { getTheme } from '../../../selectors'; import { THEME_TYPE } from '../../../pages/settings/experimental-tab/experimental-tab.constant'; const AddNetwork = ({ onBackClick, onAddNetworkClick, onAddNetworkManuallyClick, featuredRPCS, }) => { const t = useContext(I18nContext); const theme = useSelector(getTheme); const infuraRegex = /infura.io/u; const nets = featuredRPCS .sort((a, b) => (a.ticker > b.ticker ? 1 : -1)) .slice(0, 8); return ( {t('addNetwork')} {t('addFromAListOfPopularNetworks')} {t('popularCustomNetworks')} {nets.map((item, index) => ( {item.nickname} { // Warning for the networks that doesn't use infura.io as the RPC !infuraRegex.test(item.rpcUrl) && ( {t('addNetworkTooltipWarning', [ {t('learnMoreUpperCase')} , ])} } trigger="mouseenter" theme={theme === THEME_TYPE.DEFAULT ? 'light' : 'dark'} > ) } ))} ); }; AddNetwork.propTypes = { onBackClick: PropTypes.func, onAddNetworkClick: PropTypes.func, onAddNetworkManuallyClick: PropTypes.func, featuredRPCS: PropTypes.array, }; export default AddNetwork;