Skip to content

Commit 31520a2

Browse files
committed
move Breadcrumbs component definition into TopBar.tsx
1 parent ad02ede commit 31520a2

File tree

2 files changed

+41
-50
lines changed

2 files changed

+41
-50
lines changed

app/components/Breadcrumbs.tsx

Lines changed: 0 additions & 47 deletions
This file was deleted.

app/components/TopBar.tsx

Lines changed: 41 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,16 +6,22 @@
66
* Copyright Oxide Computer Company
77
*/
88
import cn from 'classnames'
9-
import React from 'react'
9+
import { Link } from 'react-router-dom'
1010

1111
import { 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'
1518
import { SiloSystemPicker } from '~/components/TopBarPicker'
19+
import { useCrumbs } from '~/hooks/use-crumbs'
1620
import { useCurrentUser } from '~/layouts/AuthenticatedLayout'
1721
import { buttonStyle } from '~/ui/lib/Button'
1822
import * as DropdownMenu from '~/ui/lib/DropdownMenu'
23+
import { Slash } from '~/ui/lib/Slash'
24+
import { intersperse } from '~/util/array'
1925
import { pb } from '~/util/path-builder'
2026

2127
export 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+
4482
function UserMenu() {
4583
const logout = useApiMutation('logout', {
4684
onSuccess: () => navToLogin({ includeCurrent: false }),

0 commit comments

Comments
 (0)