From 3c9dbdb69fadd46689535861352d63b8ddaa3474 Mon Sep 17 00:00:00 2001 From: Jennie Alles Date: Mon, 18 Dec 2023 15:08:55 +0700 Subject: [PATCH 1/6] fix(components): make module link clickable with cmd or ctrl and add copier for resouce and struct --- CHANGELOG.md | 1 + src/lib/components/module/ModuleCard.tsx | 81 +++++++++++-------- .../resource/ResourceDetailCard.tsx | 40 +++++---- .../table/modules/ModulePathLink.tsx | 25 +++--- .../table/modules/ModulesTableRow.tsx | 8 +- .../components/modules/ModuleLists.tsx | 2 +- .../components/modules/ModuleListsBody.tsx | 7 +- .../resources/ResourceSectionBody.tsx | 14 +++- 8 files changed, 112 insertions(+), 66 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 55c37c072..b162061e1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -49,6 +49,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Improvements +- [#675](https://github.com/alleslabs/celatone-frontend/pull/675) Make module links clickable with command/ctrl and add copier for struct names - [#669](https://github.com/alleslabs/celatone-frontend/pull/669) api v1 - contract transaction - [#672](https://github.com/alleslabs/celatone-frontend/pull/672) refactor balances - [#662](https://github.com/alleslabs/celatone-frontend/pull/662) Add republish button in module detail diff --git a/src/lib/components/module/ModuleCard.tsx b/src/lib/components/module/ModuleCard.tsx index 729502719..bf3ab9cbc 100644 --- a/src/lib/components/module/ModuleCard.tsx +++ b/src/lib/components/module/ModuleCard.tsx @@ -1,6 +1,8 @@ import { Flex, Grid, Text } from "@chakra-ui/react"; +import { AppLink } from "../AppLink"; import { CustomIcon } from "../icon"; +import { useFormatAddresses } from "lib/hooks/useFormatAddresses"; import type { IndexedModule } from "lib/services/move/moduleService"; import { useVerifyModule } from "lib/services/move/moduleService"; import type { MoveAccountAddr, Option } from "lib/types"; @@ -24,43 +26,54 @@ export const ModuleCard = ({ address: selectedAddress, moduleName: module.moduleName, }); - + const formatAddresses = useFormatAddresses(); return ( - setSelectedModule(module)} - gap={1} - templateColumns="20px 1fr auto" - _hover={{ - bg: "gray.700", - }} - transition=".25s all ease-out" > - - - - {module.moduleName} - - {isVerified && ( - e.stopPropagation()} + gap={1} + templateColumns="20px 1fr auto" + _hover={{ + bg: "gray.700", + }} + transition=".25s all ease-out" + > + + + + {module.moduleName} + + {isVerified && ( + + )} + + + + - )} - - - - - - + + + ); }; diff --git a/src/lib/components/resource/ResourceDetailCard.tsx b/src/lib/components/resource/ResourceDetailCard.tsx index ea6d3bb30..f4441aea3 100644 --- a/src/lib/components/resource/ResourceDetailCard.tsx +++ b/src/lib/components/resource/ResourceDetailCard.tsx @@ -7,7 +7,7 @@ import { Text, } from "@chakra-ui/react"; -import { CopyButton } from "../copy"; +import { Copier, CopyButton } from "../copy"; import { CustomIcon } from "../icon"; import type { InternalResource } from "lib/types"; import { parseJsonStr } from "lib/utils"; @@ -54,22 +54,30 @@ export const ResourceDetailCard = ({ return ( - - + div": { opacity: 0, transition: "all 0.15s ease-in-out" }, + }} + _hover={{ "& > div": { opacity: 1 } }} > - {resourceData.structTag} - - + + {resourceData.structTag} + + + + - e.stopPropagation()} > - {`${truncate(hexAddr)} :: ${moduleName}`} - + + {`${truncate(hexAddr)} :: ${moduleName}`} + + + onClick={(e) => { + e.stopPropagation(); navigate({ pathname: "/modules/[address]/[moduleName]", query: { address: hex, moduleName: moduleInfo.name, }, - }) - } + }); + }} > diff --git a/src/lib/pages/account-details/components/modules/ModuleLists.tsx b/src/lib/pages/account-details/components/modules/ModuleLists.tsx index 6eb68efdf..26bfc0fbe 100644 --- a/src/lib/pages/account-details/components/modules/ModuleLists.tsx +++ b/src/lib/pages/account-details/components/modules/ModuleLists.tsx @@ -28,7 +28,7 @@ export const ModuleLists = ({ const isMobile = useMobile(); const isMobileOverview = isMobile && !!onViewMore; return ( - + {isMobileOverview ? ( ); return ( diff --git a/src/lib/pages/account-details/components/resources/ResourceSectionBody.tsx b/src/lib/pages/account-details/components/resources/ResourceSectionBody.tsx index aa1e01ce1..0639f0f20 100644 --- a/src/lib/pages/account-details/components/resources/ResourceSectionBody.tsx +++ b/src/lib/pages/account-details/components/resources/ResourceSectionBody.tsx @@ -2,6 +2,7 @@ import { Accordion, Badge, Box, Button, Flex, Heading } from "@chakra-ui/react"; import { useRouter } from "next/router"; import { useEffect, useState } from "react"; +import { Copier } from "lib/components/copy"; import { CustomIcon } from "lib/components/icon"; import { Loading } from "lib/components/Loading"; import { ResourceDetailCard } from "lib/components/resource"; @@ -63,13 +64,24 @@ export const ResourceSectionBody = ({ pb={6} gap={12} > - + div": { opacity: 0, transition: "all 0.15s ease-in-out" }, + }} + _hover={{ "& > div": { opacity: 1 } }} + > {selectedResource.account}::{selectedResource.group} {selectedResource.items.length} +