File tree 6 files changed +58
-38
lines changed
6 files changed +58
-38
lines changed Original file line number Diff line number Diff line change @@ -67,6 +67,7 @@ export const BaseLink = forwardRef(function Link(
67
67
const isPdf = url . isPdf ( href )
68
68
const isExternal = url . isExternal ( href )
69
69
const isInternalPdf = isPdf && ! isExternal
70
+ const isHash = url . isHash ( href )
70
71
71
72
// Get proper download link for internally hosted PDF's & static files (ex: whitepaper)
72
73
// Opens in separate window.
@@ -119,6 +120,27 @@ export const BaseLink = forwardRef(function Link(
119
120
)
120
121
}
121
122
123
+ if ( isHash ) {
124
+ return (
125
+ < ChakraLink
126
+ onClick = { ( e ) => {
127
+ e . stopPropagation ( )
128
+ trackCustomEvent (
129
+ customEventOptions ?? {
130
+ eventCategory : "Link" ,
131
+ eventAction : "Clicked" ,
132
+ eventName : "Clicked on hash link" ,
133
+ eventValue : href ,
134
+ }
135
+ )
136
+ } }
137
+ { ...commonProps }
138
+ >
139
+ { children }
140
+ </ ChakraLink >
141
+ )
142
+ }
143
+
122
144
return (
123
145
< NextLink
124
146
locale = { locale }
Original file line number Diff line number Diff line change @@ -3,7 +3,7 @@ import { Box, type BoxProps } from "@chakra-ui/react"
3
3
import { MAIN_CONTENT_ID } from "@/lib/constants"
4
4
5
5
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 } />
7
7
)
8
8
9
9
export default MainArticle
Original file line number Diff line number Diff line change 1
- import React from "react "
1
+ import { useTranslation } from "next-i18next "
2
2
import { Box } from "@chakra-ui/react"
3
3
4
- import { BaseLink } from ".. /components/Link"
4
+ import { BaseLink } from "@ /components/Link"
5
5
6
- import Translation from "./Translation "
6
+ import { MAIN_CONTENT_ID } from "@/lib/constants "
7
7
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 ( )
13
10
return (
14
11
< Box bg = "primary.base" >
15
12
< BaseLink
16
- href = { hrefId }
13
+ href = { "#" + MAIN_CONTENT_ID }
17
14
lineHeight = "taller"
18
15
position = "absolute"
19
16
top = "-12"
@@ -23,7 +20,7 @@ export const SkipLink: React.FC<IProps> = ({ hrefId }) => {
23
20
_hover = { { textDecoration : "none" } }
24
21
_focus = { { position : "static" } }
25
22
>
26
- < Translation id = "skip-to-main-content" />
23
+ { t ( "skip-to-main-content" ) }
27
24
</ BaseLink >
28
25
</ Box >
29
26
)
Original file line number Diff line number Diff line change @@ -8,6 +8,7 @@ import type { Root } from "@/lib/types"
8
8
import FeedbackWidget from "@/components/FeedbackWidget"
9
9
import Footer from "@/components/Footer"
10
10
import Nav from "@/components/Nav"
11
+ import { SkipLink } from "@/components/SkipLink"
11
12
import TranslationBanner from "@/components/TranslationBanner"
12
13
import TranslationBannerLegal from "@/components/TranslationBannerLegal"
13
14
@@ -47,6 +48,8 @@ export const RootLayout = ({
47
48
48
49
return (
49
50
< Container mx = "auto" maxW = { oldTheme . variables . maxPageWidth } >
51
+ < SkipLink />
52
+
50
53
< Nav path = { asPath } />
51
54
52
55
< TranslationBanner
Original file line number Diff line number Diff line change 7
7
Hide ,
8
8
Icon ,
9
9
ListItem ,
10
- Show ,
11
10
Text ,
12
11
UnorderedList ,
13
12
useToken ,
@@ -179,17 +178,15 @@ export const UseCasesLayout: React.FC<IProps> = ({
179
178
180
179
return (
181
180
< Box position = "relative" width = "full" >
182
- < Show above = { lgBp } >
183
- < BannerNotification shouldShow zIndex = "sticky" >
184
- < Emoji text = ":pencil:" fontSize = "2xl" me = { 4 } flexShrink = { 0 } />
185
- < Text m = { 0 } >
186
- { t ( "template-usecase:template-usecase-banner" ) } { " " }
187
- < InlineLink href = { absoluteEditPath } >
188
- { t ( "template-usecase-edit-link" ) }
189
- </ InlineLink >
190
- </ Text >
191
- </ BannerNotification >
192
- </ Show >
181
+ < BannerNotification shouldShow zIndex = "sticky" hideBelow = { lgBp } >
182
+ < Emoji text = ":pencil:" fontSize = "2xl" me = { 4 } flexShrink = { 0 } />
183
+ < Text m = { 0 } >
184
+ { t ( "template-usecase:template-usecase-banner" ) } { " " }
185
+ < InlineLink href = { absoluteEditPath } >
186
+ { t ( "template-usecase-edit-link" ) }
187
+ </ InlineLink >
188
+ </ Text >
189
+ </ BannerNotification >
193
190
< HeroContainer key = { frontmatter . title } >
194
191
< TitleCard >
195
192
< Emoji fontSize = "4rem" text = { frontmatter . emoji ! } />
@@ -233,21 +230,20 @@ export const UseCasesLayout: React.FC<IProps> = ({
233
230
} }
234
231
/>
235
232
</ HeroContainer >
236
- < Show above = { lgBp } >
237
- < Flex
238
- as = { BaseLink }
239
- to = { "#" + MAIN_CONTENT_ID }
240
- bg = "ednBackground"
241
- justifyContent = "center"
242
- p = { 4 }
243
- width = "full"
244
- _hover = { {
245
- bg : "background.base" ,
246
- } }
247
- >
248
- < Icon as = { MdExpandMore } fontSize = "2xl" color = "secondary" />
249
- </ Flex >
250
- </ Show >
233
+ < Flex
234
+ as = { BaseLink }
235
+ to = { "#" + MAIN_CONTENT_ID }
236
+ bg = "ednBackground"
237
+ justifyContent = "center"
238
+ p = { 4 }
239
+ width = "full"
240
+ _hover = { {
241
+ bg : "background.base" ,
242
+ } }
243
+ hideBelow = { lgBp }
244
+ >
245
+ < Icon as = { MdExpandMore } fontSize = "2xl" color = "secondary" />
246
+ </ Flex >
251
247
< Page >
252
248
{ /* TODO: Switch to `above="lg"` after completion of Chakra Migration */ }
253
249
< LeftNavBar
Original file line number Diff line number Diff line change @@ -33,3 +33,5 @@ export const isHrefActive = (
33
33
? pathname . startsWith ( cleanHref )
34
34
: pathname === cleanHref
35
35
}
36
+
37
+ export const isHash = ( href : string ) : boolean => href . startsWith ( "#" )
You can’t perform that action at this time.
0 commit comments