File tree Expand file tree Collapse file tree 2 files changed +2
-22
lines changed
Expand file tree Collapse file tree 2 files changed +2
-22
lines changed Original file line number Diff line number Diff line change 1- import { type MouseEvent , useCallback } from "react" ;
21import { Box , Container , Flex , NavLink } from "theme-ui" ;
32
43import { Logo } from "./logo" ;
54
65type LinkComponent = React . FC < { href : string ; children : React . ReactNode } > ;
76
87const MenuLink : LinkComponent = ( { href, children } ) => {
9- const goToSection = useCallback (
10- ( e : MouseEvent ) => {
11- e . preventDefault ( ) ;
12-
13- const destinationEl : HTMLElement | null =
14- window . document . querySelector ( href ) ;
15-
16- if ( ! destinationEl ) {
17- return ;
18- }
19-
20- window . scrollTo ( {
21- top : destinationEl . offsetTop ,
22- behavior : "smooth" ,
23- } ) ;
24- } ,
25- [ href ] ,
26- ) ;
27-
288 return (
299 < NavLink
3010 sx = { {
@@ -39,7 +19,6 @@ const MenuLink: LinkComponent = ({ href, children }) => {
3919 } }
4020 mt = { [ "secondary" , 0 ] }
4121 ml = { [ 0 , "secondary" ] }
42- onClick = { goToSection }
4322 href = { href }
4423 >
4524 { children }
@@ -119,7 +98,7 @@ export const Header = () => (
11998 position : "absolute" ,
12099 top : 0 ,
121100 left : 0 ,
122- zIndex : 1 ,
101+ zIndex : 10 ,
123102
124103 width : "100%" ,
125104 } }
Original file line number Diff line number Diff line change @@ -11,6 +11,7 @@ const App = ({ Component, pageProps }: AppProps) => (
1111 styles = { css `
1212 html {
1313 font-size : 62.5% ;
14+ scroll-behavior : smooth;
1415 }
1516 body {
1617 font-size : 2rem ;
You can’t perform that action at this time.
0 commit comments