diff --git a/src/__tests__/components/Breadcrumb.test.tsx b/src/__tests__/components/Breadcrumb.test.tsx
new file mode 100644
index 0000000000..3ad64f2d5c
--- /dev/null
+++ b/src/__tests__/components/Breadcrumb.test.tsx
@@ -0,0 +1,33 @@
+import '../../__mocks__/matchMediaMock'
+import React from 'react'
+import { mount } from 'enzyme'
+import { createMemoryHistory } from 'history'
+import { Router } from 'react-router'
+import Breadcrumb from 'components/Breadcrumb'
+import {
+ Breadcrumb as HrBreadcrumb,
+ BreadcrumbItem as HrBreadcrumbItem,
+} from '@hospitalrun/components'
+
+describe('Breadcrumb', () => {
+ let history = createMemoryHistory()
+ const setup = (location: string) => {
+ history = createMemoryHistory()
+ history.push(location)
+ return mount(
+
+
+ ,
+ )
+ }
+
+ it('should render the breadcrumb items', () => {
+ const wrapper = setup('/patients')
+ const breadcrumbItem = wrapper.find(HrBreadcrumbItem)
+
+ expect(wrapper.find(HrBreadcrumb)).toHaveLength(1)
+ expect(
+ breadcrumbItem.matchesElement(patients),
+ ).toBeTruthy()
+ })
+})
diff --git a/src/components/Breadcrumb.tsx b/src/components/Breadcrumb.tsx
new file mode 100644
index 0000000000..e0de776d84
--- /dev/null
+++ b/src/components/Breadcrumb.tsx
@@ -0,0 +1,46 @@
+import React from 'react'
+import { useLocation, useHistory } from 'react-router'
+import {
+ Breadcrumb as HrBreadcrumb,
+ BreadcrumbItem as HrBreadcrumbItem,
+} from '@hospitalrun/components'
+
+interface Item {
+ name: string
+ url: string
+}
+
+function getItems(pathname: string): Item[] {
+ if (!pathname || pathname === '/') {
+ return [{ name: 'dashboard', url: '/' }]
+ }
+
+ return pathname
+ .substring(1)
+ .split('/')
+ .map((name) => ({ name, url: '/' }))
+}
+
+const Breadcrumb = () => {
+ const { pathname } = useLocation()
+ const history = useHistory()
+ const items = getItems(pathname)
+ const lastIndex = items.length - 1
+
+ return (
+
+ {items.map((item, index) => {
+ const isLast = index === lastIndex
+ const onClick = !isLast ? () => history.push(item.url) : undefined
+
+ return (
+
+ {item.name}
+
+ )
+ })}
+
+ )
+}
+
+export default Breadcrumb
diff --git a/src/index.css b/src/index.css
index 49f3c5114d..4dba66ac57 100644
--- a/src/index.css
+++ b/src/index.css
@@ -24,7 +24,7 @@ code {
bottom: 0;
left: 0;
z-index: 0; /* Behind the navbar */
- padding: 48px 0 0; /* Height of navbar */
+ padding: 75px 0 0; /* Height of navbar */
box-shadow: inset -1px 0 0 rgba(0, 0, 0, .1);
}
@@ -88,3 +88,15 @@ code {
border-color: transparent;
box-shadow: 0 0 0 3px rgba(255, 255, 255, .25);
}
+
+.breadcrumb {
+ z-index: 1;
+ position: relative;
+ padding: .2rem 1rem;
+ background-color: white;
+ border-bottom: .1rem solid lightgray;
+}
+
+.breadcrumb-item > span, .breadcrumb-item > a {
+ text-transform: capitalize;
+}