Add slider menu and subpages

This commit is contained in:
Filip Krumpe 2022-01-10 22:32:31 +01:00
parent db91d91d05
commit 8308049a90
12 changed files with 159 additions and 5 deletions

View File

@ -19,5 +19,8 @@
"prettier-plugin-svelte": "^2.4.0",
"svelte": "^3.44.0"
},
"type": "module"
"type": "module",
"dependencies": {
"@sveltejs/adapter-static": "^1.0.0-next.25"
}
}

View File

@ -5,6 +5,7 @@
<meta name="description" content="" />
<link rel="icon" href="%svelte.assets%/favicon.png" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<link href="https://unpkg.com/tailwindcss@^1.0/dist/tailwind.min.css" rel="stylesheet"/>
%svelte.head%
</head>
<body>

View File

@ -0,0 +1,15 @@
<main class="p-4 text-gray-300">
<svg height="100%" width="100%">
<line x1=0 y1=4 x2=400 y2=4/>
<line x1=0 y1=34 x2=200 y2=34/>
<line x1=0 y1=64 x2=300 y2=64/>
<line x1=0 y1=94 x2=280 y2=94/>
</svg>
</main>
<style>
svg line {
stroke: currentColor;
stroke-width: 12;
}
</style>

View File

@ -0,0 +1,25 @@
<script>
import Navbar from "./menu/_Navbar.svelte";
import Sidebar from "./menu/_Sidebar.svelte";
let open = false;
</script>
<main class="w-full h-full">
<Sidebar bind:open/>
<Navbar bind:sidebar={open}/>
<slot></slot>
</main>
<style>
:global(body) {
padding: 0;
}
@media (min-width: 640px) {
main {
max-width: none;
}
}
</style>

View File

@ -0,0 +1,6 @@
<svelte:head>
<title>About</title>
</svelte:head>
<h1>About this site</h1>
<p>TODO ...</p>

View File

@ -1,2 +1,12 @@
<script>
import Main from "./_Main.svelte";
export let name = "Test 2";
</script>
<main class="w-full h-full">
<h1>Welcome to SvelteKit</h1>
<p>Visit <a href="https://kit.svelte.dev">kit.svelte.dev</a> to read the documentation</p>
<Main name={name} />
</main>

View File

@ -0,0 +1,44 @@
<script>
export let open = false
</script>
<button class="text-gray-500 hover:text-gray-700 cursor-pointer mr-4 border-none focus:outline-none" class:open on:click={() => open = !open}>
<svg width=32 height=24>
<line id="top" x1=0 y1=2 x2=32 y2=2/>
<line id="middle" x1=0 y1=12 x2=24 y2=12/>
<line id="bottom" x1=0 y1=22 x2=32 y2=22/>
</svg>
</button>
<style>
svg {
min-height: 24px;
transition: transform 0.3s ease-in-out;
}
svg line {
stroke: currentColor;
stroke-width: 3;
transition: transform 0.3s ease-in-out
}
button {
z-index: 20;
}
.open svg {
transform: scale(0.7)
}
.open #top {
transform: translate(6px, 0px) rotate(45deg)
}
.open #middle {
opacity: 0;
}
.open #bottom {
transform: translate(-12px, 9px) rotate(-45deg)
}
</style>

View File

@ -0,0 +1,9 @@
<svg width=auto height=30>
<text x=0 y=20>ACME</text>
</svg>
<style>
text {
fill: currentColor
}
</style>

After

Width:  |  Height:  |  Size: 111 B

View File

@ -0,0 +1,4 @@
<nav class="hidden text-gray-500 uppercase text-bold sm:block">
<a href="/" class="hover:text-gray-700 hover:no-underline">Home</a>
<a href="/about" class="hover:text-gray-700 hover:no-underline">About</a>
</nav>

View File

@ -0,0 +1,16 @@
<script>
import Logo from './_Logo.svelte';
import Hamburger from './_Hamburger.svelte';
import Menu from './_Menu.svelte';
export let sidebar = false;
</script>
<header class="flex justify-between bg-gray-200 p-2 items-center text-gray-600 border-b-2">
<nav class="flex">
<Hamburger bind:open={sidebar}/>
<Logo/>
</nav>
<Menu/>
</header>

View File

@ -0,0 +1,21 @@
<script>
export let open = false
</script>
<aside class="absolute w-full h-full bg-gray-200 border-r-2 shadow-lg" class:open>
<nav class="p-12 text-xl">
<a class="block" href="/">Home</a>
<a class="block" href="/about">About</a>
</nav>
</aside>
<style>
aside {
left: -100%;
transition: left 0.3s ease-in-out
}
.open {
left: 0
}
</style>

View File

@ -1,4 +1,4 @@
import adapter from '@sveltejs/adapter-auto';
import adapter from '@sveltejs/adapter-static';
/** @type {import('@sveltejs/kit').Config} */
const config = {