diff --git a/dapp/src/components/Header/Navigation/Navigation.tsx b/dapp/src/components/Header/Navigation/Navigation.tsx index bcfe4357f..bdc668687 100644 --- a/dapp/src/components/Header/Navigation/Navigation.tsx +++ b/dapp/src/components/Header/Navigation/Navigation.tsx @@ -1,20 +1,29 @@ import React from "react" import { Box, BoxProps, HStack, List } from "@chakra-ui/react" -import { NavigationItemType } from "#/types/navigation" -import NavigationItem from "./NavigationItem" +import { EXTERNAL_HREF } from "#/constants" +import { routerPath } from "#/router/path" +import { isString } from "#/utils" +import NavigationItem, { NavigationItemProps } from "./NavigationItem" -type NavigationProps = BoxProps & { - items: NavigationItemType[] -} - -function Navigation(props: NavigationProps) { - const { items, ...restProps } = props +const NAVIGATION_ITEMS: NavigationItemProps[] = [ + { children: "Home", to: EXTERNAL_HREF.WEBSITE, isExternal: true }, + { children: "Stake", to: routerPath.home }, + { children: "Docs", to: EXTERNAL_HREF.DOCS, isExternal: true }, + { children: "FAQ", to: EXTERNAL_HREF.FAQ, isExternal: true }, + { children: "Blog", to: EXTERNAL_HREF.BLOG, isExternal: true }, + { children: "Discord", to: EXTERNAL_HREF.DISCORD, isExternal: true }, + { children: "X", to: EXTERNAL_HREF.X, isExternal: true }, +] +function Navigation(props: BoxProps) { return ( - + - {items.map((item) => ( - + {NAVIGATION_ITEMS.map((item) => ( + ))} diff --git a/dapp/src/components/Header/Navigation/NavigationItem.tsx b/dapp/src/components/Header/Navigation/NavigationItem.tsx index a010e401e..3366abe11 100644 --- a/dapp/src/components/Header/Navigation/NavigationItem.tsx +++ b/dapp/src/components/Header/Navigation/NavigationItem.tsx @@ -1,49 +1,41 @@ import React from "react" -import { - Box, - ListItem, - ListItemProps, - useMultiStyleConfig, -} from "@chakra-ui/react" -import { motion } from "framer-motion" -import { NavigationItemType } from "#/types/navigation" +import { ListItem, useMultiStyleConfig } from "@chakra-ui/react" import { To, useSearchParams } from "react-router-dom" import { useModal } from "#/hooks" -import { NavLink } from "../../shared/NavLink" +import { isString } from "#/utils" +import { NavLink, NavLinkProps } from "../../shared/NavLink" -type NavigationItemProps = ListItemProps & NavigationItemType +export type NavigationItemProps = NavLinkProps function NavigationItem(props: NavigationItemProps) { - const { label, href, ...restProps } = props - const styles = useMultiStyleConfig("Link", { variant: "navigation" }) + const { children, to: defaultTo, isExternal, ...restProps } = props + const styles = useMultiStyleConfig("Link", { + variant: "navigation", + size: "md", + }) const [searchParams] = useSearchParams() const { isOpenGlobalErrorModal } = useModal() const isDisabled = isOpenGlobalErrorModal - const to: To = { - pathname: href, - search: searchParams.toString(), - } + const to: To = isExternal + ? defaultTo + : { + pathname: isString(defaultTo) ? defaultTo : defaultTo.pathname, + search: searchParams.toString(), + } return ( - + - {({ isActive }) => ( - <> - {label} - {isActive && ( - - )} - - )} + {children} ) diff --git a/dapp/src/components/Header/index.tsx b/dapp/src/components/Header/index.tsx index e29f4f0a2..5c56be348 100644 --- a/dapp/src/components/Header/index.tsx +++ b/dapp/src/components/Header/index.tsx @@ -1,17 +1,11 @@ import React from "react" import { AcreLogo } from "#/assets/icons" -import { routerPath } from "#/router/path" import { Flex, HStack, Icon, Link } from "@chakra-ui/react" -import { NavigationItemType } from "#/types" import { EXTERNAL_HREF } from "#/constants" import { useMobileMode } from "#/hooks" import ConnectWallet from "./ConnectWallet" import { Navigation } from "./Navigation" -const NAVIGATION_ITEMS: NavigationItemType[] = [ - { label: "Dashboard", href: routerPath.home }, -] - export default function Header() { const isMobileMode = useMobileMode() @@ -23,7 +17,7 @@ export default function Header() { {!isMobileMode && ( <> - + diff --git a/dapp/src/components/shared/NavLink.tsx b/dapp/src/components/shared/NavLink.tsx index 1826af89a..305bbfe53 100644 --- a/dapp/src/components/shared/NavLink.tsx +++ b/dapp/src/components/shared/NavLink.tsx @@ -8,7 +8,7 @@ import { NavLinkProps as RouterNavLinkProps, } from "react-router-dom" -type NavLinkProps = Omit & +export type NavLinkProps = Omit & Pick export function NavLink(props: NavLinkProps) { diff --git a/dapp/src/theme/Link.ts b/dapp/src/theme/Link.ts index 7c283559e..f8b064299 100644 --- a/dapp/src/theme/Link.ts +++ b/dapp/src/theme/Link.ts @@ -5,8 +5,6 @@ const multiStyleConfig = createMultiStyleConfigHelpers(PARTS) const containerBaseStyle = defineStyle({ fontWeight: "semibold", - fontSize: "sm", - lineHeight: "sm", _hover: { textDecoration: "none", @@ -14,32 +12,39 @@ const containerBaseStyle = defineStyle({ }) const navigationContainerStyles = defineStyle({ - display: "block", - fontSize: "md", - lineHeight: "md", - fontWeight: "bold", - marginBottom: 2, - color: "grey.500", - _activeLink: { color: "grey.700" }, + fontWeight: "medium", + color: "grey.700", + _activeLink: { color: "brand.400" }, }) -const navigationIndicatorStyles = defineStyle({ - pos: "absolute", - bottom: 0.5, - left: 0, - w: "full", - h: 0.5, - bg: "brand.400", +const sizeSm = multiStyleConfig.definePartsStyle({ + container: { + fontSize: "sm", + lineHeight: "sm", + }, }) +const sizeMd = multiStyleConfig.definePartsStyle({ + container: { + fontSize: "md", + lineHeight: "md", + }, +}) + +const sizes = { + sm: sizeSm, + md: sizeMd, +} + export const linkTheme = multiStyleConfig.defineMultiStyleConfig({ baseStyle: { container: containerBaseStyle, + size: "sm", }, variants: { navigation: { container: navigationContainerStyles, - indicator: navigationIndicatorStyles, }, }, + sizes, }) diff --git a/dapp/src/types/index.ts b/dapp/src/types/index.ts index ec4b743ac..5411acd06 100644 --- a/dapp/src/types/index.ts +++ b/dapp/src/types/index.ts @@ -9,7 +9,6 @@ export * from "./time" export * from "./core" export * from "./fee" export * from "./modal" -export * from "./navigation" export * from "./form" export * from "./eip1193" export * from "./error" diff --git a/dapp/src/types/navigation.ts b/dapp/src/types/navigation.ts deleted file mode 100644 index 058b095d0..000000000 --- a/dapp/src/types/navigation.ts +++ /dev/null @@ -1,4 +0,0 @@ -export type NavigationItemType = { - label: string - href: string -}