components APIs
- Header
- Button
- Layout
- Footer
- Text
- Box
- Card
- Table
- Loading
- Select
- Loader
- Toolbar
- Icon
- CodeInput
- BottomSheet
- InfoBlock
- LanguageToggle
- ProgressCircles
- Ripple
- Toggle
- Tag
- Input
- Paginator
- Filter
- AsyncSelect
- CatalogBigButton
- ReadMore
- ConditionalWrapper
- LastCheckedDisplay
- PriceLabel
- PageTitle
- CartTable
- CartFinalPriceTable
- LoadingSpin
- InfoModal
- ProductCard
- RecommendCoupon
- PriceVales
- NomalLayout
- Web3ReactManager
- Popups
- CurrencyInput
- TransactionErrorContent
- TransactionConfirmationModal
- ConfirmationModalContent
- DoubleCurrencyLogo
- CustomModal
- CurrencySearchModal
- CurrencyLogo
- NumericalInput
- Logo
- QuestionHelper
- ListLogo
- DataTable
- WalletModal
- CustomTable
- MinimalPositionCard
- RemoveLiquidityModal
- CustomTooltip
- ColoredSlider
- ToggleSwitch
- FormattedPriceImpact
- SettingsModal
- ConfirmSwapModal
- AdvancedSwapDetails
- AddressInput
- LineChart
- StakeSyrupModal
- AccountDetails
- BetaWarningBanner
- AreaChart
- ChartType
- TokensTable
- PairTable
- TopMovers
- BarChart
- TransactionsTable
- StakeQuickModal
- UnstakeQuickModal
- SyrupCard
- CustomMenu
- SearchInput
- CustomSwitch
- FarmCard
- BuyFiatModal
- MoonpayModal
- RewardSlider
- Swap
- AddLiquidity
- PoolFinderModal
- PoolPositionCard
- SwapTokenDetails
- SuperHeader
- GlobalStyles
- PrimaryButton
- SectionTitle
- Section
- AccentSection
- ChainSelection
- CoinSelection
- AddressSelection
- SendAction
- Buttons
- Content
- Particles
- IconButton
- NotSupported
- InputSearch
- RouteGuard
- SearchBar
- FileInput
- GovBanner
- AuthForm
- DomainDetails
- Subnav
- ColumnFilter
- ImportExport
- selectFilter
- TaggedArrayInput
- FacetFilter
- ButtonSingleLine
- TextMultiline
- ButtonSelect
- BottomSheetBehavior
- InfoButton
- BulletPointX
- BulletPointCheck
- Title
- LoadingIcon
- SelectFilterControls
- CORInputForm
- SdnInputForm
- Navbar
- HomeRoute
- AuthRoute
- DocumentDetails
- DocumentStepper
- AddGame
- Auth
- Effectiveness
- Export
- PokemonType
- Moves
- Member
- MoveSelector
- Type
- Natures
- Move
- PokeInfo
- Share
- Badges
- Status
- UpdateSW
- About
- Builder
- Calculator
- Changelog
- Import
- Pokestats
- Report
- Rules
- Settings
- Tracker
- DarkThemeProvider
- NotificationHandler
- Background
- Indicator
- StyledButton
- StyledText
- Illustration
- OnboardingSlider
- FlexList
- AppLayout
- ScrollableList
- Visualization
- DataSearch
- Region
- App
- CompareApiLegend
- CompareApiBreadcrumbs
- CompareApiLink
- CompareApiCard
- ExploreApiBreadcrumbs
- ExploreApiLink
- ExploreApiSearch
- ExploreApiConst
- ApiLoader
- RefreshButton
- Listing
- PriceModal
- ConfirmationModal
- Transition
- AutoComplete
- useInput
- Avatar
- Badge
- Breadcrumbs
- ButtonDropdown
- ButtonGroup
- Capacity
- Checkbox
- Code
- Collapse
- CssBaseline
- GeistProvider
- Description
- Display
- Divider
- Dot
- Drawer
- useModal
- Fieldset
- Grid
- Image
- Keyboard
- Link
- Modal
- Note
- Page
- Pagination
- Popover
- Progress
- Radio
- Rating
- Slider
- Snippet
- Spacer
- Spinner
- Tabs
- Textarea
- Tooltip
- Tree
- useBodyScroll
- useClasses
- useClickAway
- useClipboard
- useCurrentState
- useKeyboard
- KeyMod
- KeyCode
- useMediaQuery
- useTabs
- useToasts
- User
- useTheme
- Themes
- GeistUIThemes
- useAllThemes
- CollapsableDialog
- Map
- IPForm
- IPMenu
- Container
- Parallax
- Nav
- SEO
- BlogNav
- ExtensionCard
- MenuComp
Other Related APIs
- react#useState
- @material-ui/core#Button
- @material-ui/core#Typography
- @material-ui/core#Box
- @material-ui/core#ButtonGroup
- @material-ui/core#Grid
- @material-ui/core#useMediaQuery
- @material-ui/core/styles#makeStyles
- @material-ui/core/styles#useTheme
- components#SettingsModal
- components#AddLiquidity
- hooks/Tokens#useCurrency
components#Swap TypeScript Examples
The following examples show how to use
components#Swap.
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: SwapSection.tsx From interface-v2 with GNU General Public License v3.0 | 5 votes |
SwapSection: React.FC = () => {
const classes = useStyles();
const { palette, breakpoints } = useTheme();
const mobileWindowSize = useMediaQuery(breakpoints.down('sm'));
const [tabIndex, setTabIndex] = useState(SWAP_TAB);
return (
<>
<Box className={classes.buttonGroup}>
<ButtonGroup>
<Button
className={tabIndex === SWAP_TAB ? 'active' : ''}
onClick={() => setTabIndex(SWAP_TAB)}
>
Swap
</Button>
<Button
className={tabIndex === LIQUIDITY_TAB ? 'active' : ''}
onClick={() => setTabIndex(LIQUIDITY_TAB)}
>
Liquidity
</Button>
</ButtonGroup>
</Box>
<Box className={classes.swapContainer}>
<Grid container spacing={mobileWindowSize ? 0 : 8} alignItems='center'>
<Grid item sm={12} md={6}>
{tabIndex === SWAP_TAB ? (
<Swap currencyBg={palette.background.paper} />
) : (
<AddLiquidity currencyBg={palette.background.paper} />
)}
</Grid>
<Grid item sm={12} md={6} className={classes.swapInfo}>
<Typography variant='h4'>
{tabIndex === SWAP_TAB
? 'Swap tokens at near-zero gas fees'
: 'Let your crypto work for you'}
</Typography>
<Typography variant='body1' style={{ marginTop: '20px' }}>
{tabIndex === SWAP_TAB
? 'Deposit your Liquidity Provider tokens to receive Rewards in $QUICK on top of LP Fees.'
: 'Provide Liquidity and earn 0.25% fee on all trades proportional to your share of the pool. Earn additional rewards by depositing your LP Tokens in Rewards Pools.'}
</Typography>
</Grid>
</Grid>
</Box>
</>
);
}
Example #2
Source File: SwapMain.tsx From interface-v2 with GNU General Public License v3.0 | 4 votes |
SwapMain: React.FC = () => {
const classes = useStyles();
const { palette } = useTheme();
const [swapIndex, setSwapIndex] = useState(0);
const [openSettingsModal, setOpenSettingsModal] = useState(false);
const parsedQuery = useParsedQueryString();
const currency0 = useCurrency(
parsedQuery && parsedQuery.currency0
? (parsedQuery.currency0 as string)
: undefined,
);
const currency1 = useCurrency(
parsedQuery && parsedQuery.currency1
? (parsedQuery.currency1 as string)
: undefined,
);
return (
<>
{openSettingsModal && (
<SettingsModal
open={openSettingsModal}
onClose={() => setOpenSettingsModal(false)}
/>
)}
<Box display='flex' justifyContent='space-between'>
<Box display='flex'>
<Box
className={cx(
swapIndex === 0 && classes.activeSwap,
classes.swapItem,
classes.headingItem,
)}
onClick={() => setSwapIndex(0)}
>
<Typography variant='body1'>Market</Typography>
</Box>
<Box
className={cx(
swapIndex === 1 && classes.activeSwap,
classes.swapItem,
classes.headingItem,
)}
onClick={() => setSwapIndex(1)}
>
<Typography variant='body1'>Limit</Typography>
</Box>
</Box>
<Box className={classes.headingItem}>
<SettingsIcon onClick={() => setOpenSettingsModal(true)} />
</Box>
</Box>
<Box mt={2.5}>
{swapIndex === 0 && (
<Swap
currency0={currency0 ?? undefined}
currency1={currency1 ?? undefined}
/>
)}
{swapIndex === 1 && (
<>
<GelatoLimitOrderPanel />
<GelatoLimitOrdersHistoryPanel />
<Box mt={2} textAlign='center'>
<Typography variant='body2'>
<b>* Disclaimer:</b> Limit Orders on QuickSwap are provided by
Gelato, a 3rd party protocol and should be considered in beta.
DYOR and use at your own risk. QuickSwap is not responsible.
More info can be found
<a
style={{ color: palette.text.primary }}
target='_blank'
rel='noopener noreferrer'
href='https://www.certik.org/projects/gelato'
>
here.
</a>
</Typography>
</Box>
</>
)}
</Box>
</>
);
}