mirror of
https://github.com/Fluffy-Bean/TastyBites.git
synced 2024-12-28 18:36:25 +00:00
Make temporary content for pages
Switch to SCSS for styling
This commit is contained in:
parent
b13a14ffb3
commit
12a33388f6
|
@ -22,7 +22,10 @@
|
||||||
* Typecheck JS in `.svelte` and `.js` files by default.
|
* Typecheck JS in `.svelte` and `.js` files by default.
|
||||||
* Disable this if you'd like to use dynamic types.
|
* Disable this if you'd like to use dynamic types.
|
||||||
*/
|
*/
|
||||||
"checkJs": true
|
"checkJs": true,
|
||||||
|
"paths": {
|
||||||
|
"%": ["./src"]
|
||||||
|
}
|
||||||
},
|
},
|
||||||
/**
|
/**
|
||||||
* Use global.d.ts instead of compilerOptions.types
|
* Use global.d.ts instead of compilerOptions.types
|
||||||
|
|
BIN
front/public/temp.jpg
Normal file
BIN
front/public/temp.jpg
Normal file
Binary file not shown.
After Width: | Height: | Size: 16 MiB |
|
@ -2,7 +2,7 @@
|
||||||
import Router from 'svelte-spa-router';
|
import Router from 'svelte-spa-router';
|
||||||
import { replace, link } from 'svelte-spa-router';
|
import { replace, link } from 'svelte-spa-router';
|
||||||
import active from 'svelte-spa-router/active'
|
import active from 'svelte-spa-router/active'
|
||||||
import routes from './routes';
|
import routes from '%/routes.js';
|
||||||
|
|
||||||
let oldLocation = undefined;
|
let oldLocation = undefined;
|
||||||
let showNavBar = false;
|
let showNavBar = false;
|
||||||
|
@ -22,43 +22,56 @@
|
||||||
|
|
||||||
{#if showNavBar }
|
{#if showNavBar }
|
||||||
<nav>
|
<nav>
|
||||||
<ul>
|
<ul style="justify-content: flex-end">
|
||||||
<li><a href="/" use:link use:active>Home</a></li>
|
<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="/contact" use:link use:active>Contact Us</a></li>
|
||||||
</ul>
|
</ul>
|
||||||
|
|
||||||
<span>TastyBites</span>
|
<span>TastyBites</span>
|
||||||
<ul>
|
|
||||||
|
<ul style="justify-content: flex-start">
|
||||||
<li><a href="/orders" use:link use:active>Orders</a></li>
|
<li><a href="/orders" use:link use:active>Orders</a></li>
|
||||||
<li><a href="/cart" use:link use:active>Shopping Cart</a></li>
|
<li><a href="/cart" use:link use:active>Cart</a></li>
|
||||||
</ul>
|
</ul>
|
||||||
</nav>
|
</nav>
|
||||||
{/if}
|
{/if}
|
||||||
<Router
|
<main>
|
||||||
{routes}
|
<Router
|
||||||
restoreScrollState={true}
|
{routes}
|
||||||
on:routeLoading={routeLoading}
|
restoreScrollState={true}
|
||||||
on:conditionsFailed={conditionFailure}
|
on:routeLoading={routeLoading}
|
||||||
/>
|
on:conditionsFailed={conditionFailure}
|
||||||
|
/>
|
||||||
|
</main>
|
||||||
<footer>
|
<footer>
|
||||||
<p>TastyBites is a fake restaurant</p>
|
<p>TastyBites is a fake restaurant</p>
|
||||||
</footer>
|
</footer>
|
||||||
|
|
||||||
<style lang="sass">
|
<style lang="scss">
|
||||||
nav
|
nav {
|
||||||
display: flex
|
display: flex;
|
||||||
justify-content: center
|
justify-content: center;
|
||||||
align-items: center
|
align-items: center;
|
||||||
padding: 1rem
|
padding: 1rem;
|
||||||
background-color: #f8f9fa
|
background-color: #f8f9fa;
|
||||||
border-bottom: 1px solid #e9ecef
|
border-bottom: 1px solid #e9ecef;
|
||||||
ul
|
ul {
|
||||||
padding: 0
|
width: 300px;
|
||||||
margin: 0
|
padding: 0;
|
||||||
display: flex
|
margin: 0;
|
||||||
list-style: none
|
display: flex;
|
||||||
li
|
list-style: none;
|
||||||
margin: 0 1rem
|
li {
|
||||||
span
|
margin: 0 1rem;
|
||||||
margin: 0 1rem
|
}
|
||||||
font-weight: bolder
|
span {
|
||||||
|
margin: 0 1rem;
|
||||||
|
font-weight: bolder;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
main {
|
||||||
|
padding: 1rem;
|
||||||
|
flex-grow: 1;
|
||||||
|
}
|
||||||
</style>
|
</style>
|
||||||
|
|
|
@ -1,3 +0,0 @@
|
||||||
*, *::before, *::after {
|
|
||||||
box-sizing: border-box;
|
|
||||||
}
|
|
|
@ -1,5 +1,5 @@
|
||||||
import './app.css'
|
import '%/styles/main.scss'
|
||||||
import App from './App.svelte'
|
import App from '%/App.svelte'
|
||||||
|
|
||||||
const app = new App({
|
const app = new App({
|
||||||
target: document.getElementById('app'),
|
target: document.getElementById('app'),
|
||||||
|
|
|
@ -1,5 +1,7 @@
|
||||||
<script>
|
<script>
|
||||||
import { link } from 'svelte-spa-router';
|
import { link } from 'svelte-spa-router';
|
||||||
|
|
||||||
|
export let params = {};
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<h1>404</h1>
|
<h1>404</h1>
|
26
front/src/pages/components/ItemList.svelte
Normal file
26
front/src/pages/components/ItemList.svelte
Normal file
|
@ -0,0 +1,26 @@
|
||||||
|
<script>
|
||||||
|
import MenuItem from "%/pages/components/MenuItem.svelte";
|
||||||
|
|
||||||
|
export let items = [];
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<ul>
|
||||||
|
{#each items as item}
|
||||||
|
<li><MenuItem name={item.name} price={item.price} id={item.name} /></li>
|
||||||
|
{/each}
|
||||||
|
</ul>
|
||||||
|
|
||||||
|
<style lang="scss">
|
||||||
|
ul {
|
||||||
|
list-style-type: none;
|
||||||
|
padding: 0;
|
||||||
|
margin: 0;
|
||||||
|
display: flex;
|
||||||
|
flex-direction: row;
|
||||||
|
flex-wrap: wrap;
|
||||||
|
gap: 16px
|
||||||
|
}
|
||||||
|
li {
|
||||||
|
margin: 0;
|
||||||
|
}
|
||||||
|
</style>
|
26
front/src/pages/components/MenuItem.svelte
Normal file
26
front/src/pages/components/MenuItem.svelte
Normal file
|
@ -0,0 +1,26 @@
|
||||||
|
<script>
|
||||||
|
import { link } from 'svelte-spa-router';
|
||||||
|
|
||||||
|
export let name;
|
||||||
|
export let price;
|
||||||
|
export let id;
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<a href="/item/{id}" use:link>
|
||||||
|
<span>{name}</span>
|
||||||
|
<span>£{price}</span>
|
||||||
|
</a>
|
||||||
|
|
||||||
|
<style lang="scss">
|
||||||
|
a {
|
||||||
|
width: 200px;
|
||||||
|
height: 200px;
|
||||||
|
background-color: #f0f0f0;
|
||||||
|
padding: 10px;
|
||||||
|
border: 1px solid #ccc;
|
||||||
|
border-radius: 5px;
|
||||||
|
overflow: hidden;
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
}
|
||||||
|
</style>
|
26
front/src/pages/index/Announcement.svelte
Normal file
26
front/src/pages/index/Announcement.svelte
Normal file
|
@ -0,0 +1,26 @@
|
||||||
|
<script>
|
||||||
|
import temp from '/temp.jpg';
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<div>
|
||||||
|
<img src={temp} alt="Rufus" />
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<style lang="scss">
|
||||||
|
div {
|
||||||
|
height: 400px;
|
||||||
|
background-color: #f0f0f0;
|
||||||
|
padding: 10px;
|
||||||
|
border: 1px solid #ccc;
|
||||||
|
border-radius: 5px;
|
||||||
|
position: relative;
|
||||||
|
overflow: hidden;
|
||||||
|
}
|
||||||
|
div > img{
|
||||||
|
position: absolute;
|
||||||
|
top: 0;
|
||||||
|
left: 0;
|
||||||
|
width: 100%;
|
||||||
|
height: auto;
|
||||||
|
}
|
||||||
|
</style>
|
36
front/src/pages/index/PageIndex.svelte
Normal file
36
front/src/pages/index/PageIndex.svelte
Normal file
|
@ -0,0 +1,36 @@
|
||||||
|
<script>
|
||||||
|
import { link } from 'svelte-spa-router';
|
||||||
|
import Announcement from "%/pages/index/Announcement.svelte";
|
||||||
|
import ItemList from "%/pages/components/ItemList.svelte";
|
||||||
|
|
||||||
|
const items = [
|
||||||
|
{name: "Breakfast", price: 69.99},
|
||||||
|
{name: "Dinner", price: 21},
|
||||||
|
{name: "Brick", price: 0},
|
||||||
|
{name: "Toast", price: 4382749832743},
|
||||||
|
{name: "water", price: 1},
|
||||||
|
{name: "half eaten mouldy bread", price: -9999}
|
||||||
|
];
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<Announcement />
|
||||||
|
<a href="/annoucements" use:link style="float: right">Learn More</a>
|
||||||
|
|
||||||
|
<div class="spacer"></div>
|
||||||
|
|
||||||
|
<h2>Menu</h2>
|
||||||
|
<ItemList {items} />
|
||||||
|
<a href="/menu" use:link style="float: right">See All</a>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<div class="spacer"></div>
|
||||||
|
|
||||||
|
<h2>About Us</h2>
|
||||||
|
<p>Link to the /about page</p>
|
||||||
|
|
||||||
|
<style lang="scss">
|
||||||
|
.spacer {
|
||||||
|
height: 50px;
|
||||||
|
}
|
||||||
|
</style>
|
|
@ -1,22 +1,22 @@
|
||||||
import { wrap } from "svelte-spa-router/wrap";
|
import { wrap } from "svelte-spa-router/wrap";
|
||||||
import PageLoading from "./routes/PageLoading.svelte";
|
import PageLoading from "%/pages/PageLoading.svelte";
|
||||||
import Page404 from "./routes/Page404.svelte";
|
import Page404 from "%/pages/Page404.svelte";
|
||||||
|
|
||||||
const routes = {
|
const routes = {
|
||||||
"/": wrap({
|
"/": wrap({
|
||||||
asyncComponent: () => import("./routes/PageIndex.svelte"),
|
asyncComponent: () => import("%/pages/index/PageIndex.svelte"),
|
||||||
loadingComponent: PageLoading,
|
loadingComponent: PageLoading,
|
||||||
conditions: [],
|
conditions: [],
|
||||||
userData: { showNavBar: true },
|
userData: { showNavBar: true },
|
||||||
}),
|
}),
|
||||||
"/contact": wrap({
|
"/contact": wrap({
|
||||||
asyncComponent: () => import("./routes/PageContact.svelte"),
|
asyncComponent: () => import("%/pages/PageContact.svelte"),
|
||||||
loadingComponent: PageLoading,
|
loadingComponent: PageLoading,
|
||||||
conditions: [],
|
conditions: [],
|
||||||
userData: { showNavBar: true },
|
userData: { showNavBar: true },
|
||||||
}),
|
}),
|
||||||
"/cart": wrap({
|
"/cart": wrap({
|
||||||
asyncComponent: () => import("./routes/PageShoppingCart.svelte"),
|
asyncComponent: () => import("%/pages/PageShoppingCart.svelte"),
|
||||||
loadingComponent: PageLoading,
|
loadingComponent: PageLoading,
|
||||||
conditions: [],
|
conditions: [],
|
||||||
userData: { showNavBar: true },
|
userData: { showNavBar: true },
|
||||||
|
|
|
@ -1,2 +0,0 @@
|
||||||
<h1>TastyBites reeeee</h1>
|
|
||||||
<p>aurgh</p>
|
|
9
front/src/styles/main.scss
Normal file
9
front/src/styles/main.scss
Normal file
|
@ -0,0 +1,9 @@
|
||||||
|
*, *::before, *::after {
|
||||||
|
box-sizing: border-box;
|
||||||
|
margin: 0;
|
||||||
|
}
|
||||||
|
body, #app {
|
||||||
|
min-height: 100vh;
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
}
|
|
@ -3,5 +3,13 @@ import { svelte } from '@sveltejs/vite-plugin-svelte'
|
||||||
|
|
||||||
// https://vitejs.dev/config/
|
// https://vitejs.dev/config/
|
||||||
export default defineConfig({
|
export default defineConfig({
|
||||||
plugins: [svelte()],
|
plugins: [
|
||||||
|
svelte(),
|
||||||
|
],
|
||||||
|
base: './',
|
||||||
|
resolve: {
|
||||||
|
alias: {
|
||||||
|
'%': __dirname + '/src',
|
||||||
|
}
|
||||||
|
},
|
||||||
})
|
})
|
||||||
|
|
Loading…
Reference in a new issue