Skip to content
Open
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
7 changes: 6 additions & 1 deletion frontend/src/app/layout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import type { Metadata } from "next";
import { Modak, Nunito } from "next/font/google";

import { CookieGuard } from "@/components/cookie-guard";
import SkipToContentButton from "@/components/skip-to-content-button";
import Header from "@/features/header/components/header";
import ToastListener from "@/features/system-feedback/toast/listener";
import { Providers } from "@/lib/providers";
Expand Down Expand Up @@ -79,13 +80,17 @@ export default async function RootLayout({
>
<body className="font-sans antialiased">
<div className="mx-auto flex min-h-dvh max-w-[1440px] flex-col">
<SkipToContentButton />
<Providers>
<CookieGuard>
<Suspense fallback={null}>
<ToastListener />
</Suspense>
<Header />
{children}
{/* The main content is wrapped to allow skip to content functionality. */}
<div id="main-content" className="outline-hidden">
{children}
</div>
</CookieGuard>
</Providers>
<Analytics />
Expand Down
30 changes: 30 additions & 0 deletions frontend/src/components/skip-to-content-button.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
"use client";

import ActionButton from "@/features/button/components/action";
import { cn } from "@/lib/utils/classname";

export default function SkipToContentButton() {
const handleClick = (e?: React.MouseEvent<HTMLButtonElement>) => {
e?.preventDefault();
const mainContent = document.getElementById("main-content");
if (mainContent) {
mainContent.setAttribute("tabindex", "-1");
mainContent.focus();
}
};

return (
<ActionButton
buttonStyle="frosted glass"
label="Skip to Content"
aria-label="Skip to main content"
className={cn(
"z-200 fixed m-2 w-fit",
"left-1/2 top-0 -translate-x-1/2",
"transition-transform duration-300 ease-in-out",
"translate-y-[-150%] group-focus:translate-y-[0%]",
)}
onClick={handleClick}
/>
);
}
Loading