-
Notifications
You must be signed in to change notification settings - Fork 230
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
feat: Native Send Component #1874
Draft
brendan-defi
wants to merge
77
commits into
main
Choose a base branch
from
bf/ock-send
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Changes from all commits
Commits
Show all changes
77 commits
Select commit
Hold shift + click to select a range
a86df54
send scaffolding
brendan-defi 9847c09
remove ethbalance from provider props
brendan-defi 318e32a
update utils
brendan-defi ff7d2fa
refactor to remove sendprovider dep
brendan-defi 9afd32d
starting address selection
brendan-defi 96f02d7
update getAddress to support basename reverse res
brendan-defi 53433ae
utils + tests
brendan-defi 7254218
early send flows
brendan-defi e9254e2
move send into wallet
brendan-defi 8f30262
send in walletisland
brendan-defi b921ac5
state drives active screen
brendan-defi 91a38a7
use amount input in send
brendan-defi 3d86e6e
send amount input
brendan-defi 51fd103
remove comments, unused imports
brendan-defi f43e395
fix imports
brendan-defi 08757f8
fix imports, tests
brendan-defi 33ba23d
removed duplicate hook
brendan-defi 210adc5
add close button
brendan-defi 020bbf7
address input reset
brendan-defi 8fd2959
send updates
brendan-defi e0e628b
token balance component
brendan-defi 779c941
enable actions on token balance
brendan-defi 9eb6db5
token selection
brendan-defi a44d528
improved token reselection
brendan-defi ff8e814
improved asset type switch
brendan-defi 25b8a55
update send button
brendan-defi c534c15
header back button
brendan-defi 55f53ff
fix imports
brendan-defi 8f0a51f
refactor provider for clarity
brendan-defi 35bf65d
update filename
brendan-defi 9df538d
fix subtitle
brendan-defi 1ff95e5
add fundcard when no eth balance
brendan-defi 6982ae7
minor refactor
brendan-defi 2279e9b
design review
brendan-defi e5cafbd
fix ethBalance race condition
brendan-defi 35b25ca
fix lints
brendan-defi eb50673
use common files
brendan-defi 250b5ee
subcomponents use props
brendan-defi 4498479
override classnames
brendan-defi 67195c7
input field uses names
brendan-defi 8b49f1d
update send fund wallet
brendan-defi aafd0b4
use common files
brendan-defi 8cfd20f
remove send exportsc
brendan-defi faaf63b
update token balance display
brendan-defi 830a6c9
remove max width from token name
brendan-defi 2c24140
fix use max
brendan-defi 13e6444
hardcode input autocomplete props
brendan-defi 4e2921e
send on base and mainnet
brendan-defi 7ef5f64
fix button-within-button bug
brendan-defi cdc00d7
implement succcessOverride
brendan-defi 1236114
fix lints
brendan-defi 6d9c479
implement lifecycle tracking
brendan-defi f2ab55b
update types to conform to standard useLifecycleStatus non-null expec…
brendan-defi d782eb0
fix lints
brendan-defi 767ce16
fix playground package.json
brendan-defi 3a33745
remove error export, improve number transforms
brendan-defi ba7f51a
improve number transforms
brendan-defi 6bee52c
improved number transforms
brendan-defi 4245695
improved number transforms
brendan-defi df2930b
utils for readability and reuse
brendan-defi 80f180a
remove identity wrapper
brendan-defi 255cfb4
utility for resolving the displayed address/name
brendan-defi f0beaef
use utility
brendan-defi 90eacf3
revert type change
brendan-defi 5d031a4
update lifecycle types
brendan-defi ddf6abf
update and create utils
brendan-defi 9816bcb
button label
brendan-defi 4281d2e
update provider and types
brendan-defi c76fe05
clean provider
brendan-defi 1f58995
handle null args
brendan-defi 58275a6
refactor to better leverage TextInput
brendan-defi b13ecd6
consolidate address selection
brendan-defi 5693495
refactor to avoid rerenders
brendan-defi 1ced463
handle status updates
brendan-defi 7418419
header handles address reset
brendan-defi 9262f14
fix lints
brendan-defi c444463
fix spacing
brendan-defi File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,134 @@ | ||
import type { PortfolioTokenWithFiatValue } from '@/api/types'; | ||
import { formatFiatAmount } from '@/internal/utils/formatFiatAmount'; | ||
import { truncateDecimalPlaces } from '@/internal/utils/truncateDecimalPlaces'; | ||
import { border, cn, color, text } from '@/styles/theme'; | ||
import { TokenImage } from '@/token'; | ||
import { useMemo } from 'react'; | ||
import { formatUnits } from 'viem'; | ||
|
||
type TokenBalanceProps = { | ||
token: PortfolioTokenWithFiatValue; | ||
subtitle: string; | ||
showImage?: boolean; | ||
onClick?: (token: PortfolioTokenWithFiatValue) => void; | ||
className?: string; | ||
} & ( | ||
| { showAction?: true; actionText?: string; onActionPress?: () => void } | ||
| { showAction?: false; actionText?: never; onActionPress?: never } | ||
); | ||
|
||
export function TokenBalance({ | ||
token, | ||
subtitle, | ||
showImage = true, | ||
onClick, | ||
showAction = false, | ||
actionText = 'Use max', | ||
onActionPress, | ||
className, | ||
}: TokenBalanceProps) { | ||
const formattedFiatValue = formatFiatAmount({ | ||
amount: token.fiatBalance, | ||
currency: 'USD', | ||
}); | ||
|
||
const formattedCryptoValue = truncateDecimalPlaces( | ||
formatUnits(BigInt(token.cryptoBalance), token.decimals), | ||
3, | ||
); | ||
|
||
const tokenContent = useMemo(() => { | ||
return ( | ||
<div className="grid w-full grid-cols-[2.5rem_1fr_auto] items-center gap-3"> | ||
<div className="h-10 w-10"> | ||
{showImage && <TokenImage token={token} size={40} />} | ||
</div> | ||
<div className="flex min-w-0 flex-col text-left"> | ||
<span | ||
className={cn( | ||
text.headline, | ||
color.foreground, | ||
'overflow-hidden text-ellipsis whitespace-nowrap', | ||
)} | ||
> | ||
{token.name?.trim()} | ||
</span> | ||
<span className={cn(text.label2, color.foregroundMuted)}> | ||
{`${formattedCryptoValue} ${token.symbol} ${subtitle}`} | ||
</span> | ||
</div> | ||
<div className="text-right"> | ||
{showAction ? ( | ||
<span | ||
aria-label={actionText} | ||
onClick={(e) => { | ||
e.stopPropagation(); | ||
onActionPress?.(); | ||
}} | ||
onKeyDown={(e) => { | ||
e.stopPropagation(); | ||
onActionPress?.(); | ||
}} | ||
className={cn( | ||
text.label2, | ||
color.primary, | ||
border.radius, | ||
'ml-auto p-0.5 font-bold', | ||
'border border-transparent hover:border-[--ock-line-primary]', | ||
)} | ||
> | ||
{actionText} | ||
</span> | ||
) : ( | ||
<span | ||
className={cn( | ||
text.label2, | ||
color.foregroundMuted, | ||
'whitespace-nowrap', | ||
)} | ||
> | ||
{formattedFiatValue} | ||
</span> | ||
)} | ||
</div> | ||
</div> | ||
); | ||
}, [ | ||
showImage, | ||
token, | ||
subtitle, | ||
showAction, | ||
actionText, | ||
onActionPress, | ||
formattedFiatValue, | ||
formattedCryptoValue, | ||
]); | ||
|
||
if (onClick) { | ||
return ( | ||
<button | ||
type="button" | ||
onClick={() => onClick(token)} | ||
className={cn( | ||
'flex w-full items-center justify-start gap-4 px-2 py-1', | ||
className, | ||
)} | ||
data-testid="ockTokenBalanceButton" | ||
> | ||
{tokenContent} | ||
</button> | ||
); | ||
} | ||
|
||
return ( | ||
<div | ||
className={cn( | ||
'flex w-full items-center justify-start gap-4 px-2 py-1', | ||
className, | ||
)} | ||
data-testid="ockTokenBalanceDiv" | ||
> | ||
{tokenContent} | ||
</div> | ||
); | ||
} |
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
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 |
---|---|---|
|
@@ -32,7 +32,14 @@ export const TokenRow = memo(function TokenRow({ | |
<span className="flex items-center gap-3"> | ||
{!hideImage && <TokenImage token={token} size={28} />} | ||
<span className="flex flex-col items-start"> | ||
<span className={cn(text.headline)}>{token.name}</span> | ||
<span | ||
className={cn( | ||
text.headline, | ||
'overflow-hidden text-ellipsis whitespace-nowrap text-left', | ||
)} | ||
> | ||
{token.name.trim()} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Curious what the need for There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. some tokens have whitespace at the front / end for style /s. we don't want that |
||
</span> | ||
{!hideSymbol && ( | ||
<span className={cn(text.body, color.foregroundMuted)}> | ||
{token.symbol} | ||
|
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why
<span >
here? Probably should be a button if it's clickableThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can't have a button within a button, and sometimes the whole container is a button