Skip to content

Commit 047817f

Browse files
committed
fix: update and implement SkipLink component
1 parent 39cf310 commit 047817f

File tree

3 files changed

+11
-11
lines changed

3 files changed

+11
-11
lines changed

src/components/MainArticle.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import { Box, type BoxProps } from "@chakra-ui/react"
33
import { MAIN_CONTENT_ID } from "@/lib/constants"
44

55
const MainArticle = (props: BoxProps) => (
6-
<Box as="article" id={MAIN_CONTENT_ID} tabIndex={-1} {...props} />
6+
<Box as="article" id={MAIN_CONTENT_ID} scrollMarginTop={24} {...props} />
77
)
88

99
export default MainArticle

src/components/SkipLink.tsx

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,16 @@
1-
import React from "react"
1+
import { useTranslation } from "next-i18next"
22
import { Box } from "@chakra-ui/react"
33

4-
import { BaseLink } from "../components/Link"
4+
import { BaseLink } from "@/components/Link"
55

6-
import Translation from "./Translation"
6+
import { MAIN_CONTENT_ID } from "@/lib/constants"
77

8-
export interface IProps {
9-
hrefId: string
10-
}
11-
12-
export const SkipLink: React.FC<IProps> = ({ hrefId }) => {
8+
export const SkipLink = () => {
9+
const { t } = useTranslation()
1310
return (
1411
<Box bg="primary.base">
1512
<BaseLink
16-
href={hrefId}
13+
href={"#" + MAIN_CONTENT_ID}
1714
lineHeight="taller"
1815
position="absolute"
1916
top="-12"
@@ -23,7 +20,7 @@ export const SkipLink: React.FC<IProps> = ({ hrefId }) => {
2320
_hover={{ textDecoration: "none" }}
2421
_focus={{ position: "static" }}
2522
>
26-
<Translation id="skip-to-main-content" />
23+
{t("skip-to-main-content")}
2724
</BaseLink>
2825
</Box>
2926
)

src/layouts/RootLayout.tsx

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import type { Root } from "@/lib/types"
88
import FeedbackWidget from "@/components/FeedbackWidget"
99
import Footer from "@/components/Footer"
1010
import Nav from "@/components/Nav"
11+
import { SkipLink } from "@/components/SkipLink"
1112
import TranslationBanner from "@/components/TranslationBanner"
1213
import TranslationBannerLegal from "@/components/TranslationBannerLegal"
1314

@@ -47,6 +48,8 @@ export const RootLayout = ({
4748

4849
return (
4950
<Container mx="auto" maxW={oldTheme.variables.maxPageWidth}>
51+
<SkipLink />
52+
5053
<Nav path={asPath} />
5154

5255
<TranslationBanner

0 commit comments

Comments
 (0)