Skip to content

Commit 5f58094

Browse files
committed
Adds a skip link to the app layout
1 parent ed51c24 commit 5f58094

File tree

4 files changed

+20
-3
lines changed

4 files changed

+20
-3
lines changed

resources/js/components/app-content.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ export function AppContent({
1616

1717
return (
1818
<main
19+
id="main"
1920
className="mx-auto flex h-full w-full max-w-7xl flex-1 flex-col gap-4 rounded-xl"
2021
{...props}
2122
>
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
export function AppSkipLink() {
2+
return (
3+
<a
4+
href="#main"
5+
className="absolute -top-14 left-4 z-[100] rounded-md bg-black px-4 py-2 text-sm font-semibold text-white shadow-lg transition-all duration-300 ease-in-out focus:top-2 focus:outline-2 focus:ring-primary-500 focus:outline-offset-4 dark:bg-primary dark:text-black dark:focus:outline-sidebar-ring motion-reduce:transition-none"
6+
>
7+
Skip to Main Content
8+
</a>
9+
)
10+
}

resources/js/components/ui/sidebar.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -302,6 +302,7 @@ function SidebarRail({ className, ...props }: React.ComponentProps<"button">) {
302302
function SidebarInset({ className, ...props }: React.ComponentProps<"main">) {
303303
return (
304304
<main
305+
id="main"
305306
data-slot="sidebar-inset"
306307
className={cn(
307308
"bg-background relative flex max-w-full min-h-svh flex-1 flex-col",
Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import AppLayoutTemplate from '@/layouts/app/app-sidebar-layout';
2+
import { AppSkipLink } from '@/components/app-skip-link';
23
import { type BreadcrumbItem } from '@/types';
34
import { type ReactNode } from 'react';
45

@@ -8,7 +9,11 @@ interface AppLayoutProps {
89
}
910

1011
export default ({ children, breadcrumbs, ...props }: AppLayoutProps) => (
11-
<AppLayoutTemplate breadcrumbs={breadcrumbs} {...props}>
12-
{children}
13-
</AppLayoutTemplate>
12+
<>
13+
<AppSkipLink />
14+
15+
<AppLayoutTemplate breadcrumbs={breadcrumbs} {...props}>
16+
{children}
17+
</AppLayoutTemplate>
18+
</>
1419
);

0 commit comments

Comments
 (0)