From 7deb02391a969957c443b0e69a09e08f22a49e64 Mon Sep 17 00:00:00 2001 From: ysandler Date: Thu, 1 May 2025 14:00:07 -0500 Subject: [PATCH] feat: created back button, added to breadcrumb --- src/components/NavigateBackButton.tsx | 20 ++++++ src/components/PageBreadCrumb.tsx | 94 ++++++++++++++------------- 2 files changed, 70 insertions(+), 44 deletions(-) create mode 100644 src/components/NavigateBackButton.tsx diff --git a/src/components/NavigateBackButton.tsx b/src/components/NavigateBackButton.tsx new file mode 100644 index 0000000..6026cba --- /dev/null +++ b/src/components/NavigateBackButton.tsx @@ -0,0 +1,20 @@ +'use client' + +import { ArrowUturnLeftIcon } from '@heroicons/react/20/solid' +import { Button } from './ui/button' + +const NaviagteBackButton = () => { + const handleClick = () => { + window.history.back() + } + return ( + + ) +} + +export default NaviagteBackButton diff --git a/src/components/PageBreadCrumb.tsx b/src/components/PageBreadCrumb.tsx index 0fe42a1..89d09ec 100644 --- a/src/components/PageBreadCrumb.tsx +++ b/src/components/PageBreadCrumb.tsx @@ -15,6 +15,7 @@ import { DropdownMenuTrigger, } from './ui/dropdown-menu' import { Fragment } from 'react' +import NaviagteBackButton from './NavigateBackButton' export type Route = { href: string @@ -49,50 +50,55 @@ export function PageBreadCrumb(props: Props) { const { routes } = props const groups = groupBreadCrumbHistory(routes) return ( - - - - {groups.root.label} - - - {!!groups.inBetween.length && ( - <> - - - - - Toggle menu - - - {groups.inBetween.map((r) => ( - - {r.label} - - ))} - - - - - - )} - {groups.mostRecent.map((r, index) => { - if (index != groups.mostRecent.length - 1) - return ( - - - {r.label} - - - - ) - else - return ( - - {r.label} +
+ + + + + + + {groups.root.label} + + + {!!groups.inBetween.length && ( + <> + + + + + Toggle menu + + + {groups.inBetween.map((r) => ( + + {r.label} + + ))} + + - ) - })} - - + + + )} + {groups.mostRecent.map((r, index) => { + if (index != groups.mostRecent.length - 1) + return ( + + + {r.label} + + + + ) + else + return ( + + {r.label} + + ) + })} + + +
) }