66 * Copyright Oxide Computer Company
77 */
88import cn from 'classnames'
9- import React from 'react'
9+ import { Link } from 'react-router-dom '
1010
1111import { navToLogin , useApiMutation } from '@oxide/api'
12- import { DirectionDownIcon , Profile16Icon } from '@oxide/design-system/icons/react'
12+ import {
13+ DirectionDownIcon ,
14+ PrevArrow12Icon ,
15+ Profile16Icon ,
16+ } from '@oxide/design-system/icons/react'
1317
14- import { Breadcrumbs } from '~/components/Breadcrumbs'
1518import { SiloSystemPicker } from '~/components/TopBarPicker'
19+ import { useCrumbs } from '~/hooks/use-crumbs'
1620import { useCurrentUser } from '~/layouts/AuthenticatedLayout'
1721import { buttonStyle } from '~/ui/lib/Button'
1822import * as DropdownMenu from '~/ui/lib/DropdownMenu'
23+ import { Slash } from '~/ui/lib/Slash'
24+ import { intersperse } from '~/util/array'
1925import { pb } from '~/util/path-builder'
2026
2127export function TopBar ( { systemOrSilo } : { systemOrSilo : 'system' | 'silo' } ) {
@@ -41,6 +47,38 @@ export function TopBar({ systemOrSilo }: { systemOrSilo: 'system' | 'silo' }) {
4147 )
4248}
4349
50+ function Breadcrumbs ( ) {
51+ const crumbs = useCrumbs ( ) . filter ( ( c ) => ! c . titleOnly )
52+ const isTopLevel = crumbs . length <= 1
53+ return (
54+ < nav
55+ className = "flex items-center gap-0.5 overflow-clip pr-4 text-sans-md"
56+ aria-label = "Breadcrumbs"
57+ >
58+ < PrevArrow12Icon
59+ className = { cn ( 'mx-1.5 flex-shrink-0 text-quinary' , isTopLevel && 'opacity-40' ) }
60+ />
61+
62+ { intersperse (
63+ crumbs . map ( ( { label, path } , i ) => (
64+ < Link
65+ to = { path }
66+ className = { cn (
67+ 'whitespace-nowrap text-sans-md hover:text-secondary' ,
68+ // make the last breadcrumb brighter, but only if we're below the top level
69+ ! isTopLevel && i === crumbs . length - 1 ? 'text-secondary' : 'text-tertiary'
70+ ) }
71+ key = { `${ label } |${ path } ` }
72+ >
73+ { label }
74+ </ Link >
75+ ) ) ,
76+ < Slash />
77+ ) }
78+ </ nav >
79+ )
80+ }
81+
4482function UserMenu ( ) {
4583 const logout = useApiMutation ( 'logout' , {
4684 onSuccess : ( ) => navToLogin ( { includeCurrent : false } ) ,
0 commit comments