Skip to content

Commit

Permalink
fix: Use not found page when can't find view
Browse files Browse the repository at this point in the history
style: Minor changes to search bar display
  • Loading branch information
colin969 committed Jul 31, 2024
1 parent ecd6470 commit 1ea2fcd
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 16 deletions.
8 changes: 5 additions & 3 deletions src/renderer/components/pages/NotFoundPage.tsx
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
import { Paths } from '@renderer/Paths';
import { Link } from 'react-router-dom';

/** Page shown when the current URL does not point to an existing page. */
export function NotFoundPage() {
return (
<div className='page-not-found'>
<h1 className='page-not-found__error-number'>404</h1>
<h1 className='page-not-found__title'>Page Not Found</h1>
The page you were looking for is not here.
<h1>You appear to have gotten lost :(</h1>
<Link className='link' to={Paths.HOME}> Back to home</Link>
</div>
);
}
15 changes: 10 additions & 5 deletions src/renderer/containers/withView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import * as React from 'react';
import { useLocation } from 'react-router-dom';
import { getViewName } from '@renderer/Util';
import { useAppSelector } from '@renderer/hooks/useAppSelector';
import { NotFoundPage } from '@renderer/components/pages/NotFoundPage';

export type WithViewProps = {
currentView: ResultsView;
Expand All @@ -15,10 +16,14 @@ export function withView<Props extends WithViewProps>(Component: React.Component
const viewName = getViewName(location.pathname);
const search = useAppSelector((state) => state.search);
const view = search.views[viewName];
return <Component
{...(props as Props)}
currentView={view}
currentViewName={viewName}
/>;
if (view) {
return <Component
{...(props as Props)}
currentView={view}
currentViewName={viewName}
/>;
} else {
return <NotFoundPage />;
}
};
}
20 changes: 12 additions & 8 deletions static/window/styles/core.css
Original file line number Diff line number Diff line change
Expand Up @@ -935,6 +935,9 @@ body {
height: 100%;
padding: 1em;
text-align: center;
display: flex;
flex-direction: column;
justify-content: center;
}
.page-not-found__error-number {
font-size: 8em;
Expand Down Expand Up @@ -3470,8 +3473,8 @@ body {

.search-bar {
width: 100%;
height: 2.5rem;
padding: 0.5rem;
height: 2.3rem;
padding: 0.4rem;
display: flex;
flex-direction: row;
}
Expand All @@ -3495,7 +3498,7 @@ body {
}

.search-bar-expansion {
margin-right: 0.5rem;
margin-right: 0.4rem;
flex-grow: 1;
}

Expand All @@ -3508,10 +3511,11 @@ body {
.search-bar-simple-box {
cursor: pointer;
user-select: none;
margin-left: 0.5rem;
margin-bottom: 0.5rem;
margin-left: 0.4rem;
margin-bottom: 0.4rem;
align-items: center;
padding: 0.3rem;
font-size: 0.9em;
display: flex;
flex-direction: row;
}
Expand All @@ -3522,10 +3526,10 @@ body {

.three-state-checkbox {
cursor: pointer;
display: inline-block;
display: inline-flex;
padding: 0.1rem;
width: 1.2rem;
height: 1.2rem;
width: 1.1rem;
height: 1.1rem;
border: 1px solid #ccc;
border-radius: 4px;
}
Expand Down

0 comments on commit 1ea2fcd

Please sign in to comment.