Skip to content

Commit

Permalink
display token symbol in asset selector (#664)
Browse files Browse the repository at this point in the history
* display token symbol in asset selector

* Swap out selector as well

---------

Co-authored-by: Gabe Rodriguez <[email protected]>
  • Loading branch information
hdevalence and grod220 authored Mar 8, 2024
1 parent 6c91054 commit c6581a2
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 16 deletions.
15 changes: 6 additions & 9 deletions apps/minifront/src/components/shared/select-token-modal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,8 @@ import {
Input,
} from '@penumbra-zone/ui';
import { cn } from '@penumbra-zone/ui/lib/utils';
import { AssetIcon } from '@penumbra-zone/ui/components/ui/tx/view/asset-icon';
import { ValueViewComponent } from '@penumbra-zone/ui/components/ui/tx/view/value';
import { getAddressIndex, getDisplayDenomFromView, getMetadata } from '@penumbra-zone/getters';
import { getAddressIndex } from '@penumbra-zone/getters';
import { BalancesResponse } from '@buf/penumbra-zone_penumbra.bufbuild_es/penumbra/view/v1/view_pb';

interface SelectTokenModalProps {
Expand All @@ -27,17 +26,15 @@ export default function SelectTokenModal({
}: SelectTokenModalProps) {
const [search, setSearch] = useState('');

const displayDenom = getDisplayDenomFromView(selection?.balanceView);
const denomMetadata = getMetadata.optional()(selection?.balanceView);

return (
<Dialog>
<DialogTrigger disabled={!balances.length}>
<div className='flex h-9 min-w-[100px] max-w-[200px] items-center justify-center gap-2 rounded-lg bg-light-brown px-2'>
{denomMetadata && <AssetIcon metadata={denomMetadata} />}
<p className='shrink truncate font-bold text-light-grey md:text-sm xl:text-base'>
{displayDenom}
</p>
<ValueViewComponent
view={selection?.balanceView}
showValue={false}
showEquivalent={false}
/>
</div>
</DialogTrigger>
<DialogContent>
Expand Down
6 changes: 5 additions & 1 deletion apps/minifront/src/components/swap/asset-out-box.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,11 @@ export const AssetOutBox = ({ balances }: AssetOutBoxProps) => {
) : (
<EstimateButton simulateFn={simulateSwap} />
)}
<AssetOutSelector balances={balances} assetOut={assetOut} setAssetOut={setAssetOut} />
<AssetOutSelector
balances={balances}
assetOut={matchingBalance}
setAssetOut={setAssetOut}
/>
</div>
<div className='mt-[6px] flex items-start justify-between'>
<div />
Expand Down
13 changes: 7 additions & 6 deletions apps/minifront/src/components/swap/asset-out-selector.tsx
Original file line number Diff line number Diff line change
@@ -1,12 +1,16 @@
import { Dialog, DialogClose, DialogContent, DialogHeader, DialogTrigger } from '@penumbra-zone/ui';
import { AssetIcon } from '@penumbra-zone/ui/components/ui/tx/view/asset-icon';
import { Metadata } from '@buf/penumbra-zone_penumbra.bufbuild_es/penumbra/core/asset/v1/asset_pb';
import {
Metadata,
ValueView,
} from '@buf/penumbra-zone_penumbra.bufbuild_es/penumbra/core/asset/v1/asset_pb';
import { localAssets } from '@penumbra-zone/constants';
import { BalancesResponse } from '@buf/penumbra-zone_penumbra.bufbuild_es/penumbra/view/v1/view_pb';
import { ValueViewComponent } from '@penumbra-zone/ui/components/ui/tx/view/value';

interface AssetOutSelectorProps {
balances: BalancesResponse[];
assetOut: Metadata | undefined;
assetOut: ValueView | undefined;
setAssetOut: (metadata: Metadata) => void;
}

Expand All @@ -16,10 +20,7 @@ export const AssetOutSelector = ({ balances, setAssetOut, assetOut }: AssetOutSe
<Dialog>
<DialogTrigger disabled={!balances.length}>
<div className='flex h-9 min-w-[100px] max-w-[150px] items-center justify-center gap-2 rounded-lg bg-light-brown px-2'>
{assetOut?.display && <AssetIcon metadata={assetOut} />}
<p className='truncate font-bold text-light-grey md:text-sm xl:text-base'>
{assetOut?.display}
</p>
<ValueViewComponent view={assetOut} showValue={false} showEquivalent={false} />
</div>
</DialogTrigger>
<DialogContent>
Expand Down

0 comments on commit c6581a2

Please sign in to comment.