heroweb/examples/images/index.html

101 lines
3.9 KiB
HTML
Raw Normal View History

2024-10-31 06:24:12 +00:00
<!DOCTYPE html>
<html lang="en" data-theme="dark">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>OurWorld</title>
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@picocss/pico@2.0.6/css/pico.min.css">
<link rel="stylesheet" href="home.css">
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/unpoly@3.9.2/unpoly.min.css">
<script defer src="https://unpkg.com/alpinejs@3.x.x/dist/cdn.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/unpoly@3.9.2/unpoly.min.js"></script>
</head>
<body x-data="{
images: [],
currentImageIndex: null,
menuStates: {
about: false,
work: false,
contact: false
},
async init() {
const response = await fetch('data.json');
const data = await response.json();
this.images = data.images;
this.currentImageIndex = Math.floor(Math.random() * this.images.length);
this.$nextTick(() => {
this.startImageAnimation();
});
},
getRandomIndex() {
let newIndex;
do {
newIndex = Math.floor(Math.random() * this.images.length);
} while (newIndex === this.currentImageIndex && this.images.length > 1);
return newIndex;
},
startImageAnimation() {
const img = document.querySelector('.hero img');
img.classList.add('zooming');
img.addEventListener('animationend', () => {
img.classList.add('fade-out');
setTimeout(() => {
this.currentImageIndex = this.getRandomIndex();
img.classList.remove('zooming', 'fade-out');
setTimeout(() => {
img.classList.add('zooming');
}, 50);
}, 1000);
});
},
toggleSubmenu(menu) {
this.menuStates[menu] = !this.menuStates[menu];
Object.keys(this.menuStates).forEach(key => {
if (key !== menu) this.menuStates[key] = false;
});
}
}">
<div class="nav-container">
<nav>
<a href="#" class="logo">Project Mycelium</a>
<div class="nav-links">
<div class="nav-item" @click="toggleSubmenu('about')" @click.away="menuStates.about = false">
About
<div class="submenu" :class="{ 'active': menuStates.about }">
<a href="#our-story">Our Story</a>
<a href="#mission">Mission</a>
<a href="#team">Team</a>
</div>
</div>
<div class="nav-item" @click="toggleSubmenu('work')" @click.away="menuStates.work = false">
Projects
<div class="submenu" :class="{ 'active': menuStates.work }">
<a href="#projects">Projects</a>
<a href="#case-studies">Case Studies</a>
<a href="#impact">Impact</a>
</div>
</div>
<div class="nav-item" @click="toggleSubmenu('contact')" @click.away="menuStates.contact = false">
Contact
<div class="submenu" :class="{ 'active': menuStates.contact }">
<a href="#get-in-touch">Get in Touch</a>
<a href="#locations">Locations</a>
<a href="#careers">Join us.</a>
</div>
</div>
</div>
</nav>
</div>
<section class="hero">
<img :src="images[currentImageIndex]?.url" :alt="images[currentImageIndex]?.alt">
<div class="hero-content">
<h1>We Are <br>The Unconventional Ones</h1>
<p class="lead">The ones called crazy are the only ones truly sane in a world gone mad...</p>
</div>
</section>
</body>
</html>