Skip to content

Commit c70ada5

Browse files
committed
Improve accessibility and reformat header
1 parent edd2cf9 commit c70ada5

File tree

5 files changed

+45
-29
lines changed

5 files changed

+45
-29
lines changed
4.69 KB
Loading

src/components/navigation/Header.tsx

Lines changed: 14 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -2,40 +2,28 @@ import { ReactNode, useState } from "react";
22
import { useRouter } from "next/router";
33
import Bars3Icon from "@heroicons/react/24/solid/Bars3Icon";
44

5+
import Logo from "@/assets/images/brand/logo-200x200.webp";
6+
57
import Link from "./Link";
68
import Button from "../controls/Button";
9+
import NavLink from "./NavLink";
710

8-
export interface HeaderProps {
9-
10-
}
11-
12-
const NavLink = ({ href, currentHref, children }: {
13-
href: string,
14-
currentHref: string,
15-
children: ReactNode;
16-
}) => {
17-
const active = currentHref === href;
18-
return (
19-
<Link
20-
className="text-lg font-bold py-2 border-y border-primary hover:border-primary-light aria-[current='page']:text-primary-dark aria-[current='page']:border-primary first-of-type:border-t-2 last-of-type:border-b-2 md:border-0 md:first-of-type:border-t-0 md:last-of-type:border-b-0"
21-
aria-current={active ? "page" : undefined}
22-
color="primary"
23-
href={href}
24-
>
25-
{children}
26-
</Link>
27-
);
28-
};
29-
30-
const Header = ({ }: HeaderProps) => {
11+
const Header = () => {
3112
const router = useRouter();
3213

3314
const [open, setOpen] = useState(false);
3415

3516
return (
36-
<header className="relative flex items-center w-full gap-12 px-8 py-4">
37-
<Link color="primary" className="text-2xl font-bold lg:text-4xl" href="/">
38-
Commit Rocket
17+
<header className="relative flex items-center w-full gap-4 p-4 transition-all md:px-8 md:gap-12">
18+
<Link color="primary" className="flex items-center justify-center text-2xl font-bold transition-all lg:text-4xl" href="/">
19+
<img
20+
className="object-contain transition-all text-[0px] w-10 h-10 lg:w-12 lg:h-12"
21+
src={Logo.src}
22+
width={Logo.width}
23+
height={Logo.height}
24+
alt="Commit Rocket Logo"
25+
/>
26+
<span>Commit Rocket</span>
3927
</Link>
4028
<Button color="secondary" className="p-2 ml-auto rounded-full md:hidden" onClick={() => setOpen(!open)}>
4129
<Bars3Icon className="w-6 h-6" />

src/components/navigation/Link.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,14 @@ import { twMerge } from "tailwind-merge";
55

66
import { RequiredKeys } from "@/types/utility";
77

8-
export const style = cva("transition-colors", {
8+
export const style = cva("transition-colors gap-2", {
99
variants: {
1010
underline: {
1111
true: "underline",
1212
false: ""
1313
},
1414
color: {
15+
white: "text-white hover:text-neutral-300",
1516
primary: "text-primary hover:text-primary-light",
1617
secondary: "text-secondary hover:text-secondary-light"
1718
}
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
import { ReactNode } from "react";
2+
import Link from "./Link";
3+
4+
export interface NavLinkProps {
5+
href: string,
6+
currentHref: string,
7+
children: ReactNode;
8+
}
9+
10+
const NavLink = ({ href, currentHref, children }: NavLinkProps) => {
11+
const active = currentHref === href;
12+
return (
13+
<Link
14+
className="text-lg font-bold py-2 border-y border-primary hover:border-primary-light aria-[current='page']:text-primary-dark aria-[current='page']:border-primary first-of-type:border-t-2 last-of-type:border-b-2 md:border-0 md:first-of-type:border-t-0 md:last-of-type:border-b-0"
15+
aria-current={active ? "page" : undefined}
16+
color="primary"
17+
href={href}
18+
>
19+
{children}
20+
</Link>
21+
);
22+
};
23+
24+
25+
export default NavLink

src/pages/index.tsx

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,9 +50,10 @@ const FrontPage: Page = ({ }) => {
5050
<div className="relative flex items-center justify-center w-full min-h-[20rem] max-h-[40dvh] max-h-[40vh] lg:min-h-0 lg:h-full lg:max-h-full lg:w-2/5" style={{ aspectRatio: `${LogoPicture.width} / ${LogoPicture.height}` }}>
5151
<div className="absolute w-full h-full opacity-50 aspect-square bg-gradient-radial from-primary to-transparent" aria-hidden />
5252
<motion.img
53-
className="absolute max-w-full max-h-full object-contain aspect-auto w-full rotate-[10deg]"
53+
className="absolute max-w-full max-h-full object-contain aspect-auto w-full rotate-[10deg] text-[0px]"
5454
loading="eager"
5555
variants={logoAnim}
56+
alt="Commit Rocket"
5657
src={LogoPicture.src}
5758
width={LogoPicture.width}
5859
height={LogoPicture.height}
@@ -76,8 +77,9 @@ const FrontPage: Page = ({ }) => {
7677
{title}
7778
</h3>
7879
<img
79-
className="w-full sm:w-2/3 lg:w-full"
80+
className="w-full sm:w-2/3 lg:w-full text-[0px]"
8081
loading="lazy"
82+
alt="mission"
8183
src={image.src}
8284
width={image.width}
8385
height={image.height}

0 commit comments

Comments
 (0)