Skip to content

Commit

Permalink
Add title to the document.
Browse files Browse the repository at this point in the history
  • Loading branch information
LanDinh committed Nov 15, 2023
1 parent 0a1afb4 commit 0ba348f
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 17 deletions.
8 changes: 5 additions & 3 deletions frontend/admin/app/root.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import { links, ErrorBoundary, App, handle } from './khaleesi/components/document'
import { navigationProperties } from './khaleesi/navigation/navigationData'
import { topNavigationData } from './khaleesi/navigation/commonNavigationData'


export default App
export { links, ErrorBoundary, navigationProperties, handle }
const AdminApp = () => <App title="Admin Console" />
export default AdminApp
export { links, ErrorBoundary, handle }
export const navigationProperties = topNavigationData[0]
18 changes: 10 additions & 8 deletions frontend/khaleesi/app/khaleesi/components/document.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,18 @@ import { breadcrumb } from '../navigation/breadcrumb'
import { Navigation } from '../navigation/navigation'
import { Content } from './content'
import { ErrorPage } from './error'
// @ts-ignore: styles have no types
import rootStyles from '../styles/index.css'
// @ts-ignore: styles have no types
import navigationBarStyles from '../styles/navigation.css'
import { navigationProperties } from '../navigation/navigationData'
import { topNavigationData } from '../navigation/commonNavigationData'


export const handle = {
...breadcrumb(navigationProperties),
...breadcrumb(topNavigationData[0]),
}

function Document({ children }: PropsWithChildren<{}>): JSX.Element {
function Document({ children, title }: PropsWithChildren<{ title: string }>): JSX.Element {
return <html lang="en">
<head>
<meta charSet="utf-8" />
Expand All @@ -24,7 +26,7 @@ function Document({ children }: PropsWithChildren<{}>): JSX.Element {
</head>
<body>
<div id="khaleesi-app">
<div id="khaleesi-title" className="khaleesi-bar">Title</div>
<div id="khaleesi-title" className="khaleesi-bar">{title}</div>
<Navigation />
<Content>
{children}
Expand All @@ -44,14 +46,14 @@ export const links: LinksFunction = () => [
{ rel: 'stylesheet', href: navigationBarStyles },
]

export function ErrorBoundary(): JSX.Element {
return <Document>
export function ErrorBoundary({ title }: { title: string }): JSX.Element {
return <Document title={title}>
<ErrorPage />
</Document>
}

export function App(): JSX.Element {
return <Document>
export function App({ title }: { title: string }): JSX.Element {
return <Document title={title}>
<Outlet />
</Document>
}
8 changes: 5 additions & 3 deletions frontend/khaleesi_frontend_tests/app/root.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import { links, ErrorBoundary, App, handle } from './khaleesi/components/document'
import { navigationProperties } from './khaleesi/navigation/navigationData'
import { topNavigationData } from './khaleesi/navigation/commonNavigationData'


export default App
export { links, ErrorBoundary, navigationProperties, handle }
const TestApp = () => <App title="Test App" />
export default TestApp
export { links, ErrorBoundary, handle }
export const navigationProperties = topNavigationData[0]
8 changes: 5 additions & 3 deletions templates/frontend/frontend_template/app/root.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import { links, ErrorBoundary, App, handle } from './khaleesi/components/document'
import { navigationProperties } from './khaleesi/navigation/navigationData'
import { topNavigationData } from './khaleesi/navigation/commonNavigationData'


export default App
export { links, ErrorBoundary, navigationProperties, handle }
const NewApp = () => <App title="Lorem Ipsum" />
export default NewApp
export { links, ErrorBoundary, handle }
export const navigationProperties = topNavigationData[0]

0 comments on commit 0ba348f

Please sign in to comment.