Commit 1980d417 authored by d.arizona's avatar d.arizona

nested home

parent 1daaf7fa
...@@ -18,6 +18,15 @@ import ListItemText from '@material-ui/core/ListItemText'; ...@@ -18,6 +18,15 @@ import ListItemText from '@material-ui/core/ListItemText';
import InboxIcon from '@material-ui/icons/MoveToInbox'; import InboxIcon from '@material-ui/icons/MoveToInbox';
import MailIcon from '@material-ui/icons/Mail'; import MailIcon from '@material-ui/icons/Mail';
import {
BrowserRouter as Router,
Switch,
Route,
Link,
useParams,
useRouteMatch
} from "react-router-dom";
const drawerWidth = 240; const drawerWidth = 240;
const useStyles = makeStyles((theme) => ({ const useStyles = makeStyles((theme) => ({
...@@ -95,6 +104,8 @@ export default function MiniDrawer() { ...@@ -95,6 +104,8 @@ export default function MiniDrawer() {
setOpen(false); setOpen(false);
}; };
let { path, url } = useRouteMatch();
return ( return (
<div className={classes.root}> <div className={classes.root}>
<CssBaseline /> <CssBaseline />
...@@ -160,30 +171,42 @@ export default function MiniDrawer() { ...@@ -160,30 +171,42 @@ export default function MiniDrawer() {
</Drawer> </Drawer>
<main className={classes.content}> <main className={classes.content}>
<div className={classes.toolbar} /> <div className={classes.toolbar} />
<Typography paragraph> <h2>Topics</h2>
Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt <ul>
ut labore et dolore magna aliqua. Rhoncus dolor purus non enim praesent elementum <li>
facilisis leo vel. Risus at ultrices mi tempus imperdiet. Semper risus in hendrerit <Link to={`${url}/rendering`}>Rendering with React</Link>
gravida rutrum quisque non tellus. Convallis convallis tellus id interdum velit laoreet id </li>
donec ultrices. Odio morbi quis commodo odio aenean sed adipiscing. Amet nisl suscipit <li>
adipiscing bibendum est ultricies integer quis. Cursus euismod quis viverra nibh cras. <Link to={`${url}/components`}>Components</Link>
Metus vulputate eu scelerisque felis imperdiet proin fermentum leo. Mauris commodo quis </li>
imperdiet massa tincidunt. Cras tincidunt lobortis feugiat vivamus at augue. At augue eget <li>
arcu dictum varius duis at consectetur lorem. Velit sed ullamcorper morbi tincidunt. Lorem <Link to={`${url}/props-v-state`}>Props v. State</Link>
donec massa sapien faucibus et molestie ac. </li>
</Typography> </ul>
<Typography paragraph>
Consequat mauris nunc congue nisi vitae suscipit. Fringilla est ullamcorper eget nulla <Switch>
facilisi etiam dignissim diam. Pulvinar elementum integer enim neque volutpat ac <Route exact path={path}>
tincidunt. Ornare suspendisse sed nisi lacus sed viverra tellus. Purus sit amet volutpat <h3>Please select a topic.</h3>
consequat mauris. Elementum eu facilisis sed odio morbi. Euismod lacinia at quis risus sed </Route>
vulputate odio. Morbi tincidunt ornare massa eget egestas purus viverra accumsan in. In <Route path={`${path}/:topicId`}>
hendrerit gravida rutrum quisque non tellus orci ac. Pellentesque nec nam aliquam sem et <Topic />
tortor. Habitant morbi tristique senectus et. Adipiscing elit duis tristique sollicitudin </Route>
nibh sit. Ornare aenean euismod elementum nisi quis eleifend. Commodo viverra maecenas </Switch>
accumsan lacus vel facilisis. Nulla posuere sollicitudin aliquam ultrices sagittis orci a.
</Typography>
</main> </main>
</div> </div>
); );
} }
\ No newline at end of file
function Topic() {
// The <Route> that rendered this component has a
// path of `/topics/:topicId`. The `:topicId` portion
// of the URL indicates a placeholder that we can
// get from `useParams()`.
let { topicId } = useParams();
return (
<div>
<h3>{topicId}</h3>
</div>
);
}
\ No newline at end of file
...@@ -44,11 +44,11 @@ export default function BasicExample() { ...@@ -44,11 +44,11 @@ export default function BasicExample() {
*/} */}
<Switch> <Switch>
<Route exact path="/"> <Route exact path="/">
<Home />
</Route>
<Route path="/login">
<Login /> <Login />
</Route> </Route>
<Route path="/home">
<Home />
</Route>
<Route path="/register"> <Route path="/register">
<Register /> <Register />
</Route> </Route>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment