Skip to content

Commit

Permalink
Added basic routing.
Browse files Browse the repository at this point in the history
  • Loading branch information
cmvanb committed Sep 27, 2024
1 parent eb6dc29 commit b78d23b
Show file tree
Hide file tree
Showing 12 changed files with 98 additions and 48 deletions.
10 changes: 10 additions & 0 deletions frontend/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions frontend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
"vite-plugin-solid": "^2.8.2"
},
"dependencies": {
"@solidjs/router": "^0.14.7",
"beercss": "^3.7.8",
"solid-js": "^1.8.11"
}
Expand Down
11 changes: 2 additions & 9 deletions frontend/src/App.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { createSignal } from 'solid-js';
import TopBar from './components/TopBar';
import DrawerMenu from './components/DrawerMenu';

function App() {
function App(props) {
const [menuOpen, setMenuOpen] = createSignal(false);

return (
Expand All @@ -14,14 +14,7 @@ function App() {
<DrawerMenu menuOpen={menuOpen} setMenuOpen={setMenuOpen} />
</header>
<main class="responsive">
<div class="grid">
<div class="s6">
<h3>Hello world!</h3>
</div>
<div class="s6">
<h3>Content goes here.</h3>
</div>
</div>
{props.children}
</main>
<footer>
</footer>
Expand Down
22 changes: 21 additions & 1 deletion frontend/src/index.jsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,16 @@
/* @refresh reload */
import { render } from 'solid-js/web';
import { Router, Route } from '@solidjs/router';

import './index.css';
import App from './App';
import Splash from './pages/Splash';
import NotFound from './pages/NotFound';
import Recipe from './pages/Recipe';
import Login from './pages/Login';
import Recipes from './pages/Recipes';
import MealPlanner from './pages/MealPlanner';
import Settings from './pages/Settings';

const root = document.getElementById('root');

Expand All @@ -12,4 +20,16 @@ if (import.meta.env.DEV && !(root instanceof HTMLElement)) {
);
}

render(() => <App />, root);
render(
() => (
<Router root={App}>
<Route path="/mealplanner" component={MealPlanner} />
<Route path="/recipes" component={Recipes} />
<Route path="/recipes/:id" component={Recipe} />
<Route path="/settings" component={Settings} />
<Route path="/login" component={Login} />
<Route path="/" component={Splash} />
<Route path="*" component={NotFound} />
</Router>
),
root);
9 changes: 9 additions & 0 deletions frontend/src/pages/Login.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
function Login() {
return (
<div>
<h3>LOGIN</h3>
</div>
);
}

export default Login;
9 changes: 9 additions & 0 deletions frontend/src/pages/MealPlanner.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
function MealPlanner() {
return (
<div>
<h3>MEAL PLANNER</h3>
</div>
);
}

export default MealPlanner;
9 changes: 9 additions & 0 deletions frontend/src/pages/NotFound.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
function NotFound() {
return (
<div>
<h3>404 NOT FOUND</h3>
</div>
);
}

export default NotFound;
9 changes: 9 additions & 0 deletions frontend/src/pages/Recipe.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
function Recipe() {
return (
<div>
<h3>RECIPE</h3>
</div>
);
}

export default Recipe;
9 changes: 9 additions & 0 deletions frontend/src/pages/Recipes.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
function Recipes() {
return (
<div>
<h3>RECIPES</h3>
</div>
);
}

export default Recipes;
9 changes: 9 additions & 0 deletions frontend/src/pages/Settings.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
function Settings() {
return (
<div>
<h3>SETTINGS</h3>
</div>
);
}

export default Settings;
10 changes: 10 additions & 0 deletions frontend/src/pages/Splash.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
function Splash() {
return (
<div>
<h3>SPLASH</h3>
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur.</p>
</div>
);
}

export default Splash;
38 changes: 0 additions & 38 deletions frontend/src/routes.js

This file was deleted.

0 comments on commit b78d23b

Please sign in to comment.