-
Notifications
You must be signed in to change notification settings - Fork 241
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
82
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
82 commits
Select commit
Hold shift + click to select a range
17d6b57
send scaffolding
brendan-defi 29ce8e2
remove ethbalance from provider props
brendan-defi d5f399f
update utils
brendan-defi cb64639
refactor to remove sendprovider dep
brendan-defi 971dc6a
starting address selection
brendan-defi 05eb416
update getAddress to support basename reverse res
brendan-defi a89983c
utils + tests
brendan-defi 033c4b8
early send flows
brendan-defi 6ede224
move send into wallet
brendan-defi b9bba55
send in walletisland
brendan-defi c50f9a8
state drives active screen
brendan-defi ebe1a68
use amount input in send
brendan-defi b0a97f5
send amount input
brendan-defi 7cb8665
remove comments, unused imports
brendan-defi f029ffb
fix imports
brendan-defi c49fe08
fix imports, tests
brendan-defi 8964803
removed duplicate hook
brendan-defi 9e63f2d
add close button
brendan-defi 57f92da
address input reset
brendan-defi b56268e
send updates
brendan-defi c936a62
token balance component
brendan-defi f379001
enable actions on token balance
brendan-defi f3854da
token selection
brendan-defi b1df7ac
improved token reselection
brendan-defi da50b49
improved asset type switch
brendan-defi 393fc34
update send button
brendan-defi d029daf
header back button
brendan-defi bfbb95a
fix imports
brendan-defi ada978b
refactor provider for clarity
brendan-defi 58d9600
update filename
brendan-defi 69e5ab9
fix subtitle
brendan-defi ad5af09
add fundcard when no eth balance
brendan-defi 35efd87
minor refactor
brendan-defi 620554b
design review
brendan-defi c3d3e84
fix ethBalance race condition
brendan-defi 77771aa
fix lints
brendan-defi 320f46d
use common files
brendan-defi 8999246
subcomponents use props
brendan-defi 1ed61e6
override classnames
brendan-defi 26aff3a
input field uses names
brendan-defi 671505e
update send fund wallet
brendan-defi d542d7e
use common files
brendan-defi a44357a
remove send exportsc
brendan-defi f15c9b6
update token balance display
brendan-defi 430e3d2
remove max width from token name
brendan-defi 588a8a4
fix use max
brendan-defi 67e9726
hardcode input autocomplete props
brendan-defi 7a25392
send on base and mainnet
brendan-defi a9cc65b
fix button-within-button bug
brendan-defi d838f28
implement succcessOverride
brendan-defi 3ad97f7
fix lints
brendan-defi 02aed37
implement lifecycle tracking
brendan-defi 930add1
update types to conform to standard useLifecycleStatus non-null expec…
brendan-defi 66cd248
fix lints
brendan-defi c1061d0
fix playground package.json
brendan-defi adbbe2e
remove error export, improve number transforms
brendan-defi 240a3f7
improve number transforms
brendan-defi 84d73d1
improved number transforms
brendan-defi 640615a
improved number transforms
brendan-defi 4f5452e
utils for readability and reuse
brendan-defi 6be3572
remove identity wrapper
brendan-defi 4358eaa
utility for resolving the displayed address/name
brendan-defi ca305b2
use utility
brendan-defi be0826e
revert type change
brendan-defi 1bc72ff
update lifecycle types
brendan-defi 00f920d
update and create utils
brendan-defi 441795b
button label
brendan-defi fe0de1c
update provider and types
brendan-defi 266afbf
clean provider
brendan-defi 4be81d1
handle null args
brendan-defi d5a9b15
refactor to better leverage TextInput
brendan-defi b61afce
consolidate address selection
brendan-defi 5e1d699
refactor to avoid rerenders
brendan-defi b1d9011
handle status updates
brendan-defi 4f88bb0
header handles address reset
brendan-defi 9438101
fix lints
brendan-defi 51947c3
fix spacing
brendan-defi a89d3f1
fix input resetting
brendan-defi d0fe8e8
add debounce to value inputs
brendan-defi 98c1207
refactor resolve address input
brendan-defi 1a8c48a
fix walletHasEth logic
brendan-defi 353a8e8
fix design feedback
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
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.
may be better to style the second button so it appears over the top using position relative to avoid having an interactive descendent of a button. Even with an onClick, a span won't be tabbable without a tabindex or role, both of which would make this invalid.