Skip to content

Commit

Permalink
feat(DEV-27): enable conditional rendering
Browse files Browse the repository at this point in the history
also remove header from OfflineResults
  • Loading branch information
hhimanshu committed Jul 13, 2021
1 parent 138dce6 commit 2f22c28
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 5 deletions.
2 changes: 1 addition & 1 deletion src/components/Starter/Header/header.module.css
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
grid-template-columns: auto 1fr;
padding: 20px;
position: sticky;
top: 0
top: 0;
}

.menuContainer {
Expand Down
5 changes: 2 additions & 3 deletions src/components/Starter/OfflineResults/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import { GithubUser } from '../../../../types';
import Offline from '../../../icons/offline.svg';
import styles from './offlineResults.module.css';
import { ListCachedGithubUsers } from '../ListCachedGithubUsers';
import { AppShell } from '../AppShell';

export const OfflineResults = () => {
const [cachedResponses, setCachedResponses] = useState<GithubUser[]>([]);
Expand All @@ -14,15 +13,15 @@ export const OfflineResults = () => {
}, [getCachedGithubUsers, setCachedResponses]);

return (
<AppShell>
<>
<div className={styles.offlineResults}>
<OfflineHeader />
<h3>Your Past Searches</h3>
<div className={styles.offlineResultsContainer}>
<ListCachedGithubUsers users={cachedResponses} />
</div>
</div>
</AppShell>
</>
);
};

Expand Down
4 changes: 3 additions & 1 deletion src/containers/HomeContainer.tsx
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
import React from 'react';
import { AppShell } from '../components/Starter/AppShell';
import { Home } from '../components/Starter/Home';
import { OfflineResults } from '../components/Starter/OfflineResults';

export const HomeContainer = () => {
return (
<AppShell>
<Home />
{window.navigator.onLine && <Home />}
{!window.navigator.onLine && <OfflineResults />}
</AppShell>
);
};

0 comments on commit 2f22c28

Please sign in to comment.