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,22 +26,11 @@ if (!appEl) {
throw new Error(`Unable to find #${APP_ID}!`); throw new Error(`Unable to find #${APP_ID}!`);
} }
const App: React.FC<{}> = (props) => { const Navbar: React.FC<{ currPageName: string }> = (props) => (
const page = new URLSearchParams(window.location.search); <ul className="navbar">
const currPageName = toPageName(page.get("p") || "", "vocabulary");
const PageComponent = Pages[currPageName];
return (
<>
<main>
<PageComponent />
</main>
<footer>
<p>Other pages</p>
<ul>
{pageNames.map((pageName) => ( {pageNames.map((pageName) => (
<li key={pageName}> <li key={pageName}>
{currPageName === pageName ? ( {props.currPageName === pageName ? (
pageName pageName
) : ( ) : (
<a href={`?p=${encodeURIComponent(pageName)}`}>{pageName}</a> <a href={`?p=${encodeURIComponent(pageName)}`}>{pageName}</a>
@ -49,6 +38,22 @@ const App: React.FC<{}> = (props) => {
</li> </li>
))} ))}
</ul> </ul>
);
const App: React.FC<{}> = (props) => {
const page = new URLSearchParams(window.location.search);
const currPageName = toPageName(page.get("p") || "", "vocabulary");
const PageComponent = Pages[currPageName];
return (
<>
<header>
<Navbar currPageName={currPageName} />
</header>
<main>
<PageComponent />
</main>
<footer>
<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">