Skip to content

Commit 1d4061a

Browse files
added accessibility and improved font performance
1 parent 296bbbf commit 1d4061a

3 files changed

Lines changed: 68 additions & 53 deletions

File tree

src/components/projects/Project.astro

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,12 +55,12 @@ const leftProject = position == "left";
5555
class:list={leftProject
5656
? "left"
5757
: "right"}
58-
width="700"
58+
width={700}
5959
/>
6060
<Image
6161
src={image}
6262
alt={alt}
63-
width="700"
63+
width={700}
6464
class={`absolute max-w-full
6565
aspect-video
6666
opacity-100

src/components/ui/NavigationBar.tsx

Lines changed: 62 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -132,54 +132,64 @@ export const HoverNavigation = ({
132132
</div>
133133
</motion.div>
134134
</div>
135-
<motion.div
136-
animate={{
137-
width: navVisible ? "auto" : "0px",
138-
opacity: navVisible ? "100%" : "0%",
139-
}}
140-
transition={{
141-
ease: "easeInOut",
142-
}}
143-
className={cn(
144-
"hidden w-0 flex-row items-center justify-center overflow-hidden lg:flex lg:w-auto",
145-
className,
146-
)}
135+
<nav
136+
aria-label="Desktop Navigation"
137+
className="flex items-center justify-center overflow-hidden"
147138
>
148-
{items.map((item, idx) => (
149-
<a
150-
href={item?.link}
151-
key={item?.link}
152-
className="group relative block h-fit px-5 py-2"
153-
onMouseEnter={() => setHoveredIndex(idx)}
154-
onMouseLeave={() => setHoveredIndex(null)}
155-
>
156-
<AnimatePresence>
157-
{hoveredIndex === idx && (
158-
<motion.span
159-
className="absolute inset-0 block h-full w-full rounded-3xl bg-neutral-200"
160-
layoutId="hoverBackground"
161-
initial={{ opacity: 0 }}
162-
animate={{
163-
opacity: 1,
164-
transition: { duration: 0.15 },
165-
}}
166-
exit={{
167-
opacity: 0,
168-
transition: {
169-
duration: 0.15,
170-
delay: 0.2,
171-
},
172-
}}
173-
/>
174-
)}
175-
</AnimatePresence>
176-
<NavBarLink>{item.label}</NavBarLink>
177-
</a>
178-
))}
179-
</motion.div>
139+
<motion.ul
140+
className="hidden w-0 flex-row items-center justify-center overflow-hidden lg:flex lg:w-auto"
141+
animate={{
142+
width: navVisible ? "auto" : "0px",
143+
opacity: navVisible ? "100%" : "0%",
144+
}}
145+
transition={{
146+
ease: "easeInOut",
147+
}}
148+
>
149+
{items.map((item, idx) => (
150+
<li key={item?.link}>
151+
<a
152+
href={item?.link}
153+
className="group relative block h-fit px-5 py-2"
154+
onMouseEnter={() =>
155+
setHoveredIndex(idx)
156+
}
157+
onMouseLeave={() =>
158+
setHoveredIndex(null)
159+
}
160+
>
161+
<AnimatePresence>
162+
{hoveredIndex === idx && (
163+
<motion.span
164+
className="absolute inset-0 block h-full w-full rounded-3xl bg-neutral-200"
165+
layoutId="hoverBackground"
166+
initial={{ opacity: 0 }}
167+
animate={{
168+
opacity: 1,
169+
transition: {
170+
duration: 0.15,
171+
},
172+
}}
173+
exit={{
174+
opacity: 0,
175+
transition: {
176+
duration: 0.15,
177+
delay: 0.2,
178+
},
179+
}}
180+
/>
181+
)}
182+
</AnimatePresence>
183+
<NavBarLink>{item.label}</NavBarLink>
184+
</a>
185+
</li>
186+
))}
187+
</motion.ul>
188+
</nav>
180189

181190
<div className="hamburger-wrapper flex items-center justify-center lg:hidden">
182191
<HamburgerCross
192+
aria-label="Hamburger"
183193
toggled={hamburgerOpen}
184194
toggle={setHamburgerOpen}
185195
size={20}
@@ -200,13 +210,14 @@ export const HoverNavigation = ({
200210
className="h-0 overflow-hidden"
201211
>
202212
{items.map((item, idx) => (
203-
<a
204-
href={item?.link}
205-
key={item?.link}
206-
className="group relative block px-5 py-2 text-center lg:hidden"
207-
>
208-
{item.label}
209-
</a>
213+
<li key={item?.link}>
214+
<a
215+
href={item?.link}
216+
className="group relative block px-5 py-2 text-center lg:hidden"
217+
>
218+
{item.label}
219+
</a>
220+
</li>
210221
))}
211222
</motion.ul>
212223
</div>

src/layouts/Layout.astro

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,13 +48,15 @@ import { ClientRouter } from "astro:transitions";
4848
src: url("/fonts/Fredoka-Regular.ttf") format("truetype");
4949
font-weight: normal;
5050
font-style: normal;
51+
font-display: swap;
5152
}
5253

5354
@font-face {
5455
font-family: "Antonio";
5556
src: url("/fonts/Antonio-Bold.ttf") format("truetype");
5657
font-weight: bold;
5758
font-style: normal;
59+
font-display: swap;
5860
}
5961

6062
/* Montserrat Fonts */
@@ -63,13 +65,15 @@ import { ClientRouter } from "astro:transitions";
6365
src: url("/fonts/Montserrat-Bold.ttf") format("truetype");
6466
font-weight: bold;
6567
font-style: normal;
68+
font-display: swap;
6669
}
6770

6871
@font-face {
6972
font-family: "Montserrat";
7073
src: url("/fonts/Montserrat-Regular.ttf") format("truetype");
7174
font-weight: normal;
7275
font-style: normal;
76+
font-display: swap;
7377
}
7478

7579
html {

0 commit comments

Comments
 (0)