Skip to content

Commit

Permalink
Merge branch 'master' into all-contributors/add-mbrodt
Browse files Browse the repository at this point in the history
  • Loading branch information
timleslie authored Jun 3, 2020
2 parents 44f0c4c + 6ccf012 commit dcab9ea
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 25 deletions.
5 changes: 5 additions & 0 deletions .changeset/funny-mayflies-juggle.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@keystonejs/app-admin-ui': patch
---

Converted ScrolToTop component to a custom hook.
8 changes: 2 additions & 6 deletions docs/guides/deployment.md
Original file line number Diff line number Diff line change
@@ -1,17 +1,13 @@
<!--[meta]
section: guides
title: Deployment recommendations
title: Docker
subSection: deployment
[meta]-->

# Deployment recommendations

## General
# Docker

Keystone files need to be built with `keystone build` before running in production mode.

## Docker

Keystone can be easily built as a Docker container image, suitable for deploying on Kubernetes or other environments.

Recommended guides:
Expand Down
6 changes: 1 addition & 5 deletions packages/app-admin-ui/client/components/ScrollToTop.js
Original file line number Diff line number Diff line change
@@ -1,14 +1,10 @@
import { useEffect } from 'react';
import { useLocation } from 'react-router-dom';

const ScrollToTop = ({ children }) => {
export const useScrollToTop = () => {
const location = useLocation();

useEffect(() => {
window.scrollTo(0, 0);
}, [location]);

return children;
};

export default ScrollToTop;
28 changes: 14 additions & 14 deletions packages/app-admin-ui/client/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import { globalStyles } from '@arch-ui/theme';

import { initApolloClient } from './apolloClient';
import Nav from './components/Nav';
import ScrollToTop from './components/ScrollToTop';
import { useScrollToTop } from './components/ScrollToTop';
import ConnectivityListener from './components/ConnectivityListener';
import KeyboardShortcuts from './components/KeyboardShortcuts';
import PageLoading from './components/PageLoading';
Expand Down Expand Up @@ -61,6 +61,8 @@ const ListPageWrapper = () => {
const MainPageWrapper = () => {
const { adminPath, pages } = useAdminMeta();

useScrollToTop();

const customRoutes = [
...pages
.filter(({ path }) => typeof path === 'string')
Expand All @@ -71,19 +73,17 @@ const MainPageWrapper = () => {
];

return (
<ScrollToTop>
<Nav>
<Suspense fallback={<PageLoading />}>
<Switch>
{customRoutes.map(({ path, children }) => (
<Route exact key={path} path={path} children={children} />
))}
<Route exact path={adminPath} children={<HomePageWrapper />} />
<Route path={`${adminPath}/:listKey`} children={<ListPageWrapper />} />
</Switch>
</Suspense>
</Nav>
</ScrollToTop>
<Nav>
<Suspense fallback={<PageLoading />}>
<Switch>
{customRoutes.map(({ path, children }) => (
<Route exact key={path} path={path} children={children} />
))}
<Route exact path={adminPath} children={<HomePageWrapper />} />
<Route path={`${adminPath}/:listKey`} children={<ListPageWrapper />} />
</Switch>
</Suspense>
</Nav>
);
};

Expand Down

0 comments on commit dcab9ea

Please sign in to comment.