Skip to content

Commit

Permalink
Add routes & breadcrumbs to About section
Browse files Browse the repository at this point in the history
  • Loading branch information
khoidt committed Sep 26, 2023
1 parent 06860d4 commit d6e6818
Show file tree
Hide file tree
Showing 2 changed files with 51 additions and 11 deletions.
38 changes: 33 additions & 5 deletions src/about/ui/about.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import React from 'react'
import React, { useState } from 'react'
import { Tabs, Tab } from 'react-bootstrap'
import { useHistory } from 'react-router-dom'
import AppContent from 'common/AppContent'
import { SectionCrumb } from 'common/Breadcrumbs'
import { TextCrumb } from 'common/Breadcrumbs'
import MarkupService from 'markup/application/MarkupService'
import 'about/ui/about.sass'
import AboutProject from 'about/ui/project'
Expand All @@ -11,17 +12,44 @@ import AboutSigns from 'about/ui/signs'
import AboutDictionary from 'about/ui/dictionary'
import AboutListOfKings from 'about/ui/chronology'
import DateConverterForm from 'chronology/ui/DateConverterForm'
import _ from 'lodash'

export const tabIds = [
'project',
'fragmentarium',
'corpus',
'signs',
'dictionary',
'date-converter',
'list-of-kings',
] as const
export type TabId = typeof tabIds[number]

export default function About({
markupService,
activeTab,
}: {
markupService: MarkupService
activeTab: TabId
}): JSX.Element {
const history = useHistory()
const [selectedTab, setSelectedTab] = useState(activeTab)
const handleSelect = (selectedTab: TabId) => {
history.push(selectedTab)
setSelectedTab(selectedTab)
}
return (
<AppContent title="About" crumbs={[new SectionCrumb('About')]}>
<AppContent
title="About"
crumbs={[
new TextCrumb('About'),
new TextCrumb(_.capitalize(selectedTab).replaceAll('-', ' ')),
]}
>
<Tabs
id="about"
defaultActiveKey="fragmentarium"
defaultActiveKey={selectedTab}
onSelect={(selectedTab) => handleSelect(selectedTab as TabId)}
mountOnEnter
unmountOnExit
>
Expand All @@ -43,7 +71,7 @@ export default function About({
<Tab eventKey="date-converter" title="Date converter">
<DateConverterForm />
</Tab>
<Tab eventKey="list-of-kings" title="List of Kings">
<Tab eventKey="list-of-kings" title="List of kings">
{AboutListOfKings()}
</Tab>
</Tabs>
Expand Down
24 changes: 18 additions & 6 deletions src/router/aboutRoutes.tsx
Original file line number Diff line number Diff line change
@@ -1,10 +1,14 @@
import React, { ReactNode } from 'react'
import { Route } from 'react-router-dom'
import About from 'about/ui/about'
import { Redirect, Route, RouteComponentProps } from 'react-router-dom' //Redirect
import About, { TabId, tabIds } from 'about/ui/about'
import MarkupService from 'markup/application/MarkupService'
import { sitemapDefaults } from 'router/sitemap'
import { HeadTagsService } from 'router/head'

// ToDo:
// - Update sitemap
// console.log

export default function AboutRoutes({
sitemap,
markupService,
Expand All @@ -14,18 +18,26 @@ export default function AboutRoutes({
}): JSX.Element[] {
return [
<Route
key="about"
key="about-tabs"
exact
path="/about"
render={(): ReactNode => (
path={`/about/:id(${tabIds.join('|')})`}
render={(props: RouteComponentProps<{ id: string }>): ReactNode => (
<HeadTagsService
title="About: eBL"
description="This section provides detailed information about the electronic Babylonian Library (eBL) and the materials and tools available."
>
<About markupService={markupService} />
<About
markupService={markupService}
activeTab={props.match.params.id as TabId}
/>
</HeadTagsService>
)}
{...(sitemap && sitemapDefaults)}
/>,
<Redirect
from="/about"
to="/about/fragmentarium"
key="about-root-redirect"
/>,
]
}

0 comments on commit d6e6818

Please sign in to comment.