mirror of
https://github.com/Fluffy-Bean/TastyBites.git
synced 2025-06-01 16:13:10 +00:00
Add a router and some temporary pages
This commit is contained in:
parent
56bd273711
commit
677ef885cf
9 changed files with 96 additions and 4 deletions
|
@ -1,9 +1,45 @@
|
|||
<script>
|
||||
import Router from 'svelte-spa-router';
|
||||
import { replace, link, location } from 'svelte-spa-router';
|
||||
import active from 'svelte-spa-router/active'
|
||||
import routes from './routes';
|
||||
|
||||
let oldLocation = undefined;
|
||||
let showNavBar = false;
|
||||
|
||||
function routeLoading(event) {
|
||||
if (event.detail.location === oldLocation) {
|
||||
return; // not an actual change
|
||||
}
|
||||
showNavBar = event.detail.userData.showNavBar;
|
||||
oldLocation = event.detail.location;
|
||||
}
|
||||
|
||||
function conditionFailure(event) {
|
||||
replace("/");
|
||||
}
|
||||
</script>
|
||||
|
||||
<main>
|
||||
<h1>TastyBites</h1>
|
||||
</main>
|
||||
{#if showNavBar }
|
||||
<nav>
|
||||
<p>TastyBites</p>
|
||||
<ul>
|
||||
<li><a href="/" use:link use:active>Home</a></li>
|
||||
<li><a href="/contact" use:link use:active>Contact Us</a></li>
|
||||
<li><a href="/cart" use:link use:active>Shopping Cart</a></li>
|
||||
</ul>
|
||||
<p>Location: {$location}</p>
|
||||
</nav>
|
||||
{/if}
|
||||
<Router
|
||||
{routes}
|
||||
restoreScrollState={true}
|
||||
on:routeLoading={routeLoading}
|
||||
on:conditionsFailed={conditionFailure}
|
||||
/>
|
||||
<footer>
|
||||
<p>TastyBites is a fake restaurant</p>
|
||||
</footer>
|
||||
|
||||
<style>
|
||||
</style>
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue