Skip to content

Commit

Permalink
feat(DEV-13): create OfflineHeader with offlineResults
Browse files Browse the repository at this point in the history
  • Loading branch information
hhimanshu committed Jul 8, 2021
1 parent 9b842ac commit 77713df
Show file tree
Hide file tree
Showing 4 changed files with 57 additions and 8 deletions.
32 changes: 27 additions & 5 deletions src/components/OfflineResults/index.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
import React, { useEffect, useState } from 'react';
import { getCachedGithubUsers } from './fetchFromCache';
import { GithubUser } from '../../../types';
import AppShell from '../AppShell';
import Offline from '../../icons/offline.svg';
import styles from './offlineResults.module.css';

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

return (
<div>
Your Offline results
{cachedResponses.map(r => {
return <pre key={r.login}>{JSON.stringify(r)}</pre>;
})}
<AppShell>
<OfflineHeader />
<div>
Your Offline results
{cachedResponses.map(r => {
return <pre key={r.login}>{r.name}</pre>;
})}
</div>
</AppShell>
);
};

const OfflineHeader = () => {
return (
<div className={styles.offlineHeader}>
<Offline style={{ height: 40, width: 'auto' }} />

<p>You are currently offline</p>
<button
className={styles.refresh}
onClick={() => window.location.reload()}
>
refresh
</button>
</div>
);
};
27 changes: 27 additions & 0 deletions src/components/OfflineResults/offlineResults.module.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
.offlineHeader {
display: flex;
justify-content: space-around;
align-items: center;
padding: 10px;
background: #FFEEB0;
}

.offlineHeader > p {
margin: 0;
}

.offlineIconContainer {
height: 10px;
width: auto;
border: 1px solid black
}

.refresh {
background: #000000;
color: #ffffff;
border: 0;
padding: 10px 15px;
border-radius: 4px;
font-weight: bold;
cursor: pointer;
}
2 changes: 1 addition & 1 deletion src/icons/offline.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 2 additions & 2 deletions src/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import '@fontsource/poppins/900.css';
import { registerServiceWorker } from './utilities';
import { BrowserRouter as Router, Route, Switch } from 'react-router-dom';
import { ContentContainer } from './containers/ContentContainer';
import { EmptyCard } from './components/EmptyCard';
import { OfflineResults } from './components/OfflineResults';

// todo (h2): update this condition
if (true || process.env.NODE_ENV === 'production') {
Expand All @@ -18,7 +18,7 @@ const Root = () => (
<Router>
<Switch>
<Route path='/' exact component={ContentContainer} />
<Route path='/offline' exact component={EmptyCard} />
<Route path='/offline' exact component={OfflineResults} />
</Switch>
</Router>
);
Expand Down

0 comments on commit 77713df

Please sign in to comment.