Move page list to header for easier navigation.

pull/66/head
Atul Varma 2021-03-29 07:48:56 -04:00
rodzic 3090d9fd89
commit a917f40da9
2 zmienionych plików z 35 dodań i 12 usunięć

Wyświetl plik

@ -30,6 +30,24 @@ select {
margin-top: 10px; margin-top: 10px;
margin-bottom: 10px; margin-bottom: 10px;
} }
ul.navbar {
display: flex;
list-style-type: none;
margin: 0;
padding: 0;
justify-content: flex-end;
}
ul.navbar li {
border-right: 1px solid gray;
margin-right: 8px;
padding-right: 8px;
}
ul.navbar li:last-child {
border-right: none;
}
</style> </style>
<noscript> <noscript>
<p>Alas, you need JavaScript to peruse this page.</p> <p>Alas, you need JavaScript to peruse this page.</p>

Wyświetl plik

@ -26,6 +26,20 @@ if (!appEl) {
throw new Error(`Unable to find #${APP_ID}!`); throw new Error(`Unable to find #${APP_ID}!`);
} }
const Navbar: React.FC<{ currPageName: string }> = (props) => (
<ul className="navbar">
{pageNames.map((pageName) => (
<li key={pageName}>
{props.currPageName === pageName ? (
pageName
) : (
<a href={`?p=${encodeURIComponent(pageName)}`}>{pageName}</a>
)}
</li>
))}
</ul>
);
const App: React.FC<{}> = (props) => { const App: React.FC<{}> = (props) => {
const page = new URLSearchParams(window.location.search); const page = new URLSearchParams(window.location.search);
const currPageName = toPageName(page.get("p") || "", "vocabulary"); const currPageName = toPageName(page.get("p") || "", "vocabulary");
@ -33,22 +47,13 @@ const App: React.FC<{}> = (props) => {
return ( return (
<> <>
<header>
<Navbar currPageName={currPageName} />
</header>
<main> <main>
<PageComponent /> <PageComponent />
</main> </main>
<footer> <footer>
<p>Other pages</p>
<ul>
{pageNames.map((pageName) => (
<li key={pageName}>
{currPageName === pageName ? (
pageName
) : (
<a href={`?p=${encodeURIComponent(pageName)}`}>{pageName}</a>
)}
</li>
))}
</ul>
<p> <p>
For more details about this project, see its{" "} For more details about this project, see its{" "}
<a href="https://github.com/toolness/mystic-symbolic" target="_blank"> <a href="https://github.com/toolness/mystic-symbolic" target="_blank">