Skip to content

Commit 9cb9592

Browse files
committed
feat: make footer part of page transitions
Otherwise, the footer would move instantly to its final position before the3 page transition finishes, which is weird.
1 parent f46a55e commit 9cb9592

File tree

4 files changed

+30
-9
lines changed

4 files changed

+30
-9
lines changed
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
@import "../../shared/styles/imports";
22

33
.contacts {
4+
min-height: 200vh; /* Just to simulate scroll */
45
padding: 2.5rem 0;
56
}

www/shared/react/main-layout/MainLayout.js

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,17 @@ const MainLayout = ({ children, className, ...rest }) => (
1212
<Header className={ styles.header } />
1313

1414
<div className={ styles.content }>
15-
<PageSwapper node={ children } nodeKey={ children.key } />
15+
<PageSwapper
16+
node={ children }
17+
nodeKey={ children.key }>
18+
{ ({ node }) => (
19+
<>
20+
<div className={ styles.page }>{ node }</div>
21+
<Footer className={ styles.footer } />
22+
</>
23+
) }
24+
</PageSwapper>
1625
</div>
17-
18-
<Footer className={ styles.footer } />
1926
</div>
2027
);
2128

www/shared/react/main-layout/MainLayout.module.css

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
.mainLayout {
44
min-height: 100%;
55
display: flex;
6-
flex: 1;
6+
flex: 1 0;
77
flex-direction: column;
88
background-color: var(--color-white);
99

@@ -12,10 +12,16 @@
1212
}
1313

1414
& .content {
15+
display: flex;
1516
flex: 1 0;
16-
}
17+
flex-direction: column;
1718

18-
& .footer {
19-
flex: 0 0 auto;
19+
& .page {
20+
flex: 1 0;
21+
}
22+
23+
& .footer {
24+
flex: 0 0 auto;
25+
}
2026
}
2127
}

www/shared/react/page-swapper/PageSwapper.js

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,20 +7,27 @@ import PageTransition from './page-transition';
77

88
import styles from './PageSwapper.module.css';
99

10-
const PageSwapper = ({ className, ...rest }) => {
10+
const PageSwapper = ({ children, className, ...rest }) => {
1111
const { updateScroll } = useRouterScroll();
1212

1313
return (
1414
<RawPageSwapper
1515
{ ...rest }
1616
updateScroll={ updateScroll }
1717
className={ classNames(styles.pageSwapper, className) }>
18-
{ (props) => <PageTransition { ...props } /> }
18+
{ ({ node, ...rest }) => {
19+
if (typeof children === 'function') {
20+
node = children({ node, ...rest });
21+
}
22+
23+
return <PageTransition node={ node } { ...rest } />;
24+
} }
1925
</RawPageSwapper>
2026
);
2127
};
2228

2329
PageSwapper.propTypes = {
30+
children: PropTypes.func,
2431
className: PropTypes.string,
2532
};
2633

0 commit comments

Comments
 (0)