Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CU-86a5j1veu-NEON3 - Swap - Implement Swap Details Page #240

Merged
merged 1 commit into from
Nov 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
112 changes: 35 additions & 77 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 6 additions & 6 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,13 +29,13 @@
"playwright:report": "npx playwright show-report"
},
"dependencies": {
"@cityofzion/blockchain-service": "1.8.0",
"@cityofzion/blockchain-service": "1.10.0",
"@cityofzion/bs-asteroid-sdk": "0.9.0",
"@cityofzion/bs-electron": "0.1.19",
"@cityofzion/bs-ethereum": "2.7.0",
"@cityofzion/bs-neo-legacy": "1.6.0",
"@cityofzion/bs-neo3": "1.8.2",
"@cityofzion/bs-swap": "0.1.1",
"@cityofzion/bs-electron": "0.1.21",
"@cityofzion/bs-ethereum": "2.7.2",
"@cityofzion/bs-neo-legacy": "1.6.2",
"@cityofzion/bs-neo3": "1.8.3",
"@cityofzion/bs-swap": "0.2.1",
"@cityofzion/neon-core": "5.5.1",
"@cityofzion/neon-js": "5.5.1",
"@cityofzion/wallet-connect-sdk-wallet-core": "4.4.0",
Expand Down
Binary file removed src/renderer/src/assets/images/simple-swap-logo.png
Binary file not shown.
90 changes: 90 additions & 0 deletions src/renderer/src/components/Details.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
import { cloneElement, ComponentProps } from 'react'
import { MdOutlineContentCopy } from 'react-icons/md'
import { StyleHelper } from '@renderer/helpers/StyleHelper'
import { UtilsHelper } from '@renderer/helpers/UtilsHelper'

import { IconButton } from './IconButton'
import { Separator } from './Separator'

type TRootProps = ComponentProps<'div'>
const Root = ({ className, children, ...props }: TRootProps) => {
return (
<div
className={StyleHelper.mergeStyles('flex flex-col py-2.5 px-4 bg-asphalt rounded w-full', className)}
{...props}
>
{children}
</div>
)
}

type THeaderProps = {
label: string
icon?: JSX.Element
} & ComponentProps<'div'>
const Header = ({ label, icon, children, ...props }: THeaderProps) => {
return (
<div {...props}>
<div className="flex items-center gap-2.5">
{icon && cloneElement(icon, { className: StyleHelper.mergeStyles('text-blue w-6 h-6', icon.props.className) })}

<span className="text-sm text-white">{label}</span>

{children}
</div>

<Separator className="mt-2.5 mb-5" />
</div>
)
}
type TBodyProps = ComponentProps<'div'>
const Body = ({ className, children, ...props }: TBodyProps) => {
return (
<div className={StyleHelper.mergeStyles('flex flex-col gap-5', className)} {...props}>
{children}
</div>
)
}

type TPanelProps = { label: string } & ComponentProps<'div'>
const Panel = ({ className, children, label, ...props }: TPanelProps) => {
return (
<div className={StyleHelper.mergeStyles('flex flex-col', className)} {...props}>
<div className="text-blue text-xs py-1.5 px-3.5 bg-gray-300/15 ">{label}</div>

{children}
</div>
)
}

type TItemProps = { label: string; copyable?: boolean } & ComponentProps<'div'>
const Item = ({ label, children, copyable, className, ...props }: TItemProps) => {
const handleCopy = () => {
if (typeof children !== 'string') return
UtilsHelper.copyToClipboard(children)
}
return (
<div className={StyleHelper.mergeStyles('flex flex-col group', className)}>
<div className="flex flex-col gap-2.5 py-4 px-3" {...props}>
<span className="text-xs text-gray-100 uppercase">{label}</span>

<div className="flex gap-2.5 items-center">
{typeof children === 'string' ? <span className="text-sm text-white break-all">{children}</span> : children}

{copyable && (
<IconButton
icon={<MdOutlineContentCopy className="text-neon" />}
size="sm"
onClick={handleCopy}
compacted
/>
)}
</div>
</div>

<Separator className="group-last:hidden" />
</div>
)
}

export const Details = { Root, Header, Body, Panel, Item }
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { Fragment, useEffect, useState } from 'react'
import defaultTokenLogo from '@renderer/assets/images/default-token-logo.png'
import { NumberHelper } from '@renderer/helpers/NumberHelper'

import { TGreyTokenSelectToken } from '.'

Expand Down Expand Up @@ -30,6 +31,10 @@ export const GreyTokenSelectItem = ({ token }: TProps) => {
<span className="text-white text-sm text-left uppercase truncate">{token.symbol}</span>
{token.network && <span className="text-gray-100 text-sm truncate uppercase">{` | ${token.network}`}</span>}
</span>

{token.amount && (
<span className="text-1xs text-neon truncate">{NumberHelper.formatString(token.amount, 6)}</span>
)}
</Fragment>
)
}
8 changes: 5 additions & 3 deletions src/renderer/src/components/GreyTokenSelect/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,9 @@ export const GreyTokenSelect = <T extends TGreyTokenSelectToken>({
if (balance) {
filtered = filtered.map(token => {
const tokenHash = UtilsHelper.normalizeHash(token.hash!)
const tokenBalance = balance.tokensBalances.find(tokenBalance => tokenBalance.token.hash === tokenHash)
const tokenBalance = balance.tokensBalances.find(
tokenBalance => UtilsHelper.normalizeHash(tokenBalance.token.hash) === tokenHash
)

return {
...token,
Expand Down Expand Up @@ -144,7 +146,7 @@ export const GreyTokenSelect = <T extends TGreyTokenSelectToken>({
position: 'relative',
}}
>
{rowVirtualizer.getVirtualItems().map(virtualItem => {
{rowVirtualizer.getVirtualItems().map((virtualItem, _, array) => {
const row = filteredTokensByText[virtualItem.index]

return (
Expand All @@ -162,7 +164,7 @@ export const GreyTokenSelect = <T extends TGreyTokenSelectToken>({
<GreyTokenSelectItem token={row} />
</div>

<Separator />
{virtualItem.index + 1 !== array.length && <Separator />}
</Command.Item>
)
})}
Expand Down
5 changes: 3 additions & 2 deletions src/renderer/src/components/Modal/SideModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,9 @@ import { ModalContainer } from './ModalContainer'
const widthBySizes: Partial<Record<TRouterSize, string>> = {
md: '25.875rem',
sm: '20.625rem',
xl: '62.5rem',
lg: '45rem',
lg: '32rem',
xl: '45rem',
'1xl': '62.5rem',
}

export const SideModal = () => {
Expand Down
Loading