Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 0 additions & 8 deletions src/components/Hamburger.astro

This file was deleted.

15 changes: 12 additions & 3 deletions src/components/Header.astro
Original file line number Diff line number Diff line change
@@ -1,13 +1,22 @@
---
import Hamburger from "./Hamburger.astro";
import Menu from "./Menu.astro";
import Navigation from "./Navigation.astro";
import ThemeIcon from "./ThemeIcon.astro";
---

<header>
<nav>
<Hamburger />
<ThemeIcon />
<div>
<ThemeIcon />
<Menu />
</div>
<Navigation />
</nav>
</header>

<style>
div {
display: flex;
justify-content: space-between;
}
</style>
6 changes: 6 additions & 0 deletions src/components/Menu.astro
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
---

<button aria-expanded="false" aria-controls="main-menu" class="menu">
Menu
</button>
2 changes: 1 addition & 1 deletion src/components/Navigation.astro
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
---
---
<div class="nav-links">
<div id="main-menu" class="nav-links">
<a href="/">Home</a>
<a href="/about/">About</a>
<a href="/blog/">Blog</a>
Expand Down
4 changes: 2 additions & 2 deletions src/components/ThemeIcon.astro
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@

---

<button id="themeToggle">
<svg width="30px" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24">
<button id="themeToggle" aria-label="Toggle theme">
<svg aria-hidden="true" width="30px" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24">
<path
class="sun"
fill-rule="evenodd"
Expand Down
2 changes: 1 addition & 1 deletion src/pages/about.astro
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ const identity = {
const skills = ["HTML", "CSS", "JavaScript", "React", "Astro", "Writing Docs"];
const skillColor = "navy";
const skillColor = "crimson";
Copy link
Member

@sarah11918 sarah11918 Aug 28, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just noting that we had a longer discussion on Discord about the fact that navy was practically imperceptible on the dark background.

We updated this colour to fulfill (some admittedly arbitrary) requirements:

  • use a "named" colour (to keep the explanations and discussions around this colour simple)
  • be accessible in light mode (to avoid an anti-pattern)
  • be easily perceptible in dark mode, even if not fully accessible (see following explanation)

Reasons that we chose to sacrifice meeting accessibility requirements in dark mode:

  • meeting the first two requirements listed above
  • introducing dark mode is the very last lesson before the end of the tutorial (some may not go back and check, some may not care by this point)
  • we will use this as a "teachable moment" - this lesson focuses on creating the functionality of theme toggling, but can also include guidance re: unintended consequences, always checking your site to see how you've changed it. etc. When we update the lesson on building the theme toggle, we introduce some .dark only CSS rules. We will further include guidance something like:

When you update your site to include dark mode, some colors used may need updating. Always check your rendered site when adding new styles and colors, and make adjustments when necessary! This can mean adding more .dark CSS style rules to display different styles in dark mode, or you may wish to update some colors so that they work equally well in both themes.

Consider using accessibility tools such as a [contrast checker](insert your fave here) when creating a set of colors for your site, or running a check on your website, for example with a browser extension, to spot any potential issues.

We can even have updating this skillColor variable for dark mode be a "Try it yourself" extension exercise, if we want to further emphasize checking and updating your site after introducing a new theme.

const fontWeight = "bold";
const textCase = "uppercase";
---
Expand Down
7 changes: 5 additions & 2 deletions src/scripts/menu.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
document.querySelector('.hamburger').addEventListener('click', () => {
document.querySelector('.nav-links').classList.toggle('expanded');
const menu = document.querySelector('.menu')

menu.addEventListener('click', () => {
const isExpanded = menu.getAttribute('aria-expanded') === 'true';
menu.setAttribute('aria-expanded', !isExpanded);
});
39 changes: 24 additions & 15 deletions src/styles/global.css
Original file line number Diff line number Diff line change
Expand Up @@ -22,24 +22,18 @@ h1 {

/* nav styles */

.hamburger {
padding-right: 20px;
cursor: pointer;
.menu {
background-color: #0d0950;
border: none;
color: #fff;
font-size: 1.2rem;
font-weight: bold;
padding: 5px 10px;
}

.hamburger .line {
display: block;
width: 40px;
height: 5px;
margin-bottom: 10px;
background-color: #ff9776;
}

.nav-links {
width: 100%;
top: 5rem;
left: 48px;
background-color: #ff9776;
display: none;
margin: 0;
}
Expand All @@ -52,14 +46,15 @@ h1 {
font-size: 1.2rem;
font-weight: bold;
text-transform: uppercase;
color: #0d0950;
}

.nav-links a:hover,
.nav-links a:focus {
background-color: #ff9776;
}

.expanded {
:has(.menu[aria-expanded="true"]) .nav-links {
display: unset;
}

Expand All @@ -77,7 +72,7 @@ h1 {
padding: 15px 20px;
}

.hamburger {
.menu {
display: none;
}
}
Expand All @@ -87,6 +82,20 @@ html.dark {
color: #fff;
}

.dark .menu {
background-color: #fff;
color: #000;
}

.dark .nav-links a:hover,
.dark .nav-links a:focus {
color: #0d0950;
}

.dark .nav-links a {
color: #fff;
}

.dark a {
color: #ff9776;
}