Skip to content

Commit

Permalink
Merging in dev
Browse files Browse the repository at this point in the history
  • Loading branch information
NickHodges committed Apr 3, 2024
2 parents e876369 + 8030ff2 commit 1702df0
Show file tree
Hide file tree
Showing 6 changed files with 53 additions and 62 deletions.
113 changes: 52 additions & 61 deletions src/components/layout/Header.astro
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ import { menuLinks, siteConfig } from "@/site-config";
import Search from "../Search.astro";
import ThemeToggle from "../ThemeToggle.astro";
import nickImg from "@/assets/nick.png";
import { Image } from "astro:assets";
const url = new URL(Astro.request.url);
---
Expand All @@ -11,50 +13,39 @@ const url = new URL(Astro.request.url);
<div class="flex sm:flex-col">
<a
aria-current={url.pathname === "/" ? "page" : false}
class="inline-flex items-center grayscale hover:filter-none sm:relative sm:inline-block"
class="inline-flex items-center hover:filter-none sm:relative sm:inline-block"
href="/"
>
<svg
aria-hidden="true"
class="me-3 h-10 w-6 sm:absolute sm:start-[-4.5rem] sm:me-0 sm:h-20 sm:w-12"
fill="none"
focusable="false"
viewBox="0 0 272 480"
xmlns="http://www.w3.org/2000/svg"
>
<title>Logo</title>
<path
d="M181.334 93.333v-40L226.667 80v40l-45.333-26.667ZM136.001 53.333 90.667 26.667v426.666L136.001 480V53.333Z"
fill="#B04304"></path>
<path
d="m136.001 119.944 45.333-26.667 45.333 26.667-45.333 26.667-45.333-26.667ZM90.667 26.667 136.001 0l45.333 26.667-45.333 26.666-45.334-26.666ZM181.334 53.277l45.333-26.666L272 53.277l-45.333 26.667-45.333-26.667ZM0 213.277l45.333-26.667 45.334 26.667-45.334 26.667L0 213.277ZM136 239.944l-45.333-26.667v53.333L136 239.944Z"
fill="#FF5D01"></path>
<path
d="m136 53.333 45.333-26.666v120L226.667 120V80L272 53.333V160l-90.667 53.333v240L136 480V306.667L45.334 360V240l45.333-26.667v53.334L136 240V53.333Z"
fill="#53C68C"></path>
<path d="M45.334 240 0 213.334v120L45.334 360V240Z" fill="#B04304"></path>
</svg>
<span class="text-xl font-bold sm:text-2xl">{siteConfig.title}</span>
<Image
src={nickImg}
alt="Logo"
loading="eager"
class="me-3 h-10 w-10 sm:absolute sm:start-[-4.5rem] sm:me-0 sm:h-20 sm:w-20"
/>
<title>Logo</title>
</a>
<nav
aria-label="Main menu"
class="absolute -inset-x-4 top-14 hidden flex-col items-end gap-y-4 rounded-md bg-bgColor/[.85] py-4 text-accent shadow backdrop-blur group-[.menu-open]:z-50 group-[.menu-open]:flex sm:static sm:z-auto sm:-ms-4 sm:mt-1 sm:flex sm:flex-row sm:items-center sm:divide-x sm:divide-dashed sm:divide-accent sm:rounded-none sm:bg-transparent sm:py-0 sm:shadow-none sm:backdrop-blur-none"
id="navigation-menu"
>
{
menuLinks.map((link) => (
<a
aria-current={url.pathname === link.path ? "page" : false}
class="px-4 py-4 sm:py-0 sm:hover:underline"
data-astro-prefetch
href={link.path}
>
{link.title}
</a>
))
}
</nav>
<span class="text-xl font-bold sm:ml-5 sm:text-2xl">{siteConfig.title}</span>
<!-- Added sm:ml-5 for margin-left in the sm: breakpoint -->
</div>
<nav
aria-label="Main menu"
class="absolute -inset-x-4 top-14 hidden flex-col items-end gap-y-4 rounded-md bg-bgColor/[.85] py-4 text-accent shadow backdrop-blur group-[.menu-open]:z-50 group-[.menu-open]:flex sm:static sm:z-auto sm:-ms-4 sm:mt-1 sm:flex sm:flex-row sm:items-center sm:divide-x sm:divide-dashed sm:divide-accent sm:rounded-none sm:bg-transparent sm:py-0 sm:shadow-none sm:backdrop-blur-none"
id="navigation-menu"
>
{
menuLinks.map((link) => (
<a
aria-current={url.pathname === link.path ? "page" : false}
class="px-4 py-4 sm:py-0 sm:hover:underline"
data-astro-prefetch
href={link.path}
>
{link.title}
</a>
))
}
</nav>

<Search />
<ThemeToggle />
<mobile-button>
Expand Down Expand Up @@ -96,31 +87,31 @@ const url = new URL(Astro.request.url);
</svg>
</button>
</mobile-button>
</header>

<script>
import { toggleClass } from "@/utils";
<script>
import { toggleClass } from "@/utils";

class MobileNavBtn extends HTMLElement {
private headerEl: HTMLElement;
private menuOpen: boolean;
private mobileButtonEl: HTMLButtonElement;
class MobileNavBtn extends HTMLElement {
private headerEl: HTMLElement;
private menuOpen: boolean;
private mobileButtonEl: HTMLButtonElement;

toggleMobileMenu = () => {
toggleClass(this.headerEl, "menu-open");
this.menuOpen = !this.menuOpen;
this.mobileButtonEl.setAttribute("aria-expanded", this.menuOpen.toString());
};
toggleMobileMenu = () => {
toggleClass(this.headerEl, "menu-open");
this.menuOpen = !this.menuOpen;
this.mobileButtonEl.setAttribute("aria-expanded", this.menuOpen.toString());
};

constructor() {
super();
this.headerEl = document.getElementById("main-header")!;
this.mobileButtonEl = this.querySelector("button") as HTMLButtonElement;
this.menuOpen = false;
constructor() {
super();
this.headerEl = document.getElementById("main-header")!;
this.mobileButtonEl = this.querySelector("button") as HTMLButtonElement;
this.menuOpen = false;

this.mobileButtonEl.addEventListener("click", this.toggleMobileMenu);
this.mobileButtonEl.addEventListener("click", this.toggleMobileMenu);
}
}
}

customElements.define("mobile-button", MobileNavBtn);
</script>
customElements.define("mobile-button", MobileNavBtn);
</script>
</header>
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
"@/utils": ["src/utils/index.ts"],
"@/types": ["src/types.ts"],
"@/site-config": ["src/site.config.ts"],
"@/pagedata/*": ["src/pages/data/*"]
"@/pagedata/*": ["src/content/data/*"]
}
},
"exclude": ["node_modules", "**/node_modules/*", ".vscode", "dist"]
Expand Down

0 comments on commit 1702df0

Please sign in to comment.