Connect, collaborate, and grow with a community of TypeScript developers
1220 skip to code editor (#1251)
Junsu Park123bca5b601e
diff --git a/apps/web/src/components/Navigation/index.tsx b/apps/web/src/components/Navigation/index.tsxindex 75a25215..85be64b6 100644--- a/apps/web/src/components/Navigation/index.tsx+++ b/apps/web/src/components/Navigation/index.tsx@@ -14,6 +14,7 @@ import { ThemeButton } from './theme-button';import { NavWrapper } from './nav-wrapper';import { LoginLink } from './login-link';import { SignOutLink } from './signout-link';+import { SkipToCodeEditor } from './skip-to-code-editor';import { getScopedI18n } from '~/locales/server';import { MobileNav } from './mobile-nav';import { NavLink } from './nav-link';@@ -53,6 +54,7 @@ export async function Navigation() {<NavWrapper><div className="flex w-full items-center justify-between"><div className="relative flex items-center gap-3">+ <SkipToCodeEditor /><Link className="flex space-x-1.5 focus:outline-none focus-visible:ring-2" href="/"><svgxmlns="http://www.w3.org/2000/svg"diff --git a/apps/web/src/components/Navigation/skip-to-code-editor.tsx b/apps/web/src/components/Navigation/skip-to-code-editor.tsxnew file mode 100644index 00000000..ec7419e9--- /dev/null+++ b/apps/web/src/components/Navigation/skip-to-code-editor.tsx@@ -0,0 +1,16 @@+'use client';+import { usePathname } from 'next/navigation';++export const SkipToCodeEditor = () => {+ const pathname = usePathname();++ if (!pathname.includes('challenge')) {+ return null;+ }++ return (+ <a href="#code-editor" className="sr-only focus:static focus:h-auto focus:w-auto">+ Skip to code editor+ </a>+ );+};diff --git a/packages/monaco/src/split-editor.tsx b/packages/monaco/src/split-editor.tsxindex c6547a4c..6cedd79b 100644--- a/packages/monaco/src/split-editor.tsx+++ b/packages/monaco/src/split-editor.tsx@@ -290,7 +290,11 @@ export default function SplitEditor({return (<div className={clsx('flex h-[calc(100%-_90px)] flex-col', className)} ref={wrapper}>- <section className="h-full overflow-hidden">+ <section+ id="code-editor"+ tabIndex={-1}+ className="h-full overflow-hidden focus:border focus:border-blue-500"+ ><CodeEditorclassName="overflow-hidden"height={userEditorState && settings.bindings === 'vim' ? 'calc(100% - 36px)' : '100%'}