@@ -4,47 +4,63 @@ import '@mdxeditor/editor/style.css';
4
4
import './styles/usdswebsite.override.css' ;
5
5
import "react-toastify/dist/ReactToastify.css" ;
6
6
import "./App.css" ;
7
- import { Fragment } from "react" ;
7
+ import { Fragment , useState } from "react" ;
8
8
import { BlogEditorPage } from "./pages/BlogEditorPage.tsx" ;
9
- import { NavList , Header , Title , } from "@trussworks/react-uswds" ;
9
+ import { NavList , Header , Title , NavMenuButton , PrimaryNav , Grid , GridContainer , } from "@trussworks/react-uswds" ;
10
+ import { HomePage } from "./pages/HomePage.tsx" ;
11
+ import { AboutPage } from "./pages/AboutPage.tsx" ;
10
12
11
13
// we use the uswds styles from usds.github.io/website-staging
12
14
// import '@uswds/uswds/css/uswds.css';
13
15
16
+ // roll our own nav. Doing anything too fancy is difficult on github pages because of paths.
17
+ // keys are UX names which isn't great but whatever. It's just a few lines of code.
18
+ const Pages = [ "Home" , "Blog Edit" , "About" ] as const ;
19
+ type PagesType = ( typeof Pages ) [ number ] ;
20
+ type PagesMap = {
21
+ [ key in PagesType ] ?: React . ReactElement ;
22
+ } ;
14
23
15
- // const Layout = () => {
16
- // return (
17
- // <Fragment>
18
- // <Header basic>
19
- // <div className="usa-nav-container">
20
- // <div className="usa-navbar">
21
- // <Title>Website Content Editor</Title>
22
- // {/* A "layout route" is a good place to put markup you want to
23
- // share across all the pages on your site, like navigation. */ }
24
- // <NavList items={
25
- // [<NavLink key={"homenavlink"} to="/">Home</NavLink>,
26
- // <NavLink key={"aboutlink"} to="/about">About</NavLink>,
27
- // <NavLink key={"blogedit"} to="/blogedit">News-and-blog editor</NavLink>]
28
- // } type="primary"/>
29
- // </div>
30
- // </div>
31
- // </Header>
32
- //
33
- //
34
- // {/* An <Outlet> renders whatever child route is currently active,
35
- // so you can think about this <Outlet> as a placeholder for
36
- // the child routes we defined above. */ }
37
- // <section className="usa-section">
38
- // <Outlet/>
39
- // </section>
40
- // </Fragment>
41
- // );
42
- // }
43
24
44
25
function App ( ) {
26
+ const [ page , SetPage ] = useState < PagesType > ( "Home" ) ;
27
+ const PAGES_MAP : PagesMap = {
28
+ "Home" : < HomePage /> ,
29
+ "Blog Edit" : < BlogEditorPage /> ,
30
+ "About" : < AboutPage /> ,
31
+ } ;
32
+
45
33
return (
46
34
< Fragment >
47
- < BlogEditorPage />
35
+ < Header basic >
36
+ < div className = "usa-nav-container" >
37
+ < PrimaryNav
38
+ aria-label = "Primary navigation"
39
+ items = { Pages . map ( ( eachPage ) =>
40
+ < a key = { `${ eachPage } ` }
41
+ href = ""
42
+ className = { eachPage === page ? "usa-nav__link usa-current" : "usa-nav__link" }
43
+ onClick = { ( e ) => {
44
+ SetPage ( eachPage ) ;
45
+ e . preventDefault ( ) ;
46
+ e . stopPropagation ( ) ;
47
+ } } > { eachPage } </ a > ) } />
48
+ </ div >
49
+ </ Header >
50
+ < div className = "usa-section" >
51
+ < GridContainer >
52
+ < Grid row gap >
53
+ < main
54
+ className = "usa-layout-docs__main desktop:grid-col-12 usa-prose usa-layout-docs"
55
+ id = "main-content"
56
+ role = { "main" }
57
+ >
58
+ < h1 > Website Content Editor</ h1 >
59
+ { PAGES_MAP [ page ] }
60
+ </ main >
61
+ </ Grid >
62
+ </ GridContainer >
63
+ </ div >
48
64
< ToastContainer limit = { 4 } />
49
65
</ Fragment >
50
66
) ;
0 commit comments