Skip to content

Commit

Permalink
Merge pull request #14 from 1xINTERNET/feature/8-Create-hero-component
Browse files Browse the repository at this point in the history
#8: Hero component
  • Loading branch information
john1xi authored Jun 19, 2024
2 parents 4a2d64b + 77dba17 commit 357bc29
Show file tree
Hide file tree
Showing 6 changed files with 58 additions and 2 deletions.
Binary file added public/png/localHeroImage.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
6 changes: 6 additions & 0 deletions src/assets/images/HeroImage.astro
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
import { Image } from "astro:assets";
import localHeroImage from "../../../public/png/localHeroImage.png";
---

<Image class:list={"w-full"} src={localHeroImage} alt="Hero Image" />
24 changes: 24 additions & 0 deletions src/components/Hero.astro
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
---
import HeroImage from "../assets/images/HeroImage.astro";
import NavigationBar from "@components/NavigationBar.astro";
---

<div class="relative w-full h-auto overflow-hidden" id="hero">
<div class="absolute left-0 right-0" id="navbar-container">
<NavigationBar />
</div>
<div
class="w-full max-sm:w-[200%] h-auto max-sm:right-0 max-sm:top-[50%] max-sm:-ml-[100%]"
>
<HeroImage />
</div>
<div
class="absolute text-[white] z-10 left-[10%] max-sm:left-[5%] bottom-[20%] max-sm:bottom-[5%] w-3/4 max-sm:w-5/6"
id="hero-text"
>
<h1>
About <span class="bg-blue">300 million</span> kids worldwide don't have a
football.
</h1>
</div>
</div>
20 changes: 20 additions & 0 deletions src/components/NavigationBar.astro
Original file line number Diff line number Diff line change
Expand Up @@ -62,16 +62,36 @@ import HashtagWhyULoveFootball from "@components/HashtagWhyULoveFootball.astro";
var navBar = document.getElementById("navbar");
var openButton = document.getElementById("open-mobile-menu");
var closeButton = document.getElementById("close-mobile-menu");
var hero = document.getElementById("hero");
var navBar_container = document.getElementById("navbar-container");
var hero_text = document.getElementById("hero-text");
var footer = document.getElementById("footer");
var menuItems = document.querySelectorAll("#navbar li");

if (navBar && openButton && closeButton) {
openButton.addEventListener("click", () => {
navBar?.classList.contains("hidden")
? navBar.classList.remove("hidden")
: navBar?.classList.add("hidden");
hero?.classList.contains("relative")
? hero.classList.remove("relative")
: hero?.classList.add("relative");
navBar_container?.classList.contains("absolute")
? navBar_container.classList.remove("absolute", "left-0", "right-0")
: navBar_container?.classList.add("absolute", "left-0", "right-0");
hero_text?.classList.contains("absolute")
? hero_text.classList.remove("absolute")
: hero_text?.classList.add("absolute");
footer?.classList.contains("hidden")
? footer.classList.remove("hidden")
: footer?.classList.add("hidden");
});
closeButton.addEventListener("click", () => {
navBar?.classList.add("hidden");
hero?.classList.add("relative");
navBar_container?.classList.add("absolute", "left-0", "right-0");
hero_text?.classList.add("absolute");
footer?.classList.remove("hidden");
});
menuItems.forEach((item) =>
item.addEventListener("click", () => {
Expand Down
4 changes: 2 additions & 2 deletions src/layouts/Layout.astro
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
---
import Footer from "@components/Footer.astro";
import NavigationBar from "@components/NavigationBar.astro";
import Hero from "@components/Hero.astro";
interface Props {
title: string;
Expand All @@ -21,7 +21,7 @@ const { title } = Astro.props;
</head>
<body>
<main>
<NavigationBar />
<Hero />
<slot />
<Footer />
</main>
Expand Down
6 changes: 6 additions & 0 deletions src/styles/global.css
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,12 @@
@apply text-[18px] leading-6;
}

@media only screen and (max-width: 768px) {
h1 {
@apply text-[36px] leading-[48px];
}
}

iframe {
@apply aspect-video;
}
Expand Down

0 comments on commit 357bc29

Please sign in to comment.