Skip to content

Commit

Permalink
[Explorer]: Apps address asset (MystenLabs#13281)
Browse files Browse the repository at this point in the history
## Description 


![address-update](https://github.com/MystenLabs/sui/assets/127577476/b4e8e3ba-40d5-44d0-aa1b-73ff16b44d49)


## Test Plan 

How did you test the new or updated feature?

---
If your changes are not user-facing and not a breaking change, you can
skip the following section. Otherwise, please indicate what changed, and
then add to the Release Notes section as highlighted during the release
process.

### Type of Change (Check all that apply)

- [ ] protocol change
- [ ] user-visible impact
- [ ] breaking change for a client SDKs
- [ ] breaking change for FNs (FN binary must upgrade)
- [ ] breaking change for validators or node operators (must upgrade
binaries)
- [ ] breaking change for on-chain data layout
- [ ] necessitate either a data wipe or data migration

### Release notes

---------

Co-authored-by: Nikhil Mattu <[email protected]>
  • Loading branch information
plam-ml and Nikhil-Mysten authored Aug 5, 2023
1 parent a6d83b1 commit 3dacfa0
Show file tree
Hide file tree
Showing 20 changed files with 549 additions and 91 deletions.
11 changes: 11 additions & 0 deletions apps/core/tailwind.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -167,15 +167,26 @@ export default {
},
height: {
31.5: '7.5rem',
120: '30rem',
coinsAndAssetsContainer: '31.25rem',
},
maxHeight: {
coinsAndAssetsContainer: '31.25rem',
},
width: {
31.5: '7.5rem',
walletLogo: '4.813rem',
},
maxWidth: {
80: '20rem',
},
minWidth: {
10: '2.5rem',
18: '4.5rem',
50: '12.5rem',
transactionColumn: '31.875rem',
ownObjectContainer: '13.125rem',
ownObjectContainerMobile: '9.375rem',
},
transitionTimingFunction: {
'ease-in-out-cubic': 'cubic-bezier(0.65, 0, 0.35, 1)',
Expand Down
2 changes: 1 addition & 1 deletion apps/explorer/src/components/OwnedCoins/CoinItem.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ type CoinItemProps = {
export default function CoinItem({ coin }: CoinItemProps) {
const [formattedBalance, symbol] = useFormatCoin(coin.balance, coin.coinType);
return (
<div className="flex items-center justify-between rounded-lg bg-white px-3 py-2 shadow-panel">
<div className="flex min-w-50 max-w-80 items-center justify-between rounded-lg bg-white px-3 py-2 shadow-panel">
<ObjectLink objectId={coin.coinObjectId} />
<div className="col-span-3 inline-flex items-center gap-1">
<Text color="steel-darker" variant="bodySmall/medium">
Expand Down
4 changes: 2 additions & 2 deletions apps/explorer/src/components/OwnedCoins/OwnedCoinView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -68,13 +68,13 @@ export default function OwnedCoinView({ coin, id }: OwnedCoinViewProps) {
)}
</div>

<div className="flex w-[25%] px-2">
<div className="flex w-[25%] pl-2">
<Text color={coin.isRecognized ? 'steel-darker' : 'gray-60'} variant="body/medium">
{coin.coinObjectCount}
</Text>
</div>

<div className="flex w-[30%] items-center gap-1 truncate">
<div className="flex w-[30%] items-center gap-1 truncate pl-1">
<Text
color={coin.isRecognized ? 'steel-darker' : 'gray-60'}
variant="bodySmall/medium"
Expand Down
8 changes: 4 additions & 4 deletions apps/explorer/src/components/OwnedCoins/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -76,12 +76,12 @@ export function OwnedCoins({ id }: { id: string }) {

const filterOptions = useMemo(
() => [
{ label: 'ALL', value: COIN_FILTERS.ALL },
{ label: `${balances.recognizedBalances.length} RECOGNIZED`, value: COIN_FILTERS.RECOGNIZED },
{
label: `${balances.unrecognizedBalances.length} UNRECOGNIZED`,
value: COIN_FILTERS.UNRECOGNIZED,
},
{ label: 'ALL', value: COIN_FILTERS.ALL },
],
[balances],
);
Expand All @@ -99,8 +99,8 @@ export function OwnedCoins({ id }: { id: string }) {
<LoadingIndicator />
</div>
) : (
<div className="flex flex-col gap-4 pt-5 text-left">
<div className='md:mt-12" flex w-full justify-between border-b border-gray-45 pb-3'>
<div className="flex max-h-coinsAndAssetsContainer flex-col gap-4 pt-5 text-left ">
<div className="flex w-full flex-col justify-between gap-y-3 border-b border-gray-45 pb-3 sm:flex-row">
<Heading color="steel-darker" variant="heading4/semibold">
{balances.allBalances.length} Coins
</Heading>
Expand Down Expand Up @@ -132,7 +132,7 @@ export function OwnedCoins({ id }: { id: string }) {
</div>
)}

<div className="flex max-h-80 flex-col overflow-auto">
<div className="flex flex-col overflow-auto">
<div className="mb-2.5 flex uppercase tracking-wider text-gray-80">
<div className="w-[45%] pl-3">
<Text variant="caption/medium" color="steel-dark">
Expand Down
131 changes: 131 additions & 0 deletions apps/explorer/src/components/OwnedObjects/ListView.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,131 @@
// Copyright (c) Mysten Labs, Inc.
// SPDX-License-Identifier: Apache-2.0

import { type SuiObjectResponse } from '@mysten/sui.js/client';
import { Placeholder, Text } from '@mysten/ui';
import { type ReactNode, useState } from 'react';

import { useResolveVideo } from '~/hooks/useResolveVideo';
import { ObjectLink } from '~/ui/InternalLink';
import { ObjectVideoImage } from '~/ui/ObjectVideoImage';
import { parseObjectType } from '~/utils/objectUtils';
import { trimStdLibPrefix } from '~/utils/stringUtils';

function ListViewItem({
asset,
type,
objectId,
loading,
onClick,
}: {
asset?: ReactNode;
type?: ReactNode;
objectId?: ReactNode;
loading?: boolean;
onClick?: () => void;
}) {
return (
<div
onClick={onClick}
className="group mb-2 flex items-center justify-between rounded-lg p-1 hover:bg-hero/5"
>
<div className="flex max-w-[66%] basis-8/12 items-center gap-3 md:max-w-[25%] md:basis-3/12 md:pr-5">
{loading ? <Placeholder rounded="lg" width="540px" height="20px" /> : asset}
</div>

<div className="hidden max-w-[50%] basis-6/12 pr-5 md:flex">
{loading ? <Placeholder rounded="lg" width="540px" height="20px" /> : type}
</div>

<div className="flex max-w-[34%] basis-3/12">
{loading ? <Placeholder rounded="lg" width="540px" height="20px" /> : objectId}
</div>
</div>
);
}

function ListViewItemContainer({ obj }: { obj: SuiObjectResponse }) {
const [open, setOpen] = useState(false);
const video = useResolveVideo(obj);
const displayMeta = obj.data?.display?.data;
const name = displayMeta?.name ?? displayMeta?.description ?? '';
const type = trimStdLibPrefix(parseObjectType(obj));
const objectId = obj.data?.objectId;

return (
<ListViewItem
asset={
<>
<ObjectVideoImage
title={name}
subtitle={type}
src={displayMeta?.image_url || ''}
video={video}
variant="xs"
open={open}
setOpen={setOpen}
/>
<div className="flex flex-col overflow-hidden">
<Text variant="subtitle/semibold" color="steel-darker" truncate>
{name || '--'}
</Text>
<div className="block md:hidden">
<Text variant="pSubtitle/normal" color="steel-dark" truncate>
{type}
</Text>
</div>
</div>
</>
}
type={
<Text variant="bodySmall/medium" color="steel-dark" truncate>
{type}
</Text>
}
objectId={
<Text variant="bodySmall/medium" color="steel-dark" truncate>
{objectId && <ObjectLink objectId={objectId} />}
</Text>
}
/>
);
}

interface ListViewProps {
data?: SuiObjectResponse[];
loading?: boolean;
}

export function ListView({ data, loading }: ListViewProps) {
return (
<div className="flex flex-col overflow-auto">
<div className="mb-3.5 flex w-full justify-around">
<div className="max-w-[66%] basis-8/12 md:max-w-[25%] md:basis-3/12">
<Text variant="caption/medium" color="steel-dark">
ASSET
</Text>
</div>
<div className="hidden basis-6/12 md:block">
<Text variant="caption/medium" color="steel-dark">
TYPE
</Text>
</div>
<div className="basis-3/12">
<Text variant="caption/medium" color="steel-dark">
OBJECT ID
</Text>
</div>
</div>
{loading && new Array(10).fill(0).map((_, index) => <ListViewItem key={index} loading />)}

<div className="flex h-full w-full flex-col overflow-y-scroll">
{data?.map((obj) => {
if (!obj.data) {
return null;
}
return <ListViewItemContainer key={obj.data.objectId} obj={obj} />;
})}
</div>
</div>
);
}
3 changes: 2 additions & 1 deletion apps/explorer/src/components/OwnedObjects/OwnedObject.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,11 @@ export default function OwnedObject({ obj }: OwnedObjectTypes) {

return (
<ObjectDetails
noTypeRender
variant="small"
id={obj.data?.objectId}
type={trimStdLibPrefix(parseObjectType(obj))}
name={displayMeta?.name ?? displayMeta?.description}
name={displayMeta?.name ?? displayMeta?.description ?? '--'}
image={displayMeta?.image_url}
video={video}
/>
Expand Down
46 changes: 46 additions & 0 deletions apps/explorer/src/components/OwnedObjects/SmallThumbNailsView.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
// Copyright (c) Mysten Labs, Inc.
// SPDX-License-Identifier: Apache-2.0

import { type SuiObjectResponse } from '@mysten/sui.js/client';
import { Placeholder } from '@mysten/ui';
import { type ReactNode } from 'react';

import OwnedObject from '~/components/OwnedObjects/OwnedObject';

interface Props {
data?: SuiObjectResponse[];
loading?: boolean;
}

function OwnObjectContainer({ children }: { children: ReactNode }) {
return (
<div className="w-full min-w-ownObjectContainerMobile basis-1/2 pb-3 pr-4 md:min-w-ownObjectContainer md:basis-1/4">
<div className="rounded-lg p-2 hover:bg-hero/5">{children}</div>
</div>
);
}

function SmallThumbNailsViewLoading() {
return (
<>
{new Array(10).fill(0).map((_, index) => (
<OwnObjectContainer key={index}>
<Placeholder rounded="lg" height="80px" />
</OwnObjectContainer>
))}
</>
);
}

export function SmallThumbNailsView({ data, loading }: Props) {
return (
<div className="flex flex-row flex-wrap overflow-auto">
{loading && <SmallThumbNailsViewLoading />}
{data?.map((obj, index) => (
<OwnObjectContainer key={index}>
<OwnedObject obj={obj} key={obj?.data?.objectId} />
</OwnObjectContainer>
))}
</div>
);
}
Loading

0 comments on commit 3dacfa0

Please sign in to comment.