Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

init: add skip-to-main-content shortcut #7390

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open
Changes from 1 commit
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
20 changes: 19 additions & 1 deletion apps/site/components/withNavBar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,26 +3,44 @@
import { useLocale } from 'next-intl';
import { useTheme } from 'next-themes';
import type { FC } from 'react';
yaten2302 marked this conversation as resolved.
Show resolved Hide resolved
import { useState } from 'react';

import NavBar from '@/components/Containers/NavBar';
import WithBanner from '@/components/withBanner';
import { useSiteNavigation } from '@/hooks';
import { useRouter, usePathname } from '@/navigation.mjs';
import { availableLocales } from '@/next.locales.mjs';

import Button from './Common/Button';

const WithNavBar: FC = () => {
const { navigationItems } = useSiteNavigation();
const { resolvedTheme, setTheme } = useTheme();
const { replace } = useRouter();
const pathname = usePathname();
const [tabPressed, setTabPressed] = useState(false);

const locale = useLocale();

const toggleCurrentTheme = () =>
setTheme(resolvedTheme === 'dark' ? 'light' : 'dark');

const handleTabPress = (event: React.KeyboardEvent<HTMLInputElement>) => {
yaten2302 marked this conversation as resolved.
Show resolved Hide resolved
if (event.key === 'Tab') {
setTabPressed(prev => !prev);
}
};

return (
<div>
<div onKeyDown={handleTabPress}>
<Button
className="${tabPressed ? 'translate-y-0' : '-translate-y-16' !fixed left-0 m-3 -translate-y-16 p-3 transition-all focus:translate-y-0"
yaten2302 marked this conversation as resolved.
Show resolved Hide resolved
aria-hidden={!tabPressed}
href="#main"
>
Skip to main content
yaten2302 marked this conversation as resolved.
Show resolved Hide resolved
</Button>

<WithBanner section="index" />

<NavBar
Expand Down
Loading