add mobile nav

This commit is contained in:
Enrico Bühler 2024-07-01 21:49:17 +02:00
parent ff6b723b11
commit 84dde04352
3 changed files with 128 additions and 65 deletions

View File

@ -38,9 +38,14 @@ export interface Props
extends HTMLAttributes<"button">, extends HTMLAttributes<"button">,
VariantProps<typeof button> {} VariantProps<typeof button> {}
const { variant = "default", size = "default", ...props } = Astro.props; const {
variant = "default",
size = "default",
class: className,
...props
} = Astro.props;
--- ---
<button {...props} class={button({ variant, size })}> <button {...props} class={button({ variant, size, class: className })}>
<slot /> <slot />
</button> </button>

View File

@ -1,8 +1,13 @@
--- ---
import { button } from "../Button.astro"; import Button, { button } from "../Button.astro";
import { Menu } from "lucide-astro";
--- ---
<header id="header" class="fixed top-0 w-full h-[100px] z-50 bg-neutral-accent"> <header id="header" class="fixed top-0 w-full h-[100px] z-50">
<div
class="bg-neutral-accent/90 w-full h-full absolute -z-20 backdrop-blur-lg"
>
</div>
<div <div
class="flex flex-row justify-between h-full w-full max-w-section m-auto p-main" class="flex flex-row justify-between h-full w-full max-w-section m-auto p-main"
> >
@ -11,11 +16,39 @@ import { button } from "../Button.astro";
<h2 class="text-3xl font-extrabold">vspace.one</h2> <h2 class="text-3xl font-extrabold">vspace.one</h2>
</a> </a>
</div> </div>
<div class="flex flex-row gap-2 items-center"> <Button variant="default" class="lg:hidden" id="nav-button">
<Menu />
</Button>
<div
id="nav-mobile"
class="animate-in slide-in-from-top-10 ease-out-quart duration-1000 absolute top-[100px] w-full
bg-neutral p-main left-0 hidden flex flex-col gap-3 -z-30"
>
<a class={button({ variant: "secondary", size: "lg" })} href="/#location" <a class={button({ variant: "secondary", size: "lg" })} href="/#location"
>Standort</a >Standort</a
> >
<a class={button({ variant: "secondary", size: "lg" })} href="/faq">FAQ</a <a
class={button({
variant: "secondary",
size: "lg",
})}
href="/faq">FAQ</a
>
<a class={button({ variant: "primary", size: "lg" })} href="/support"
>Unterstütze uns!</a
>
</div>
<div class="flex flex-row gap-2 items-center max-lg:hidden">
<a class={button({ variant: "secondary", size: "lg" })} href="/#location"
>Standort</a
>
<a
class={button({
variant: "secondary",
size: "lg",
class: "max-md:hidden",
})}
href="/faq">FAQ</a
> >
<a class={button({ variant: "primary", size: "lg" })} href="/support" <a class={button({ variant: "primary", size: "lg" })} href="/support"
>Unterstütze uns!</a >Unterstütze uns!</a
@ -23,3 +56,34 @@ import { button } from "../Button.astro";
</div> </div>
</div> </div>
</header> </header>
<script>
import { animate, spring, stagger } from "motion";
const button = document.getElementById("nav-button")!;
const navMobile = document.getElementById("nav-mobile")!;
const navButtons = navMobile.children;
button.addEventListener("click", () => {
if (navMobile.classList.contains("hidden")) {
animate(
navButtons as unknown as NodeListOf<any>,
{
y: [-30, 0],
scale: [0.8, 1],
opacity: [0, 1],
},
{
easing: spring({
stiffness: 200,
damping: 20,
mass: 1,
}),
delay: stagger(0.1),
},
);
}
navMobile.classList.toggle("hidden");
});
</script>

View File

@ -9,10 +9,11 @@ import "pannellum/build/pannellum.css";
<div <div
id="landing-heading-container" id="landing-heading-container"
style="opacity: 0;" style="opacity: 0;"
class="flex flex-col justify-center items-center gap-2 backdrop-blur-2xl p-card rounded-card ring ring-primary/20" class="flex flex-col justify-center items-center gap-2 backdrop-blur-2xl p-card rounded-card ring ring-primary/20
max-md:w-[90vw]"
> >
<!--h1>vspace.one</h1--> <!--h1>vspace.one</h1-->
<h2 class="text-4xl">Ein Makerspace und Hackerspace</h2> <h2 class="text-4xl text-center">Ein Makerspace und Hackerspace</h2>
<p> <p>
<a class="text-xl" href="/tour">Hier gehts zur virtuellen Space-Tour!</a <a class="text-xl" href="/tour">Hier gehts zur virtuellen Space-Tour!</a
> >
@ -20,7 +21,7 @@ import "pannellum/build/pannellum.css";
</div> </div>
</div> </div>
<div class="w-full h-full"> <div class="w-full h-full">
<div class="w-full h-full" id="pano-bg"></div> <div style="opacity: 0;" class="w-full h-full" id="pano-bg"></div>
<!--little-planet <!--little-planet
width="2400" width="2400"
height="900" height="900"
@ -36,25 +37,27 @@ import "pannellum/build/pannellum.css";
import { animate } from "motion"; import { animate } from "motion";
import { ease } from "@unom/style"; import { ease } from "@unom/style";
const viewer = pannellum.viewer("pano-bg", { const init = () => {
const panoBg = document.getElementById("pano-bg")!;
const viewer = pannellum.viewer(panoBg, {
panorama: "/pic/panorama/maschinenraum_half.jpg", panorama: "/pic/panorama/maschinenraum_half.jpg",
autoLoad: true, autoLoad: true,
showControls: false, showControls: false,
}); });
viewer.setYaw(90, true); viewer.setYaw(90, false);
const animateEntry = () => { const animateEntry = () => {
let scene: any = document.querySelector("little-planet.anim")!;
const landingHeadingContainer = document.querySelector( const landingHeadingContainer = document.querySelector(
"#landing-heading-container", "#landing-heading-container",
)!; )!;
console.log(scene.children); viewer.on("load", () => {
console.log("loaded");
scene.addEventListener("load", () => {
animate( animate(
scene, panoBg,
{ scale: [0.9, 1], opacity: [0, 1] }, { scale: [0.9, 1], opacity: [0, 1] },
{ {
...ease.quint!(1.5).out, ...ease.quint!(1.5).out,
@ -71,33 +74,24 @@ import "pannellum/build/pannellum.css";
animate( animate(
(progress) => { (progress) => {
scene.camera = { viewer.setPitch(progress * 10, false);
lon: -180 + ((progress * 270) % 360), viewer.setYaw(160 + ((progress * 270) % 360), false);
lat: progress * 10, viewer.setHfov(50 + progress * 50, false);
fov: 20 + 50 * progress,
};
}, },
{ {
...ease.quint!(4).inOut, ...ease.quint!(4).inOut,
}, },
); );
/** spring({
stiffness: 10,
damping: 40,
mass: 2,
restSpeed: 0.01,
restDistance: 0.001,
}) */
}); });
}; };
animateEntry(); animateEntry();
};
init();
document.addEventListener("astro:after-swap", () => { document.addEventListener("astro:after-swap", () => {
animateEntry(); init();
}); });
</script> </script>
<script is:inline type="module" src="https://unpkg.com/little-planet@0.5"
></script>
</div> </div>