From 21516c64a49293433937e67992417e443c58f052 Mon Sep 17 00:00:00 2001 From: Jennie Alles Date: Thu, 18 Jan 2024 17:49:35 +0700 Subject: [PATCH 1/8] fix(components): fix nft related bugs --- src/lib/components/action-msg/SingleMsg.tsx | 6 ++- .../components/button/InstantiateButton.tsx | 14 +++---- src/lib/components/icon/CustomIcon.tsx | 2 +- .../json-schema/EditSchemaButtons.tsx | 3 +- src/lib/components/nft/NftCard.tsx | 1 + .../table/modules/ModulePathLink.tsx | 2 +- .../MutateEventsTableMobileCard.tsx | 8 +++- .../mutate-events/MutateEventsTableRow.tsx | 12 +++++- src/lib/layout/mobile/NavDrawer.tsx | 11 +++++ .../components/nfts/FilterItem.tsx | 25 +++++++---- .../components/nfts/NftsSection.tsx | 1 + .../module-details/components/ModuleTop.tsx | 1 + src/lib/pages/nft-collection-details/data.ts | 2 +- .../pages/nft-collection-details/index.tsx | 42 +++++++++++-------- .../components/CollectionCard.tsx | 40 +++++++++--------- .../components/CollectionList.tsx | 2 +- .../nft-details/components/NftInfoItem.tsx | 5 ++- src/lib/pages/nft-details/index.tsx | 37 +++++++++++----- .../public-project/components/AllProject.tsx | 3 +- .../components/tx-message/TxMsgExpand.tsx | 4 +- src/lib/styles/theme/components/tag.ts | 5 +-- 21 files changed, 141 insertions(+), 85 deletions(-) diff --git a/src/lib/components/action-msg/SingleMsg.tsx b/src/lib/components/action-msg/SingleMsg.tsx index 5518fab98..9841fc69a 100644 --- a/src/lib/components/action-msg/SingleMsg.tsx +++ b/src/lib/components/action-msg/SingleMsg.tsx @@ -54,6 +54,8 @@ export const SingleMsg = ({ @@ -62,13 +64,13 @@ export const SingleMsg = ({ ))} {/* Tag left over */} {tags && length && length - tags.length > 0 && ( - + +{length - tags.length} )} {/* Length */} {!tags && length && ( - + {length} )} diff --git a/src/lib/components/button/InstantiateButton.tsx b/src/lib/components/button/InstantiateButton.tsx index bcba9ccbf..80a835541 100644 --- a/src/lib/components/button/InstantiateButton.tsx +++ b/src/lib/components/button/InstantiateButton.tsx @@ -23,10 +23,11 @@ const getInstantiateButtonProps = ( variant: string; icon: JSX.Element | undefined; } => { + const buttonDisabledState = "outline-gray"; if (isUnknown) { return { tooltipLabel: "", - variant: "outline-gray", + variant: buttonDisabledState, icon: undefined, }; } @@ -35,20 +36,15 @@ const getInstantiateButtonProps = ( tooltipLabel: isWalletConnected ? "You can instantiate without opening proposal" : "You need to connect wallet to instantiate contract", - variant: "outline-primary", - icon: ( - - ), + variant: isWalletConnected ? "outline-primary" : buttonDisabledState, + icon: , }; } return { tooltipLabel: isWalletConnected ? "Instantiate through proposal only (Coming Soon)" : "You need to connect wallet to open instantiate proposal", - variant: "outline-gray", + variant: buttonDisabledState, icon: , }; }; diff --git a/src/lib/components/icon/CustomIcon.tsx b/src/lib/components/icon/CustomIcon.tsx index 25350fcbb..0e204cc11 100644 --- a/src/lib/components/icon/CustomIcon.tsx +++ b/src/lib/components/icon/CustomIcon.tsx @@ -1539,7 +1539,7 @@ export const ICONS = { /> ), - viewBox: viewboxDefault, + viewBox: "0 0 16 14", }, }; diff --git a/src/lib/components/json-schema/EditSchemaButtons.tsx b/src/lib/components/json-schema/EditSchemaButtons.tsx index 4756c8cc5..c33837a30 100644 --- a/src/lib/components/json-schema/EditSchemaButtons.tsx +++ b/src/lib/components/json-schema/EditSchemaButtons.tsx @@ -26,10 +26,9 @@ export const EditSchemaButtons = ({ } aria-label="reattach schema" /> diff --git a/src/lib/components/nft/NftCard.tsx b/src/lib/components/nft/NftCard.tsx index 3d4421da9..d0f01794e 100644 --- a/src/lib/components/nft/NftCard.tsx +++ b/src/lib/components/nft/NftCard.tsx @@ -39,6 +39,7 @@ export const NftCard = ({ width="100%" height="100%" objectFit="cover" + backgroundPosition="center" borderRadius="8px" src={metadata?.image ? metadata.image : NFT_IMAGE_PLACEHOLDER} /> diff --git a/src/lib/components/table/modules/ModulePathLink.tsx b/src/lib/components/table/modules/ModulePathLink.tsx index 7b226c704..4e7866877 100644 --- a/src/lib/components/table/modules/ModulePathLink.tsx +++ b/src/lib/components/table/modules/ModulePathLink.tsx @@ -22,7 +22,7 @@ export const ModulePathLink = ({ className="copier-wrapper" display={{ base: "inline-flex", md: "flex" }} align="center" - h="24px" + h={{ base: "auto", md: "24px" }} > - {oldValue} + + {oldValue} + - {newValue} + + {newValue} + } diff --git a/src/lib/components/table/mutate-events/MutateEventsTableRow.tsx b/src/lib/components/table/mutate-events/MutateEventsTableRow.tsx index c409c8fd4..e594b9183 100644 --- a/src/lib/components/table/mutate-events/MutateEventsTableRow.tsx +++ b/src/lib/components/table/mutate-events/MutateEventsTableRow.tsx @@ -28,11 +28,19 @@ export const MutateEventsTableRow = ({ {mutatedFieldName} - {oldValue} + + + {oldValue} + + - {newValue} + + + {newValue} + + {formatUTC(timestamp)} diff --git a/src/lib/layout/mobile/NavDrawer.tsx b/src/lib/layout/mobile/NavDrawer.tsx index 5b3995d40..711ac3782 100644 --- a/src/lib/layout/mobile/NavDrawer.tsx +++ b/src/lib/layout/mobile/NavDrawer.tsx @@ -18,6 +18,7 @@ import { NetworkMenu } from "../NetworkMenu"; import { AmpEvent, track } from "lib/amplitude"; import { useMoveConfig, + useNftConfig, usePublicProjectConfig, useWasmConfig, } from "lib/app-provider"; @@ -33,6 +34,7 @@ export const NavDrawer = () => { const { getSavedPublicProjects } = usePublicProjectStore(); const wasm = useWasmConfig({ shouldRedirect: false }); const move = useMoveConfig({ shouldRedirect: false }); + const nft = useNftConfig({ shouldRedirect: false }); const publicProject = usePublicProjectConfig({ shouldRedirect: false }); const mobileMenu: MenuInfo[] = [ @@ -84,6 +86,15 @@ export const NavDrawer = () => { }, ] : []), + ...(nft.enabled + ? [ + { + name: "NFT Collections", + slug: "/nft-collections", + icon: "group" as IconKeys, + }, + ] + : []), ], }, ]; diff --git a/src/lib/pages/account-details/components/nfts/FilterItem.tsx b/src/lib/pages/account-details/components/nfts/FilterItem.tsx index 875e2d904..08d845ea9 100644 --- a/src/lib/pages/account-details/components/nfts/FilterItem.tsx +++ b/src/lib/pages/account-details/components/nfts/FilterItem.tsx @@ -1,7 +1,8 @@ -import { Badge, Box, Flex, Image, Text } from "@chakra-ui/react"; +import { Badge, Flex, Image, Text } from "@chakra-ui/react"; import { AmpEvent, track } from "lib/amplitude"; import { CustomIcon } from "lib/components/icon"; +import { NFT_IMAGE_PLACEHOLDER } from "lib/data"; import { useMetadata } from "lib/services/nft"; interface FilterItemProps { @@ -10,6 +11,7 @@ interface FilterItemProps { onClick: () => void; uri?: string; isActive?: boolean; + isDefault?: boolean; } export const FilterItem = ({ @@ -18,6 +20,7 @@ export const FilterItem = ({ onClick, uri, isActive, + isDefault = false, }: FilterItemProps) => { const { data: metadata } = useMetadata(uri ?? ""); @@ -39,17 +42,23 @@ export const FilterItem = ({ justify="space-between" > - {metadata && uri ? ( + {isDefault ? ( + + + + ) : ( - ) : ( - - - )} {collectionName} diff --git a/src/lib/pages/account-details/components/nfts/NftsSection.tsx b/src/lib/pages/account-details/components/nfts/NftsSection.tsx index 47a4569dc..f53aa730d 100644 --- a/src/lib/pages/account-details/components/nfts/NftsSection.tsx +++ b/src/lib/pages/account-details/components/nfts/NftsSection.tsx @@ -57,6 +57,7 @@ export const NftsSection = ({ address, totalData = 0 }: NftsSectionProps) => { onClick={() => handleOnClick(undefined)} isActive={selectedCollection === undefined} count={totalData} + isDefault /> {collections.map((item) => ( { textFormat="normal" maxWidth="fit-content" type="user_address" + fixedHeight={false} /> {name} @@ -159,22 +160,27 @@ const CollectionDetailsBody = ({ - - - + { bg: "gray.800", }} > - - {metadata?.image ? ( - - ) : ( - - )} - - + + + + {name} + {collections.map((collection) => ( diff --git a/src/lib/pages/nft-details/components/NftInfoItem.tsx b/src/lib/pages/nft-details/components/NftInfoItem.tsx index d1e7bc9f1..89ab1a555 100644 --- a/src/lib/pages/nft-details/components/NftInfoItem.tsx +++ b/src/lib/pages/nft-details/components/NftInfoItem.tsx @@ -13,7 +13,7 @@ export const NftInfoItem = ({ isCentered = true, }: NftInfoItemProps) => ( - {label}: + {label} {children} diff --git a/src/lib/pages/nft-details/index.tsx b/src/lib/pages/nft-details/index.tsx index 56fb3cf7f..2618e5a46 100644 --- a/src/lib/pages/nft-details/index.tsx +++ b/src/lib/pages/nft-details/index.tsx @@ -45,8 +45,6 @@ import { import type { NftDetailQueryParams } from "./types"; import { zNftDetailQueryParams } from "./types"; -const IMAGE_SIZE = "360px"; - const InvalidNft = () => ; const NftDetailsBody = ({ @@ -103,14 +101,31 @@ const NftDetailsBody = ({ tokenId={tokenId} /> )} - +
+ +
{!isMobile && ( <> @@ -157,6 +172,7 @@ const NftDetailsBody = ({ textFormat="normal" maxWidth="full" ampCopierSection="nft-address-nft-detail-top" + fixedHeight={false} />
@@ -168,6 +184,7 @@ const NftDetailsBody = ({ textFormat="normal" maxWidth="full" ampCopierSection="holder-address-nft-detail-top" + fixedHeight={false} /> diff --git a/src/lib/pages/public-project/components/AllProject.tsx b/src/lib/pages/public-project/components/AllProject.tsx index c6d8dfce8..9fc745dd8 100644 --- a/src/lib/pages/public-project/components/AllProject.tsx +++ b/src/lib/pages/public-project/components/AllProject.tsx @@ -63,7 +63,7 @@ export const AllProject = observer(() => { p={12} > - + Gathering Public Projects... { color="text.dark" textAlign="center" whiteSpace="pre-wrap" + variant="body2" > We are currently gathering public projects to feature here.
To share yours with the community, please submit your request. diff --git a/src/lib/pages/tx-details/components/tx-message/TxMsgExpand.tsx b/src/lib/pages/tx-details/components/tx-message/TxMsgExpand.tsx index 4f9566138..2e3216b5d 100644 --- a/src/lib/pages/tx-details/components/tx-message/TxMsgExpand.tsx +++ b/src/lib/pages/tx-details/components/tx-message/TxMsgExpand.tsx @@ -1,5 +1,5 @@ /* eslint-disable complexity */ -import { Flex, Tag } from "@chakra-ui/react"; +import { Flex, Tag, Text } from "@chakra-ui/react"; import type { Coin } from "@cosmjs/stargate"; import { findAttribute } from "@cosmjs/stargate/build/logs"; import type { ReactNode } from "react"; @@ -341,7 +341,7 @@ export const TxMsgExpand = ({ m={0} mt={{ base: 1, md: 0 }} /> - {content} + {content} {!isMobile && isIBC && ( IBC diff --git a/src/lib/styles/theme/components/tag.ts b/src/lib/styles/theme/components/tag.ts index 143ef1d3b..a82eafe2d 100644 --- a/src/lib/styles/theme/components/tag.ts +++ b/src/lib/styles/theme/components/tag.ts @@ -43,7 +43,7 @@ export const Tag = defineMultiStyleConfig({ baseStyle: { container: { px: 2, - py: 0, + py: 1, borderRadius: "full", lineHeight: "100%", textAlign: "center", @@ -52,20 +52,17 @@ export const Tag = defineMultiStyleConfig({ sizes: { xs: { container: { - maxH: "18px", height: "18px", fontSize: "12px", }, }, sm: { container: { - maxH: "20px", fontSize: "12px", }, }, md: { container: { - maxH: "24px", fontSize: "12px", }, }, From 9c1263a9cc1dfe56c7791f8e24958365a8a048b6 Mon Sep 17 00:00:00 2001 From: Jennie Alles Date: Thu, 18 Jan 2024 18:51:58 +0700 Subject: [PATCH 2/8] fix(components): fix nft related bugs --- CHANGELOG.md | 1 + .../components/CollectionSuppliesOverview.tsx | 37 +++++++++---- .../pages/nft-collection-details/index.tsx | 2 +- .../pages/nft-details/components/Title.tsx | 53 ++++++++++++++----- .../components/ViewResourceButton.tsx | 1 + src/lib/pages/nft-details/index.tsx | 48 ++++++++++------- src/lib/query/collection.ts | 5 +- src/lib/query/nft.ts | 15 ++++-- src/lib/services/nft/collection.ts | 4 +- src/lib/services/nft/nft.ts | 4 +- 10 files changed, 120 insertions(+), 50 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 9031e997d..75df71cb7 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -60,6 +60,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Bug fixes +- [#735](https://github.com/alleslabs/celatone-frontend/pull/735) Fix nfts related bugs - [#732](https://github.com/alleslabs/celatone-frontend/pull/732) Fix custom tab incorrect variant and recent modules text - [#722](https://github.com/alleslabs/celatone-frontend/pull/722) Fix flicker query page diff --git a/src/lib/pages/nft-collection-details/components/CollectionSuppliesOverview.tsx b/src/lib/pages/nft-collection-details/components/CollectionSuppliesOverview.tsx index 7d6a2ed00..2b5971241 100644 --- a/src/lib/pages/nft-collection-details/components/CollectionSuppliesOverview.tsx +++ b/src/lib/pages/nft-collection-details/components/CollectionSuppliesOverview.tsx @@ -21,7 +21,7 @@ interface CollectionSuppliesOverviewProps { onViewMore: () => void; } -export const CollectionSuppliesOverview = ({ +export const CollectionSuppliesOverviewBody = ({ totalCount, nfts, isLoading, @@ -41,16 +41,9 @@ export const CollectionSuppliesOverview = ({ return ( ); - return ( - - - - NFTs in this collection - - {totalCount} - - + <> + {nftsInfo.map((nft) => ( @@ -58,6 +51,30 @@ export const CollectionSuppliesOverview = ({ ))} {totalCount > displayedNftCount && } + + ); +}; + +export const CollectionSuppliesOverview = ({ + totalCount, + nfts, + isLoading, + onViewMore, +}: CollectionSuppliesOverviewProps) => { + return ( + + + + NFTs in this collection + + {totalCount} + + ); }; diff --git a/src/lib/pages/nft-collection-details/index.tsx b/src/lib/pages/nft-collection-details/index.tsx index 8f02497dc..2ac301758 100644 --- a/src/lib/pages/nft-collection-details/index.tsx +++ b/src/lib/pages/nft-collection-details/index.tsx @@ -228,8 +228,8 @@ const CollectionDetailsBody = ({ maxSupply={maxSupply} /> diff --git a/src/lib/pages/nft-details/components/Title.tsx b/src/lib/pages/nft-details/components/Title.tsx index 0b6138b7d..470f9d0f3 100644 --- a/src/lib/pages/nft-details/components/Title.tsx +++ b/src/lib/pages/nft-details/components/Title.tsx @@ -1,27 +1,54 @@ -import { Flex, Heading, Text } from "@chakra-ui/react"; +import { Alert, Flex, Heading, Text } from "@chakra-ui/react"; +import { useMobile } from "lib/app-provider"; import { AppLink } from "lib/components/AppLink"; import type { HexAddr32 } from "lib/types"; +import { ViewResourceButton } from "./ViewResourceButton"; + interface TitleProps { collectionAddress: HexAddr32; + nftAddress: HexAddr32; displayCollectionName: string; tokenId: string; + isBurned?: boolean; } export const Title = ({ collectionAddress, displayCollectionName, tokenId, -}: TitleProps) => ( - - - - {displayCollectionName} - - - - {tokenId} - - -); + nftAddress, + isBurned, +}: TitleProps) => { + const isMobile = useMobile(); + return ( + + {isBurned && ( + + + This NFT is already burned + + + )} + + + + + {displayCollectionName} + + + + {tokenId} + + + {!isMobile && } + + + ); +}; diff --git a/src/lib/pages/nft-details/components/ViewResourceButton.tsx b/src/lib/pages/nft-details/components/ViewResourceButton.tsx index ecbab95c7..a052c1e7f 100644 --- a/src/lib/pages/nft-details/components/ViewResourceButton.tsx +++ b/src/lib/pages/nft-details/components/ViewResourceButton.tsx @@ -15,6 +15,7 @@ export const ViewResourceButton = ({ nftAddress }: ViewResourceButtonProps) => {