Skip to content

Commit

Permalink
Merge pull request #103 from alleslabs/style/add-network-checked
Browse files Browse the repository at this point in the history
style: add checkmark to selected network
  • Loading branch information
poomthiti committed Jan 19, 2023
2 parents 9ca9b86 + 73f9240 commit 147e5a0
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 20 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

### Features

- [#103](https://github.com/alleslabs/celatone-frontend/pull/103) Add check mark to selected network
- [#92](https://github.com/alleslabs/celatone-frontend/pull/92) Create select contract component for admin and migrate pages
- [#101](https://github.com/alleslabs/celatone-frontend/pull/101) Fix incorrect truncating of proposal id in contract detail's migration table
- [#100](https://github.com/alleslabs/celatone-frontend/pull/100) Fix contract instantiated time parsing
Expand Down
2 changes: 1 addition & 1 deletion src/lib/data/wallet.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
export const MAINNET_CHAIN_NAMES = [];
export const MAINNET_CHAIN_NAMES = ["osmosis"];

export const TESTNET_CHAIN_NAMES = ["osmosistestnet"];

Expand Down
55 changes: 36 additions & 19 deletions src/lib/layout/Header.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import { useWallet } from "@cosmos-kit/react";
import { useRouter } from "next/router";
import { useCallback } from "react";
import { FiChevronDown } from "react-icons/fi";
import { MdCheck } from "react-icons/md";

import { useInternalNavigate } from "lib/app-provider";
import { WalletSection } from "lib/components/Wallet";
Expand All @@ -22,10 +23,16 @@ import Searchbar from "./Searchbar";
const Header = () => {
const router = useRouter();
const navigate = useInternalNavigate();
const { currentChainRecord, setCurrentChain, getChainRecord } = useWallet();
const {
currentChainRecord,
currentChainName,
setCurrentChain,
getChainRecord,
} = useWallet();

const handleChainSelect = useCallback(
(chainName: string) => {
if (chainName === currentChainName) return;
setCurrentChain(chainName);
navigate({
pathname: router.asPath.replace(`/${router.query.network}`, ""),
Expand All @@ -37,7 +44,7 @@ const Header = () => {
},
});
},
[setCurrentChain, navigate, router]
[currentChainName, setCurrentChain, navigate, router]
);

return (
Expand Down Expand Up @@ -89,23 +96,33 @@ const Header = () => {
</Flex>
</MenuButton>
<MenuList>
{CHAIN_NAMES.map((chainName) => {
return (
<MenuItem
key={chainName}
onClick={() => {
handleChainSelect(chainName);
}}
flexDirection="column"
alignItems="flex-start"
>
<Text>{getChainRecord(chainName)?.chain.pretty_name}</Text>
<Text color="text.dark" fontSize="sm">
{getChainRecord(chainName)?.chain.chain_id}
</Text>
</MenuItem>
);
})}
{CHAIN_NAMES.map((chainName) => (
<MenuItem
key={chainName}
onClick={() => {
handleChainSelect(chainName);
}}
flexDirection="column"
alignItems="flex-start"
_hover={{
backgroundColor: "hover.dark",
}}
>
<Flex justify="space-between" align="center" w="full">
<Flex direction="column">
<Text variant="body2">
{getChainRecord(chainName)?.chain.pretty_name}
</Text>
<Text color="text.dark" variant="body3">
{getChainRecord(chainName)?.chain.chain_id}
</Text>
</Flex>
{chainName === currentChainName && (
<Icon as={MdCheck} boxSize={4} color="gray.600" />
)}
</Flex>
</MenuItem>
))}
</MenuList>
</Menu>
<WalletSection />
Expand Down

1 comment on commit 147e5a0

@vercel
Copy link

@vercel vercel bot commented on 147e5a0 Jan 19, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.