Add fancy sliding menu
This commit is contained in:
parent
85bb2ec9f6
commit
1430091143
@ -1,12 +1,24 @@
|
|||||||
<script>
|
<script>
|
||||||
|
import Navbar from "./menu/Navbar.svelte";
|
||||||
|
import Sidebar from "./menu/Sidebar.svelte";
|
||||||
|
|
||||||
export let name;
|
export let name;
|
||||||
|
|
||||||
|
let open = false;
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<main>
|
<main>
|
||||||
|
<Sidebar bind:open/>
|
||||||
|
<Navbar bind:sidebar={open}/>
|
||||||
|
|
||||||
<h1>Hello {name}!</h1>
|
<h1>Hello {name}!</h1>
|
||||||
<p>Visit the <a href="https://svelte.dev/tutorial">Svelte tutorial</a> to learn how to build Svelte apps.</p>
|
<p>Visit the <a href="https://svelte.dev/tutorial">Svelte tutorial</a> to learn how to build Svelte apps.</p>
|
||||||
</main>
|
</main>
|
||||||
|
|
||||||
|
<svelte:head>
|
||||||
|
<link href="https://unpkg.com/tailwindcss@^1.0/dist/tailwind.min.css" rel="stylesheet"/>
|
||||||
|
</svelte:head>
|
||||||
|
|
||||||
<style>
|
<style>
|
||||||
main {
|
main {
|
||||||
text-align: center;
|
text-align: center;
|
||||||
|
|||||||
15
webapp/src/Main.svelte
Normal file
15
webapp/src/Main.svelte
Normal 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>
|
||||||
44
webapp/src/menu/Hamburger.svelte
Normal file
44
webapp/src/menu/Hamburger.svelte
Normal 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>
|
||||||
9
webapp/src/menu/Logo.svelte
Normal file
9
webapp/src/menu/Logo.svelte
Normal 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 |
4
webapp/src/menu/Menu.svelte
Normal file
4
webapp/src/menu/Menu.svelte
Normal file
@ -0,0 +1,4 @@
|
|||||||
|
<nav class="hidden text-gray-500 uppercase text-bold sm:block">
|
||||||
|
<a href="/about" class="hover:text-gray-700 hover:no-underline">About</a>
|
||||||
|
<a href="/contact" class="hover:text-gray-700 hover:no-underline">Contact</a>
|
||||||
|
</nav>
|
||||||
16
webapp/src/menu/Navbar.svelte
Normal file
16
webapp/src/menu/Navbar.svelte
Normal 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>
|
||||||
21
webapp/src/menu/Sidebar.svelte
Normal file
21
webapp/src/menu/Sidebar.svelte
Normal 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="#about">About</a>
|
||||||
|
<a class="block" href="#contact">Contact</a>
|
||||||
|
</nav>
|
||||||
|
</aside>
|
||||||
|
|
||||||
|
<style>
|
||||||
|
aside {
|
||||||
|
left: -100%;
|
||||||
|
transition: left 0.3s ease-in-out
|
||||||
|
}
|
||||||
|
|
||||||
|
.open {
|
||||||
|
left: 0
|
||||||
|
}
|
||||||
|
</style>
|
||||||
Loading…
x
Reference in New Issue
Block a user