diff --git a/CHANGELOG.md b/CHANGELOG.md index 765c2fce5..6292ee069 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -57,6 +57,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Improvements +- [#323](https://github.com/alleslabs/celatone-frontend/pull/323) Revise back button and breadcrumb components - [#339](https://github.com/alleslabs/celatone-frontend/pull/339) Update all routes to plural form, and patch all codes - [#334](https://github.com/alleslabs/celatone-frontend/pull/334) Change `osmo-test-4` to `osmo-test-5`, fix tx service when accountId is undefined - [#311](https://github.com/alleslabs/celatone-frontend/pull/311) Refine css styling diff --git a/src/lib/components/Breadcrumb.tsx b/src/lib/components/Breadcrumb.tsx new file mode 100644 index 000000000..40b5115b7 --- /dev/null +++ b/src/lib/components/Breadcrumb.tsx @@ -0,0 +1,56 @@ +import { + Breadcrumb as ChakraBreadcrumb, + BreadcrumbItem as ChakraBreadcrumbItem, + Text, +} from "@chakra-ui/react"; + +import type { Option } from "lib/types"; + +import { AppLink } from "./AppLink"; +import { CustomIcon } from "./icon"; + +type BreadcrumbItemProps = { + text: Option; + href?: string; +}; + +type BreadcrumbProps = { + items: BreadcrumbItemProps[]; + mb?: number; +}; + +export const Breadcrumb = ({ items, mb = 0 }: BreadcrumbProps) => ( + } + > + {items.map((item) => + item.href ? ( + item.text && ( + + + {item.text} + + + ) + ) : ( + + + {item.text} + + + ) + )} + +); diff --git a/src/lib/pages/account-details/index.tsx b/src/lib/pages/account-details/index.tsx index edc318364..1cc2c2a31 100644 --- a/src/lib/pages/account-details/index.tsx +++ b/src/lib/pages/account-details/index.tsx @@ -12,7 +12,7 @@ import { useRouter } from "next/router"; import { useEffect, useState } from "react"; import { useValidateAddress } from "lib/app-provider"; -import { BackButton } from "lib/components/button"; +import { Breadcrumb } from "lib/components/Breadcrumb"; import { CopyLink } from "lib/components/CopyLink"; import { CustomTab } from "lib/components/CustomTab"; import { CustomIcon } from "lib/components/icon"; @@ -27,7 +27,12 @@ import { usePublicProjectBySlug, } from "lib/services/publicProjectService"; import type { HumanAddr } from "lib/types"; -import { formatPrice, getFirstQueryParam, scrollToTop } from "lib/utils"; +import { + formatPrice, + getFirstQueryParam, + scrollToTop, + truncate, +} from "lib/utils"; import { AssetsSection } from "./components/asset"; import { DelegationsSection } from "./components/delegations"; @@ -86,30 +91,46 @@ const AccountDetailsBody = ({ accountAddress }: AccountDetailsBodyProps) => { return ( <> - - - {publicDetail?.logo && ( - {publicDetail.name} - )} - - {displayName} - - - - - Wallet Address: - - + {publicDetail && ( + + )} + + + + {publicDetail?.logo && ( + {publicDetail.name} + )} + + {displayName} + + + + + Wallet Address: + + + {publicInfo?.description && ( @@ -331,7 +352,6 @@ const AccountDetails = () => { return ( - {validateUserAddress(accountAddressParam) && validateContractAddress(accountAddressParam) ? ( diff --git a/src/lib/pages/block-details/components/BlockDetailsTop.tsx b/src/lib/pages/block-details/components/BlockDetailsTop.tsx index 73642d3a9..8c05813a8 100644 --- a/src/lib/pages/block-details/components/BlockDetailsTop.tsx +++ b/src/lib/pages/block-details/components/BlockDetailsTop.tsx @@ -38,67 +38,72 @@ export const BlockDetailsTop = ({ blockData }: BlockDetailsTopProps) => { const disablePrevious = block <= 1; return ( - - - - - {blockData.height} - - - - - Block Hash: - - + + + + + + {blockData.height} + + + + {!disablePrevious && ( + + } + variant="ghost-gray" + /> + + )} + + } + variant="ghost-gray" + /> + + + - - - + + - {dateFromNow(blockData.timestamp)} + Block Hash: + + + + + + + + {dateFromNow(blockData.timestamp)} + + + + + {formatUTC(blockData.timestamp)} - - - {formatUTC(blockData.timestamp)} - - - {!disablePrevious && ( - - } - variant="ghost-gray" - /> - - )} - - } - variant="ghost-gray" - /> - - - ); }; diff --git a/src/lib/pages/block-details/index.tsx b/src/lib/pages/block-details/index.tsx index 5b88037fd..4400562e1 100644 --- a/src/lib/pages/block-details/index.tsx +++ b/src/lib/pages/block-details/index.tsx @@ -1,7 +1,7 @@ import { useRouter } from "next/router"; import { useEffect } from "react"; -import { BackButton } from "lib/components/button"; +import { Breadcrumb } from "lib/components/Breadcrumb"; import { Loading } from "lib/components/Loading"; import PageContainer from "lib/components/PageContainer"; import { EmptyState } from "lib/components/state"; @@ -26,7 +26,12 @@ const BlockDetail = () => { return ( - + {blockData ? ( <> diff --git a/src/lib/pages/blocks/components/BlocksRow.tsx b/src/lib/pages/blocks/components/BlocksRow.tsx index 704703fe0..42cee0dac 100644 --- a/src/lib/pages/blocks/components/BlocksRow.tsx +++ b/src/lib/pages/blocks/components/BlocksRow.tsx @@ -26,7 +26,7 @@ export const BlocksRow = ({ templateColumns, blockData }: BlocksRowProps) => { {truncate(blockData.hash.toUpperCase())} - + - - + + + + {publicProject.publicDetail?.logo && ( + + + {publicProject.publicCodeData?.name && ( @@ -93,18 +123,6 @@ const CodeDetailsBody = observer( )} - {publicProject.publicCodeData?.description && ( { if (data.isLoading) return ; return ( - {!isCodeId(codeIdParam) ? ( ) : ( diff --git a/src/lib/pages/contract-details/components/ContractTop.tsx b/src/lib/pages/contract-details/components/ContractTop.tsx index dede8dc9a..b4ab963d7 100644 --- a/src/lib/pages/contract-details/components/ContractTop.tsx +++ b/src/lib/pages/contract-details/components/ContractTop.tsx @@ -9,6 +9,7 @@ import { import router from "next/router"; import { useInternalNavigate } from "lib/app-provider"; +import { Breadcrumb } from "lib/components/Breadcrumb"; import { AdminButton } from "lib/components/button"; import { CopyLink } from "lib/components/CopyLink"; import { CustomIcon } from "lib/components/icon"; @@ -19,7 +20,7 @@ import { SaveContractDetailsModal, } from "lib/components/modal"; import type { ContractAddr, ContractData } from "lib/types"; -import { getFirstQueryParam } from "lib/utils"; +import { getFirstQueryParam, truncate } from "lib/utils"; interface ContractTopProps { contractData: ContractData; @@ -94,94 +95,118 @@ export const ContractTop = ({ contractData }: ContractTopProps) => { }; return ( - - - - {publicProject.publicDetail?.logo && ( - {publicProject.publicDetail.name} - )} - - {displayName} - - - - - Contract Address: - - + + {publicProject.publicDetail && ( + - - - - Label: - - - {contractData.instantiateInfo?.label} - - - {publicProject.publicInfo?.name && ( - - - Public Contract Name: - - - {publicProject.publicInfo?.name} - - - )} - {publicProject.publicInfo?.github && ( - )} - - - - - - - {contractLocalInfo && ( - } + + + + + {publicProject.publicDetail?.logo && ( + {publicProject.publicDetail.name} - } - /> - )} - {renderSaveButton()} + )} + + {displayName} + + + + + + + + {contractLocalInfo && ( + } + /> + } + /> + )} + {renderSaveButton()} + + + + + + + Contract Address: + + + + + + Label: + + + {contractData.instantiateInfo?.label} + + + {publicProject.publicInfo?.name && ( + + + Public Contract Name: + + + {publicProject.publicInfo?.name} + + + )} + {publicProject.publicInfo?.github && ( + + )} + diff --git a/src/lib/pages/contract-details/index.tsx b/src/lib/pages/contract-details/index.tsx index 339ff3e00..e0254cb7c 100644 --- a/src/lib/pages/contract-details/index.tsx +++ b/src/lib/pages/contract-details/index.tsx @@ -11,7 +11,6 @@ import { useRouter } from "next/router"; import { useEffect } from "react"; import { useValidateAddress } from "lib/app-provider"; -import { BackButton } from "lib/components/button"; import { CustomTab } from "lib/components/CustomTab"; import { Loading } from "lib/components/Loading"; import PageContainer from "lib/components/PageContainer"; @@ -149,7 +148,6 @@ const ContractDetails = observer(() => { if (isLoading) return ; return ( - {validateContractAddress(contractAddressParam) ? ( ) : ( diff --git a/src/lib/pages/contract-list/slug.tsx b/src/lib/pages/contract-list/slug.tsx index 553a00dfd..73c7773ee 100644 --- a/src/lib/pages/contract-list/slug.tsx +++ b/src/lib/pages/contract-list/slug.tsx @@ -5,16 +5,13 @@ import { Menu, MenuButton, MenuList, - Breadcrumb, - BreadcrumbItem, - Text, } from "@chakra-ui/react"; import { observer } from "mobx-react-lite"; import { useRouter } from "next/router"; import { useEffect } from "react"; import { useInternalNavigate } from "lib/app-provider"; -import { AppLink } from "lib/components/AppLink"; +import { Breadcrumb } from "lib/components/Breadcrumb"; import { CustomIcon } from "lib/components/icon"; import { EditListNameModal, @@ -81,32 +78,11 @@ const ContractsByList = observer(() => { return ( - } - > - - - Contract Lists - - - - - {contractListInfo.name} - - - + items={[ + { text: "Contract Lists", href: "/contract-list" }, + { text: contractListInfo.name }, + ]} + /> { return ( {isFetching && } - Execute Contract diff --git a/src/lib/pages/faucet/index.tsx b/src/lib/pages/faucet/index.tsx index 3c0491bc3..898b9c23f 100644 --- a/src/lib/pages/faucet/index.tsx +++ b/src/lib/pages/faucet/index.tsx @@ -17,7 +17,6 @@ import { useInternalNavigate, useValidateAddress, } from "lib/app-provider"; -import { BackButton } from "lib/components/button"; import type { FormStatus } from "lib/components/forms"; import { TextInput } from "lib/components/forms"; import { CustomIcon } from "lib/components/icon"; @@ -144,7 +143,6 @@ const Faucet = () => { return ( - Osmosis Testnet Faucet diff --git a/src/lib/pages/public-project/components/DetailHeader.tsx b/src/lib/pages/public-project/components/DetailHeader.tsx index 09ef4f01b..6321074af 100644 --- a/src/lib/pages/public-project/components/DetailHeader.tsx +++ b/src/lib/pages/public-project/components/DetailHeader.tsx @@ -1,15 +1,6 @@ -import { - Box, - Breadcrumb, - BreadcrumbItem, - Text, - Flex, - Heading, - Image, -} from "@chakra-ui/react"; +import { Box, Text, Flex, Heading, Image } from "@chakra-ui/react"; -import { AppLink } from "lib/components/AppLink"; -import { CustomIcon } from "lib/components/icon"; +import { Breadcrumb } from "lib/components/Breadcrumb"; import type { Option, PublicDetail } from "lib/types"; import { getNameAndDescriptionDefault } from "lib/utils"; @@ -23,48 +14,27 @@ interface DetailHeaderProps { export const DetailHeader = ({ details, slug }: DetailHeaderProps) => ( <> - } - > - - - Public Projects - - - - - {details?.name} - - - + items={[ + { text: "Public Projects", href: "/projects" }, + { text: details?.name }, + ]} + /> - + {details?.logo && ( Celatone )} diff --git a/src/lib/pages/query/index.tsx b/src/lib/pages/query/index.tsx index ff880a2de..898c4b5f9 100644 --- a/src/lib/pages/query/index.tsx +++ b/src/lib/pages/query/index.tsx @@ -5,7 +5,6 @@ import { useRouter } from "next/router"; import { useCallback, useEffect, useState } from "react"; import { useInternalNavigate, useLCDEndpoint } from "lib/app-provider"; -import { BackButton } from "lib/components/button"; import { ContractSelectSection } from "lib/components/ContractSelectSection"; import { CustomIcon } from "lib/components/icon"; import { LoadingOverlay } from "lib/components/LoadingOverlay"; @@ -93,7 +92,6 @@ const Query = () => { return ( {isFetching && } - Query Contract diff --git a/src/lib/pages/tx-details/components/TxHeader.tsx b/src/lib/pages/tx-details/components/TxHeader.tsx index 1b996d520..d86061073 100644 --- a/src/lib/pages/tx-details/components/TxHeader.tsx +++ b/src/lib/pages/tx-details/components/TxHeader.tsx @@ -26,7 +26,8 @@ export const TxHeader = ({ txData, ...flexProps }: TxHeaderProps) => { - - - Transaction Hash: - - - - - - {txData.isTxFailed ? ( + + + + Transaction Hash: + + + + + + {txData.isTxFailed ? ( + <> + +

Failed

+ + ) : ( + <> + +

Success

+ + )} +
+ + {txData.timestamp ? ( <> - -

Failed

+

{dateFromNow(txData.timestamp)}

+ +

{formatUTC(txData.timestamp)}

) : ( - <> - -

Success

- +

N/A

)}
- - {txData.timestamp ? ( - <> -

{dateFromNow(txData.timestamp)}

- -

{formatUTC(txData.timestamp)}

- - ) : ( -

N/A

- )}
); diff --git a/src/lib/pages/tx-details/index.tsx b/src/lib/pages/tx-details/index.tsx index 9d94697db..29e886633 100644 --- a/src/lib/pages/tx-details/index.tsx +++ b/src/lib/pages/tx-details/index.tsx @@ -2,14 +2,14 @@ import { Flex } from "@chakra-ui/react"; import { useRouter } from "next/router"; import { useEffect } from "react"; -import { BackButton } from "lib/components/button"; +import { Breadcrumb } from "lib/components/Breadcrumb"; import { Loading } from "lib/components/Loading"; import PageContainer from "lib/components/PageContainer"; import { EmptyState } from "lib/components/state/EmptyState"; import { AmpEvent, AmpTrack } from "lib/services/amplitude"; import { useAssetInfos } from "lib/services/assetService"; import { useTxData } from "lib/services/txService"; -import { getFirstQueryParam } from "lib/utils"; +import { getFirstQueryParam, truncate } from "lib/utils"; import { TxHeader, TxInfo } from "./components"; import { MessageSection } from "./components/MessageSection"; @@ -44,10 +44,15 @@ const TxDetails = () => { return ( - + {txData ? ( <> - +