-
Notifications
You must be signed in to change notification settings - Fork 310
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
f737adb
commit 0826e97
Showing
73 changed files
with
3,457 additions
and
759 deletions.
There are no files selected for viewing
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
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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
95 changes: 95 additions & 0 deletions
95
packages/plugins/Trader/src/SiteAdaptor/components/BridgeNode.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,95 @@ | ||
import { makeStyles } from '@masknet/theme' | ||
import { Typography } from '@mui/material' | ||
import { memo, type HTMLProps } from 'react' | ||
import { CoinIcon, type CoinIconProps } from './CoinIcon.js' | ||
|
||
const useStyles = makeStyles<void, 'active'>()((theme, _, refs) => ({ | ||
active: {}, | ||
node: { | ||
position: 'relative', | ||
padding: theme.spacing(1.5), | ||
display: 'flex', | ||
flexDirection: 'column', | ||
gap: 10, | ||
borderRadius: theme.spacing(1.5), | ||
border: `1px solid ${theme.palette.maskColor.line}`, | ||
backgroundColor: theme.palette.maskColor.bg, | ||
[`&.${refs.active}`]: { | ||
backgroundColor: theme.palette.maskColor.bottom, | ||
'&::after': { | ||
content: '""', | ||
display: 'block', | ||
borderRadius: 4, | ||
border: '1px solid transparent', | ||
borderRightColor: theme.palette.maskColor.line, | ||
borderBottomColor: theme.palette.maskColor.line, | ||
transform: 'scaleX(.6) rotate(45deg) translate(-50%, 100%)', | ||
backgroundColor: theme.palette.maskColor.bottom, | ||
position: 'absolute', | ||
width: 12, | ||
height: 12, | ||
left: '50%', | ||
bottom: -2, | ||
zIndex: 1, | ||
}, | ||
}, | ||
}, | ||
coin: { | ||
display: 'flex', | ||
gap: theme.spacing(0.5), | ||
alignItems: 'flex-start', | ||
}, | ||
chainName: { | ||
fontSize: 16, | ||
lineHeight: '20px', | ||
color: theme.palette.maskColor.second, | ||
}, | ||
symbol: { | ||
fontSize: 16, | ||
lineHeight: '20px', | ||
fontWeight: 700, | ||
color: theme.palette.maskColor.main, | ||
}, | ||
step: { | ||
position: 'absolute', | ||
userSelect: 'none', | ||
right: 0, | ||
top: 0, | ||
minWidth: theme.spacing(4), | ||
textAlign: 'center', | ||
lineHeight: '76px', | ||
fontSize: 64, | ||
fontWeight: 700, | ||
fontFamily: 'Helvetica', | ||
color: theme.palette.maskColor.secondaryMain, | ||
}, | ||
})) | ||
|
||
interface Props extends HTMLProps<HTMLDivElement>, Pick<CoinIconProps, 'chainId' | 'address' | 'disableBadge'> { | ||
symbol?: string | ||
step: number | ||
active?: boolean | ||
} | ||
|
||
export const BridgeNode = memo<Props>(function BridgeNode({ | ||
symbol, | ||
chainId, | ||
address, | ||
label, | ||
step, | ||
active, | ||
disableBadge, | ||
...rest | ||
}) { | ||
const { classes, cx } = useStyles() | ||
return ( | ||
<div {...rest} className={cx(classes.node, rest.className, active ? classes.active : null)}> | ||
<Typography className={classes.chainName}>{label}</Typography> | ||
<div className={classes.coin}> | ||
<CoinIcon chainId={chainId} address={address} disableBadge={disableBadge} /> | ||
<Typography className={classes.symbol}>{symbol ?? '--'}</Typography> | ||
</div> | ||
<Typography className={classes.step}>{step}</Typography> | ||
</div> | ||
) | ||
}) |
74 changes: 74 additions & 0 deletions
74
packages/plugins/Trader/src/SiteAdaptor/components/CoinIcon.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,74 @@ | ||
import { NetworkIcon, TokenIcon } from '@masknet/shared' | ||
import { NetworkPluginID } from '@masknet/shared-base' | ||
import { makeStyles } from '@masknet/theme' | ||
import type { Web3Helper } from '@masknet/web3-helpers' | ||
import { OKX } from '@masknet/web3-providers' | ||
import { isSameAddress } from '@masknet/web3-shared-base' | ||
import type { ChainId } from '@masknet/web3-shared-evm' | ||
import { Box, type BoxProps } from '@mui/material' | ||
import { skipToken, useQuery } from '@tanstack/react-query' | ||
import { memo } from 'react' | ||
|
||
const useStyles = makeStyles()(() => ({ | ||
icon: { | ||
position: 'relative', | ||
width: 30, | ||
height: 30, | ||
}, | ||
tokenIcon: { | ||
height: 30, | ||
width: 30, | ||
}, | ||
badgeIcon: { | ||
position: 'absolute', | ||
right: -3, | ||
bottom: -2, | ||
}, | ||
})) | ||
|
||
export interface CoinIconProps extends BoxProps { | ||
chainId?: ChainId | ||
address?: string | ||
token?: Web3Helper.FungibleTokenAll | ||
tokenIconSize?: number | ||
chainIconSize?: number | ||
disableBadge?: boolean | ||
} | ||
|
||
export const CoinIcon = memo<CoinIconProps>(function CoinIcon({ | ||
chainId, | ||
address, | ||
tokenIconSize = 30, | ||
chainIconSize = 12, | ||
disableBadge, | ||
...rest | ||
}) { | ||
const { classes, cx } = useStyles() | ||
|
||
const { data: logoURL } = useQuery({ | ||
queryKey: ['okx-tokens', chainId], | ||
queryFn: chainId ? () => OKX.getTokens(chainId) : skipToken, | ||
select(tokens) { | ||
return tokens?.find((x) => isSameAddress(x.address, address))?.logoURL | ||
}, | ||
}) | ||
return ( | ||
<Box className={cx(classes.icon, rest.className)}> | ||
<TokenIcon | ||
className={classes.tokenIcon} | ||
chainId={chainId} | ||
address={address || ''} | ||
size={tokenIconSize} | ||
logoURL={logoURL} | ||
/> | ||
{chainId && !disableBadge ? | ||
<NetworkIcon | ||
pluginID={NetworkPluginID.PLUGIN_EVM} | ||
className={classes.badgeIcon} | ||
chainId={chainId} | ||
size={chainIconSize} | ||
/> | ||
: null} | ||
</Box> | ||
) | ||
}) |
Oops, something went wrong.