-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* feat: add navbar * feat: breadcumbs
- Loading branch information
Showing
6 changed files
with
104 additions
and
23 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
import { Breadcrumb, type SystemStyleObject } from "@chakra-ui/react"; | ||
import * as React from "react"; | ||
|
||
export interface BreadcrumbRootProps extends Breadcrumb.RootProps { | ||
separator?: React.ReactNode; | ||
separatorGap?: SystemStyleObject["gap"]; | ||
} | ||
|
||
export const BreadcrumbRoot = React.forwardRef< | ||
HTMLDivElement, | ||
BreadcrumbRootProps | ||
>(function BreadcrumbRoot(props, ref) { | ||
const { separator, separatorGap, children, ...rest } = props; | ||
|
||
const validChildren = React.Children.toArray(children).filter( | ||
React.isValidElement | ||
); | ||
|
||
return ( | ||
<Breadcrumb.Root ref={ref} {...rest}> | ||
<Breadcrumb.List gap={separatorGap}> | ||
{validChildren.map((child, index) => { | ||
const last = index === validChildren.length - 1; | ||
return ( | ||
<React.Fragment key={index}> | ||
<Breadcrumb.Item>{child}</Breadcrumb.Item> | ||
{!last && ( | ||
<Breadcrumb.Separator>{separator}</Breadcrumb.Separator> | ||
)} | ||
</React.Fragment> | ||
); | ||
})} | ||
</Breadcrumb.List> | ||
</Breadcrumb.Root> | ||
); | ||
}); | ||
|
||
export const BreadcrumbLink = Breadcrumb.Link; | ||
export const BreadcrumbCurrentLink = Breadcrumb.CurrentLink; | ||
export const BreadcrumbEllipsis = Breadcrumb.Ellipsis; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
"use client"; | ||
|
||
import { Box, ClientOnly, Flex, Skeleton, Stack } from "@chakra-ui/react"; | ||
import { | ||
BreadcrumbCurrentLink, | ||
BreadcrumbLink, | ||
BreadcrumbRoot, | ||
} from "@components/breadcrumb"; | ||
import { usePathname } from "next/navigation"; | ||
import { ColorModeToggle } from "./components/color-mode-toggle"; | ||
|
||
function getBreadcrumbs() { | ||
const parts = usePathname().split("/"); | ||
if (parts.length == 2 && !parts[0] && !parts[1]) { | ||
return <BreadcrumbCurrentLink>heystac</BreadcrumbCurrentLink>; | ||
} else if (parts.length == 3 && parts[1] == "catalogs") { | ||
return [ | ||
<BreadcrumbLink href="/" key={0}> | ||
heystac | ||
</BreadcrumbLink>, | ||
<BreadcrumbCurrentLink key={1}>{parts[2]}</BreadcrumbCurrentLink>, | ||
]; | ||
} else { | ||
return <BreadcrumbLink href="/">heystac</BreadcrumbLink>; | ||
} | ||
} | ||
|
||
export default function Navbar() { | ||
const breadcrumbs = getBreadcrumbs(); | ||
return ( | ||
<Box> | ||
<Flex | ||
minH={"60px"} | ||
bg={{ base: "white", _dark: "gray.800" }} | ||
color={{ base: "gray.600", _dark: "white" }} | ||
py={{ base: 2 }} | ||
px={{ base: 4 }} | ||
borderBottom={1} | ||
borderStyle={"solid"} | ||
borderColor={{ base: "gray.200", _dark: "gray.900" }} | ||
align={"center"} | ||
> | ||
<Flex flex={1} justify={"start"}> | ||
<BreadcrumbRoot separator="/">{breadcrumbs}</BreadcrumbRoot> | ||
</Flex> | ||
<Stack> | ||
<ClientOnly fallback={<Skeleton w="10" h="10" rounded="md" />}> | ||
<ColorModeToggle /> | ||
</ClientOnly> | ||
</Stack> | ||
</Flex> | ||
</Box> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters