Skip to content

Commit e02cdef

Browse files
committed
feat(ui): Added Skip To Content
1 parent fcfc7e2 commit e02cdef

File tree

12 files changed

+47
-12
lines changed

12 files changed

+47
-12
lines changed
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
@reference "../styles/index.css";
2+
3+
.skipToContent {
4+
@apply sr-only
5+
focus:not-sr-only
6+
focus:absolute
7+
focus:top-4
8+
focus:left-4
9+
focus:z-50
10+
focus:rounded
11+
focus:bg-green-600
12+
focus:px-4
13+
focus:py-2
14+
focus:text-white
15+
focus:ring-2
16+
focus:ring-green-400
17+
focus:outline-none;
18+
}

apps/site/components/withNavBar.tsx

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import LanguageDropdown from '@node-core/ui-components/Common/LanguageDropDown';
44
import Skeleton from '@node-core/ui-components/Common/Skeleton';
55
import NavBar from '@node-core/ui-components/Containers/NavBar';
66
// TODO(@AvivKeller): I don't like that we are importing styles from another module
7-
import styles from '@node-core/ui-components/Containers/NavBar/index.module.css';
7+
import navBarStyles from '@node-core/ui-components/Containers/NavBar/index.module.css';
88
import GitHubIcon from '@node-core/ui-components/Icons/Social/GitHub';
99
import { availableLocales } from '@node-core/website-i18n';
1010
import dynamic from 'next/dynamic';
@@ -21,12 +21,14 @@ import { useRouter, usePathname } from '#site/navigation.mjs';
2121
import type { SimpleLocaleConfig } from '@node-core/ui-components/types';
2222
import type { FC } from 'react';
2323

24+
import styles from './withNavBar.module.css';
25+
2426
const ThemeToggle = dynamic(
2527
() => import('@node-core/ui-components/Common/ThemeToggle'),
2628
{
2729
ssr: false,
2830
loading: () => (
29-
<Skeleton className={styles.themeToggleSkeleton} loading={true} />
31+
<Skeleton className={navBarStyles.themeToggleSkeleton} loading={true} />
3032
),
3133
}
3234
);
@@ -55,6 +57,10 @@ const WithNavBar: FC = () => {
5557
<div>
5658
<WithBanner section="index" />
5759

60+
<a href="#main" className={styles.skipToContent}>
61+
{t('components.common.skipToContent')}
62+
</a>
63+
5864
<NavBar
5965
navItems={navigationItems.map(([, { label, link, target }]) => ({
6066
link,
@@ -85,7 +91,7 @@ const WithNavBar: FC = () => {
8591
<Link
8692
href="https://github.com/nodejs/node"
8793
aria-label="Node.js Github"
88-
className={styles.ghIconWrapper}
94+
className={navBarStyles.ghIconWrapper}
8995
>
9096
<GitHubIcon />
9197
</Link>

apps/site/layouts/About.tsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,9 @@ const AboutLayout: FC<PropsWithChildren> = ({ children }) => (
1616
<WithSidebar navKeys={['about', 'getInvolved']} />
1717

1818
<div>
19-
<main>{children}</main>
19+
<main id="main" tabIndex={-1}>
20+
{children}
21+
</main>
2022

2123
<WithMetaBar />
2224
</div>

apps/site/layouts/ArticlePage.tsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,9 @@ const ArticlePageLayout: FC<PropsWithChildren> = ({ children }) => (
1515
<WithSidebar navKeys={[]} />
1616

1717
<div>
18-
<main>{children}</main>
18+
<main id="main" tabIndex={-1}>
19+
{children}
20+
</main>
1921

2022
<WithMetaBar />
2123
</div>

apps/site/layouts/Blog.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ const BlogLayout: FC = () => {
5454
<WithNavBar />
5555

5656
<div className={styles.blogLayout}>
57-
<main>
57+
<main id="main" tabIndex={-1}>
5858
<BlogHeader category={blogData.category} />
5959

6060
<WithBlogCategories

apps/site/layouts/Default.tsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,9 @@ const DefaultLayout: FC<PropsWithChildren> = ({ children }) => (
1414
<WithSidebar navKeys={[]} />
1515

1616
<div>
17-
<main>{children}</main>
17+
<main id="main" tabIndex={-1}>
18+
{children}
19+
</main>
1820
</div>
1921
</Article>
2022

apps/site/layouts/Download.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ const DownloadLayout: FC<PropsWithChildren> = async ({ children }) => {
1818
<WithNavBar />
1919

2020
<div className={styles.downloadLayout}>
21-
<main>
21+
<main id="main" tabIndex={-1}>
2222
<h1>{frontmatter.title}</h1>
2323

2424
<WithDownloadSection releases={releases}>

apps/site/layouts/DownloadArchive.tsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,9 @@ const DownloadArchiveLayout: FC<PropsWithChildren> = ({ children }) => (
1010
<WithNavBar />
1111

1212
<div className={styles.downloadLayout}>
13-
<main>{children}</main>
13+
<main id="main" tabIndex={-1}>
14+
{children}
15+
</main>
1416
</div>
1517

1618
<WithFooter />

apps/site/layouts/GlowingBackdrop.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,8 @@ const GlowingBackdropLayout: FC<
2222
<GlowingBackdrop />
2323

2424
<main
25+
id="main"
26+
tabIndex={-1}
2527
className={classNames({
2628
[styles.homeLayout]: kind === 'home',
2729
})}

apps/site/layouts/Learn.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ const LearnLayout: FC<PropsWithChildren> = ({ children }) => (
1717
<WithSideBar navKeys={['learn']} />
1818

1919
<div>
20-
<main>
20+
<main id="main" tabIndex={-1}>
2121
{children}
2222

2323
<WithSidebarCrossLinks navKey="learn" />

0 commit comments

Comments
 (0)