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
3 changes: 3 additions & 0 deletions apps/site/components/withNavBar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import LanguageDropdown from '@node-core/ui-components/Common/LanguageDropDown';
import Skeleton from '@node-core/ui-components/Common/Skeleton';
import SkipToContentButton from '@node-core/ui-components/Common/SkipToContentButton';
import NavBar from '@node-core/ui-components/Containers/NavBar';
// TODO(@AvivKeller): I don't like that we are importing styles from another module
import styles from '@node-core/ui-components/Containers/NavBar/index.module.css';
Expand Down Expand Up @@ -55,6 +56,8 @@ const WithNavBar: FC = () => {
<div>
<WithBanner section="index" />

<SkipToContentButton label={t('components.common.skipToContent')} />

<NavBar
navItems={navigationItems.map(([, { label, link, target }]) => ({
link,
Expand Down
4 changes: 3 additions & 1 deletion apps/site/layouts/About.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,9 @@ const AboutLayout: FC<PropsWithChildren> = ({ children }) => (
<WithSidebar navKeys={['about', 'getInvolved']} />

<div>
<main>{children}</main>
<main id="main" tabIndex={-1}>
{children}
</main>

<WithMetaBar />
</div>
Expand Down
4 changes: 3 additions & 1 deletion apps/site/layouts/ArticlePage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,9 @@ const ArticlePageLayout: FC<PropsWithChildren> = ({ children }) => (
<WithSidebar navKeys={[]} />

<div>
<main>{children}</main>
<main id="main" tabIndex={-1}>
{children}
</main>

<WithMetaBar />
</div>
Expand Down
2 changes: 1 addition & 1 deletion apps/site/layouts/Blog.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ const BlogLayout: FC = () => {
<WithNavBar />

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

<WithBlogCategories
Expand Down
4 changes: 3 additions & 1 deletion apps/site/layouts/Default.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,9 @@ const DefaultLayout: FC<PropsWithChildren> = ({ children }) => (
<WithSidebar navKeys={[]} />

<div>
<main>{children}</main>
<main id="main" tabIndex={-1}>
{children}
</main>
</div>
</Article>

Expand Down
2 changes: 1 addition & 1 deletion apps/site/layouts/Download.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ const DownloadLayout: FC<PropsWithChildren> = async ({ children }) => {
<WithNavBar />

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

<WithDownloadSection releases={releases}>
Expand Down
4 changes: 3 additions & 1 deletion apps/site/layouts/DownloadArchive.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,9 @@ const DownloadArchiveLayout: FC<PropsWithChildren> = ({ children }) => (
<WithNavBar />

<div className={styles.downloadLayout}>
<main>{children}</main>
<main id="main" tabIndex={-1}>
{children}
</main>
</div>

<WithFooter />
Expand Down
2 changes: 2 additions & 0 deletions apps/site/layouts/GlowingBackdrop.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ const GlowingBackdropLayout: FC<
<GlowingBackdrop />

<main
id="main"
tabIndex={-1}
className={classNames({
[styles.homeLayout]: kind === 'home',
})}
Expand Down
2 changes: 1 addition & 1 deletion apps/site/layouts/Learn.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ const LearnLayout: FC<PropsWithChildren> = ({ children }) => (
<WithSideBar navKeys={['learn']} />

<div>
<main>
<main id="main" tabIndex={-1}>
{children}

<WithSidebarCrossLinks navKey="learn" />
Expand Down
2 changes: 1 addition & 1 deletion apps/site/layouts/Post.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ const PostLayout: FC<PropsWithChildren> = ({ children }) => {

<div className={styles.contentLayout}>
<div className={styles.postLayout}>
<main>
<main id="main" tabIndex={-1}>
{type === 'vulnerability' && <EOLAlert />}

<h1>{frontmatter.title}</h1>
Expand Down
3 changes: 2 additions & 1 deletion packages/i18n/src/locales/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -268,7 +268,8 @@
"themeToggle": {
"light": "Switch to Light Mode",
"dark": "Switch to Dark Mode"
}
},
"skipToContent": "Skip to content"
},
"metabar": {
"lastUpdated": "Last Updated",
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import { describe, it } from 'node:test';
import assert from 'node:assert/strict';

import { render, screen } from '@testing-library/react';

import SkipToContentButton from '../';

describe('SkipToContentButton', () => {
it('renders with correct label', () => {
render(<SkipToContentButton label="Skip to content" />);
const link = screen.getByRole('link', { name: 'Skip to content' });
assert.ok(link);
});
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
@reference "../../styles/index.css";

.skipToContent {
@apply sr-only
focus:not-sr-only
focus:absolute
focus:top-4
focus:left-4
focus:z-50
focus:rounded
focus:bg-green-600
focus:px-4
focus:py-2
focus:text-white
focus:ring-2
focus:ring-green-500
focus:outline-none
dark:focus:ring-green-400;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import SkipToContentButton from '#ui/Common/SkipToContentButton';

import type { Meta as MetaObj, StoryObj } from '@storybook/react-webpack5';

type Story = StoryObj<typeof SkipToContentButton>;
type Meta = MetaObj<typeof SkipToContentButton>;

export const Default: Story = {
args: {
label: 'Skip to content',
},
};

export default { component: SkipToContentButton } as Meta;
21 changes: 21 additions & 0 deletions packages/ui-components/src/Common/SkipToContentButton/index.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import type { FC, AnchorHTMLAttributes } from 'react';

import styles from './index.module.css';

type SkipToContentButtonProps = AnchorHTMLAttributes<HTMLAnchorElement> & {
label: string;
};

const SkipToContentButton: FC<SkipToContentButtonProps> = ({
label,
href = '#main',
...props
}) => {
return (
<a href={href} className={styles.skipToContent} {...props}>
{label}
</a>
);
};

export default SkipToContentButton;