components#TopMovers TypeScript Examples
The following examples show how to use
components#TopMovers.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: AnalyticsTokens.tsx From interface-v2 with GNU General Public License v3.0 | 5 votes |
AnalyticsTokens: React.FC = () => {
const classes = useStyles();
const { palette } = useTheme();
const [tokensFilter, setTokensFilter] = useState(0);
const [topTokens, updateTopTokens] = useState<any[] | null>(null);
const { bookmarkTokens } = useBookmarkTokens();
const favoriteTokens = useMemo(() => {
if (topTokens) {
return topTokens.filter(
(token: any) => bookmarkTokens.indexOf(token.id) > -1,
);
} else {
return [];
}
}, [topTokens, bookmarkTokens]);
useEffect(() => {
const fetchTopTokens = async () => {
updateTopTokens(null); //set top tokens as null to show loading status when fetching tokens data
const [newPrice, oneDayPrice] = await getEthPrice();
const topTokensData = await getTopTokens(newPrice, oneDayPrice, 200);
if (topTokensData) {
updateTopTokens(topTokensData);
}
};
fetchTopTokens();
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [updateTopTokens]);
return (
<Box width='100%' mb={3}>
<TopMovers background={palette.grey.A700} hideArrow={true} />
<Box my={4} px={2} display='flex' flexWrap='wrap' alignItems='center'>
<Box
className={classes.tokensFilter}
onClick={() => setTokensFilter(0)}
color={
tokensFilter === 0 ? palette.primary.main : palette.text.disabled
}
>
<Typography variant='h6'>All Cryptos</Typography>
</Box>
<Box
className={classes.tokensFilter}
color={
tokensFilter === 1 ? palette.primary.main : palette.text.disabled
}
onClick={() => setTokensFilter(1)}
>
<Typography variant='h6'>Favourites</Typography>
</Box>
<Box
className={classes.tokensFilter}
color={
tokensFilter === 2 ? palette.primary.main : palette.text.disabled
}
onClick={() => setTokensFilter(2)}
>
<Typography variant='h6'>New Listing</Typography>
</Box>
</Box>
<Box className={classes.panel}>
{topTokens && topTokens.length === 200 ? (
<TokensTable data={tokensFilter === 0 ? topTokens : favoriteTokens} />
) : (
<Skeleton variant='rect' width='100%' height={150} />
)}
</Box>
</Box>
);
}
Example #2
Source File: LandingPage.tsx From interface-v2 with GNU General Public License v3.0 | 4 votes |
LandingPage: React.FC = () => {
const classes = useStyles();
const { palette, breakpoints } = useTheme();
const mobileWindowSize = useMediaQuery(breakpoints.down('sm'));
const { t } = useTranslation();
const features = [
{
img: FeaturedSwap,
title: t('swapTokens'),
desc: t('featureTradeDesc'),
},
{
img: ProvideLiquidity,
title: t('supplyLiquidity'),
desc: t('featureLiquidityDesc'),
},
{
img: Rewards,
title: t('earndQUICK'),
desc: t('featureDepositDesc'),
},
{
img: DragonsLair,
title: t('dragonLair'),
desc: t('featureDragonDesc'),
},
{
img: BuyWithFiat,
title: t('buyWithFiat'),
desc: t('featureBuyFiatDesc'),
},
{
img: Analytics,
title: t('analytics'),
desc: t('featureAnalyticsDesc'),
},
];
const socialicons = [
{
link: 'https://www.reddit.com/r/QuickSwap/',
icon: <RedditIcon />,
title: 'Reddit',
},
{
link: 'https://discord.com/invite/XJTM7FV88Y',
icon: <DiscordIcon />,
title: 'Discord',
},
{
link: 'https://twitter.com/QuickswapDEX',
icon: <TwitterIcon />,
title: 'Twitter',
},
{
link: 'https://quickswap-layer2.medium.com/',
icon: <MediumIcon />,
title: 'Medium',
},
{
link: 'https://www.youtube.com/channel/UCrPlF-DBwD-UzLFDzJ4Z5Fw',
icon: <YouTubeIcon />,
title: 'Youtube',
},
{
link: 'https://t.me/QuickSwapDEX',
icon: <TelegramIcon />,
title: 'Telegram',
},
{
link: 'https://www.coingecko.com/en/exchanges/quickswap',
icon: <CoingeckoIcon />,
title: 'CoinGecko',
},
];
const history = useHistory();
const { globalData, updateGlobalData } = useGlobalData();
useEffect(() => {
async function fetchGlobalData() {
const [newPrice, oneDayPrice] = await getEthPrice();
const newGlobalData = await getGlobalData(newPrice, oneDayPrice);
if (newGlobalData) {
updateGlobalData({ data: newGlobalData });
}
}
fetchGlobalData();
}, [updateGlobalData]);
return (
<div id='landing-page' style={{ width: '100%' }}>
<Box margin={mobileWindowSize ? '64px 0' : '100px 0 80px'}>
<HeroSection globalData={globalData} />
</Box>
<Box className={classes.tradingInfo} display='flex'>
<TradingInfo globalData={globalData} />
</Box>
<Box className={classes.smallCommunityContainer}>
{socialicons.map((val, ind) => (
<a
href={val.link}
target='_blank'
key={ind}
rel='noopener noreferrer'
>
<Box display='flex' mx={1.5}>
{val.icon}
</Box>
</a>
))}
</Box>
<Box mt={2} width={1}>
<TopMovers background={palette.background.paper} />
</Box>
<Box className={classes.quickInfo}>
<Typography style={{ fontSize: '24px' }}>
{t('quickInfoTitle')}
</Typography>
<img src={Motif} alt='Motif' />
</Box>
<SwapSection />
<Box className={classes.rewardsContainer}>
<Box maxWidth='480px' width='100%'>
<Typography variant='h4'>{t('earnRewardsbyDeposit')}</Typography>
<Typography style={{ marginTop: '20px' }}>
{t('depositLPTokensRewards')}
</Typography>
</Box>
<RewardSlider />
<Box
bgcolor={palette.secondary.dark}
color={palette.text.primary}
width={194}
height={48}
display='flex'
alignItems='center'
justifyContent='center'
borderRadius={24}
style={{ cursor: 'pointer' }}
onClick={() => {
history.push('/farm');
}}
>
<Typography variant='body1'>{t('seeAllPairs')}</Typography>
</Box>
</Box>
<BuyFiatSection />
<Box className={classes.featureContainer}>
<Box className={classes.featureHeading}>
<Typography variant='h3'>{t('features')}</Typography>
<Box className={classes.featureDivider} />
</Box>
<Grid container spacing={4}>
{features.map((val, index) => (
<Grid item container alignItems='center' sm={12} md={6} key={index}>
<img src={val.img} alt={val.title} />
<Box className='featureText'>
<Typography variant='h5'>{val.title}</Typography>
<Typography variant='body1'>{val.desc}</Typography>
</Box>
</Grid>
))}
</Grid>
</Box>
<Box className={classes.communityContainer}>
<Box className={classes.featureHeading}>
<Typography variant='h3'>{t('joinCommunity')}</Typography>
<Box className={classes.featureDivider} />
</Box>
<Box className='socialContent'>
{socialicons.map((val, ind) => (
<Box key={ind}>
<a href={val.link} target='_blank' rel='noopener noreferrer'>
{val.icon}
<Typography>{val.title}</Typography>
</a>
</Box>
))}
</Box>
</Box>
</div>
);
}