Skip to content

Commit

Permalink
add profile info
Browse files Browse the repository at this point in the history
  • Loading branch information
Jipperism committed Nov 6, 2023
1 parent 9a4d68e commit 4b1fb68
Show file tree
Hide file tree
Showing 3 changed files with 57 additions and 3 deletions.
2 changes: 1 addition & 1 deletion components/ConnectButton.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ export const ConnectButton = ({ ...buttonProps }: ButtonProps) => {
<div style={{ display: "flex", gap: 12 }}>
<Button
{...buttonProps}
variant={"blackAndWhite"}
variant={"blackAndWhiteOutline"}
onClick={openChainModal}
style={{ display: "flex", alignItems: "center" }}
type="button"
Expand Down
52 changes: 50 additions & 2 deletions components/layout/header.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import {
Flex,
Heading,
HStack,
Image,
Menu,
MenuButton,
MenuItem,
Expand All @@ -17,10 +18,13 @@ import React from "react";
import { BiChevronDown, BiChevronUp } from "react-icons/bi";
import { Pivot as Hamburger } from "hamburger-react";
import Link from "next/link";
import { useAccount, useEnsAvatar, useEnsName } from "wagmi";
import { formatAddress } from "@/utils/formatting";

export const headerHeight = "64px";

export const Header = () => {
const { isConnected } = useAccount();
return (
<Flex
width={"100%"}
Expand All @@ -38,11 +42,21 @@ export const Header = () => {
<BrowseMenu />
</Show>
</HStack>
<HStack ml={"auto"} alignItems={"center"} height={"100%"}>
<Flex ml={"auto"} alignItems={"center"} height={"100%"}>
<Show above={"md"}>
<ConnectButton />
</Show>
<Show below={"md"}>
{isConnected && (
<Flex
px={4}
borderLeft={"1px solid black"}
backgroundColor={"white"}
height={"100%"}
>
<ProfileInfo />
</Flex>
)}
<Flex
alignItems={"center"}
borderLeft={"1px solid black"}
Expand All @@ -51,7 +65,7 @@ export const Header = () => {
<MobileMenuButton />
</Flex>
</Show>
</HStack>
</Flex>
</Flex>
);
};
Expand Down Expand Up @@ -134,6 +148,40 @@ const MobileMenuLink = ({ href, text }: { href: string; text: string }) => {
);
};

const ProfileInfo = () => {
const { address, isConnected } = useAccount();
const { data: avatarData } = useEnsAvatar();
const { data: ensName } = useEnsName();

if (!isConnected) {
return null;
}

return (
<Flex
height={"100%"}
width={"100%"}
alignItems={"center"}
justifyContent={"flex-start"}
>
{avatarData && (
<Image
alt={ensName ?? "Avatar"}
src={avatarData}
width={8}
height={8}
borderRadius={999}
mr={2}
/>
)}
<VStack alignItems={"flex-start"} spacing={0}>
{ensName && <Text fontWeight={500}>{ensName}</Text>}
{address && <Text fontSize={"xs"}>{formatAddress(address)}</Text>}
</VStack>
</Flex>
);
};

const BrowseMenu = () => {
const width = "250px";
return (
Expand Down
6 changes: 6 additions & 0 deletions theme.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,12 @@ const Button = defineStyleConfig({
background: "black",
borderRadius: 16,
},
blackAndWhiteOutline: {
color: "black",
background: "white",
border: "1px solid black",
borderRadius: 16,
},
},
defaultProps: {},
});
Expand Down

0 comments on commit 4b1fb68

Please sign in to comment.