Skip to content

Commit 9506290

Browse files
committed
Navbar: keyboard accessibility improved
1 parent 51c9982 commit 9506290

File tree

2 files changed

+15
-11
lines changed

2 files changed

+15
-11
lines changed

src/components/BackToTop.tsx

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,13 @@
11
"use client"
22

3+
import * as React from "react"
4+
35
import { ArrowUp } from "lucide-react"
4-
import { useEffect, useState } from "react"
56

67
const BackToTop = () => {
7-
const [isVisible, setIsVisible] = useState(false)
8+
const [isVisible, setIsVisible] = React.useState(false)
89

9-
useEffect(() => {
10+
React.useEffect(() => {
1011
if (typeof window === "undefined") return
1112

1213
const handleScroll = () => {

src/components/Navbar.tsx

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,10 @@
33
import React, { useState } from "react"
44
import Link from "next/link"
55
import { Button } from "@/components/ui/button"
6-
import { Github, Menu, X, Heart } from "lucide-react"
6+
7+
import { Menu, X, Heart } from "lucide-react"
8+
import { FaGithub } from "react-icons/fa6"
9+
710
import StylizedSiteName from "./StylizedSiteName"
811

912
export default function Navbar() {
@@ -22,13 +25,13 @@ export default function Navbar() {
2225
<div className="container mx-auto px-4 sm:px-6 lg:px-8">
2326
<div className="flex h-20 items-center justify-between">
2427
<StylizedSiteName />
25-
<div className="hidden md:block">
26-
<div className="ml-10 flex items-baseline space-x-4">
28+
<div className="hidden md:flex items-center">
29+
<div className="ml-10 flex items-center space-x-4">
2730
{navItems.map((item) => (
2831
<Link
2932
key={item.name}
3033
href={item.path}
31-
className="rounded-md px-3 py-2 text-sm font-medium transition duration-150 ease-in-out hover:bg-neutral-950"
34+
className="rounded-md px-3 py-2 text-sm font-medium transition-colors hover:bg-neutral-900 focus:bg-neutral-900 outline-none"
3235
>
3336
{item.name}
3437
</Link>
@@ -42,15 +45,15 @@ export default function Navbar() {
4245
)
4346
}
4447
variant="outline"
45-
className="flex items-center space-x-2 border border-purple-400 bg-transparent text-purple-400 transition duration-150 ease-in-out hover:bg-purple-400 hover:text-neutral-900"
48+
className="flex items-center space-x-2 border border-purple-400 bg-transparent text-purple-400 transition-colors ease-in-out hover:bg-purple-400 hover:text-neutral-900 focus:bg-purple-400 focus:text-neutral-900"
4649
>
47-
<Github className="size-5" />
50+
<FaGithub className="size-5" />
4851
<span>Star on GitHub</span>
4952
</Button>
5053
<Button
5154
asChild
5255
variant="outline"
53-
className="flex items-center space-x-2 border border-pink-400 bg-transparent text-pink-400 transition duration-150 ease-in-out hover:bg-pink-400 hover:text-neutral-900"
56+
className="flex items-center space-x-2 border border-pink-400 bg-transparent text-pink-400 transition-colors ease-in-out hover:bg-pink-400 hover:text-neutral-900 focus:bg-pink-400 focus:text-neutral-900"
5457
>
5558
<Link href="/sponsor">
5659
<Heart className="size-5" />
@@ -95,7 +98,7 @@ export default function Navbar() {
9598
className="block rounded-md px-3 py-2 text-base font-medium text-purple-400 transition duration-150 ease-in-out hover:bg-neutral-950"
9699
onClick={toggleMenu}
97100
>
98-
<Github className="mr-2 inline-block size-5" />
101+
<FaGithub className="mr-2 inline-block size-5" />
99102
Star on GitHub
100103
</a>
101104
<Link

0 commit comments

Comments
 (0)