-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Breadcrumbs powered by
useMatches()
(#2531)
* first pass at matches-based breadcrumbs. route config changes required * kinda fix things in the route config * use-title.ts -> use-crumbs.ts * Update import --------- Co-authored-by: Charlie Park <[email protected]>
- Loading branch information
1 parent
f8e094f
commit ee3a658
Showing
13 changed files
with
289 additions
and
411 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,47 @@ | ||
/* | ||
* This Source Code Form is subject to the terms of the Mozilla Public | ||
* License, v. 2.0. If a copy of the MPL was not distributed with this | ||
* file, you can obtain one at https://mozilla.org/MPL/2.0/. | ||
* | ||
* Copyright Oxide Computer Company | ||
*/ | ||
import cn from 'classnames' | ||
import { Link } from 'react-router-dom' | ||
|
||
import { PrevArrow12Icon } from '@oxide/design-system/icons/react' | ||
|
||
import { useCrumbs } from '~/hooks/use-crumbs' | ||
import { Slash } from '~/ui/lib/Slash' | ||
import { intersperse } from '~/util/array' | ||
|
||
export function Breadcrumbs() { | ||
const crumbs = useCrumbs() | ||
const isTopLevel = crumbs.length <= 1 | ||
return ( | ||
<nav | ||
className="flex items-center gap-0.5 overflow-clip pr-4 text-sans-md" | ||
aria-label="Breadcrumbs" | ||
> | ||
<PrevArrow12Icon | ||
className={cn('mx-1.5 flex-shrink-0 text-quinary', isTopLevel && 'opacity-40')} | ||
/> | ||
|
||
{intersperse( | ||
crumbs.map(({ label, path }, i) => ( | ||
<Link | ||
to={path} | ||
className={cn( | ||
'whitespace-nowrap text-sans-md hover:text-secondary', | ||
// make the last breadcrumb brighter, but only if we're below the top level | ||
!isTopLevel && i === crumbs.length - 1 ? 'text-secondary' : 'text-tertiary' | ||
)} | ||
key={`${label}|${path}`} | ||
> | ||
{label} | ||
</Link> | ||
)), | ||
<Slash /> | ||
)} | ||
</nav> | ||
) | ||
} |
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
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
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
Oops, something went wrong.