File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -3,6 +3,7 @@ import ThumbnailGrid from '@/components/ThumbnailGrid';
33import Thumbnail from '@/components/Thumbnail' ;
44import Header from '@/components/Header' ;
55import Footer from '@/components/Footer' ;
6+ import ScrollRestore from '@/components/ScrollRestore' ;
67import { getTranslations } from '@/lib/translation' ;
78
89import statuses from '@/lib/statuses' ;
@@ -12,6 +13,7 @@ export default async function Home() {
1213
1314 return (
1415 < >
16+ < ScrollRestore />
1517 < Header t = { t } />
1618 < main >
1719 < Usage t = { t } />
Original file line number Diff line number Diff line change @@ -3,6 +3,7 @@ import ThumbnailGrid from '@/components/ThumbnailGrid';
33import Thumbnail from '@/components/Thumbnail' ;
44import Header from '@/components/Header' ;
55import Footer from '@/components/Footer' ;
6+ import ScrollRestore from '@/components/ScrollRestore' ;
67import { getTranslations } from '@/lib/translation' ;
78
89import statuses from '@/lib/statuses' ;
@@ -12,6 +13,7 @@ export default async function Home() {
1213
1314 return (
1415 < >
16+ < ScrollRestore />
1517 < Header t = { t } />
1618 < main >
1719 < Usage t = { t } />
Original file line number Diff line number Diff line change @@ -21,7 +21,11 @@ export default async function Info({ params }: { params: { status: string } }) {
2121 < Header t = { t } />
2222 < main >
2323 < nav >
24- < Link href = "/" className = "text-white" > { `< ${ t . BACK_TO_HOME } ` } </ Link >
24+ < Link
25+ href = "/"
26+ className = "text-white"
27+ scroll = { false }
28+ > { `< ${ t . BACK_TO_HOME } ` } </ Link >
2529 </ nav >
2630
2731 < h1 className = "text-center my-12" >
Original file line number Diff line number Diff line change 1+ 'use client' ;
2+
3+ import { useEffect } from 'react' ;
4+
5+ const ScrollRestore = ( ) => {
6+ useEffect ( ( ) => {
7+ const savedPosition = sessionStorage . getItem ( 'homeScrollPosition' ) ;
8+ if ( savedPosition ) {
9+ window . scrollTo ( 0 , parseInt ( savedPosition , 10 ) ) ;
10+ sessionStorage . removeItem ( 'homeScrollPosition' ) ;
11+ }
12+ } , [ ] ) ;
13+
14+ return null ;
15+ } ;
16+
17+ export default ScrollRestore ;
Original file line number Diff line number Diff line change 1+ export { default } from './ScrollRestore' ;
Original file line number Diff line number Diff line change 1+ 'use client' ;
2+
13import Link from 'next/link' ;
24import Image from 'next/image' ;
35
@@ -10,10 +12,15 @@ type ThumbnailProps = {
1012const Thumbnail = ( { code, description, t } : ThumbnailProps ) => {
1113 const hrefBase = t . LOCALE === 'ca' ? '/ca' : '' ;
1214
15+ const saveScrollPosition = ( ) => {
16+ sessionStorage . setItem ( 'homeScrollPosition' , window . scrollY . toString ( ) ) ;
17+ } ;
18+
1319 return (
1420 < div id = { `${ code } ` } className = "flex flex-col flex-grow h-full text-white overflow-hidden rounded shadow bg-[--interactive]" >
1521 < Link
1622 href = { `${ hrefBase } /status/${ code } ` }
23+ onClick = { saveScrollPosition }
1724 className = "text-white no-underline"
1825 >
1926 < div className = "pt-[56.25%] relative overflow-hidden" >
You can’t perform that action at this time.
0 commit comments