Skip to content

Commit

Permalink
resolve errors, banner warnings, use React.Fragment shorthand (#1006)
Browse files Browse the repository at this point in the history
  • Loading branch information
Silvyre authored Apr 15, 2020
1 parent fd70912 commit 301790a
Show file tree
Hide file tree
Showing 5 changed files with 41 additions and 43 deletions.
4 changes: 2 additions & 2 deletions src/frontend/plugins/gatsby-plugin-top-layout/TopLayout.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import theme from '../../src/theme';

export default function TopLayout(props) {
return (
<React.Fragment>
<>
<Helmet>
<meta name="viewport" content="minimum-scale=1, initial-scale=1, width=device-width" />
<link
Expand All @@ -20,7 +20,7 @@ export default function TopLayout(props) {
<CssBaseline />
{props.children}
</ThemeProvider>
</React.Fragment>
</>
);
}

Expand Down
42 changes: 20 additions & 22 deletions src/frontend/src/components/Banner/Banner.jsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import React, { useEffect, useState } from 'react';
import PropTypes from 'prop-types';
import { ThemeProvider, makeStyles } from '@material-ui/core/styles';
import { makeStyles } from '@material-ui/core/styles';
import Typography from '@material-ui/core/Typography';
import Fab from '@material-ui/core/Fab';
import KeyboardArrowDownIcon from '@material-ui/icons/KeyboardArrowDown';
Expand Down Expand Up @@ -170,6 +170,20 @@ function RetrieveBannerDynamicAssets() {
// Ensure we are using an image which fits correctly to user's viewspace
const dimensions = `${window.innerWidth}x${window.innerHeight}`;

async function getStats() {
await getDynamicAsset(`${telescopeUrl}/stats/year`, (response) => {
const localeStats = {
posts: response.posts.toLocaleString(),
authors: response.authors.toLocaleString(),
words: response.words.toLocaleString(),
};
setStats(localeStats);

// Ease in Background
setTransitionBackground(false);
});
}

await getDynamicAsset(
`https://source.unsplash.com/collection/894/${dimensions}/`,
(response) => {
Expand All @@ -183,20 +197,6 @@ function RetrieveBannerDynamicAssets() {
);
}

async function getStats() {
await getDynamicAsset(`${telescopeUrl}/stats/year`, (response) => {
const localeStats = {
posts: response.posts.toLocaleString(),
authors: response.authors.toLocaleString(),
words: response.words.toLocaleString(),
};
setStats(localeStats);

// Ease in Background
setTransitionBackground(false);
});
}

getBackgroundImgSrc();
}, [telescopeUrl]);

Expand Down Expand Up @@ -256,15 +256,13 @@ export default function Banner() {
}, [telescopeUrl]);

return (
<React.Fragment>
<>
<CssBaseline />
<div className={classes.heroBanner}>
<RetrieveBannerDynamicAssets />
<ThemeProvider>
<Typography variant="h1" className={classes.h1}>
{'Telescope'}
</Typography>
</ThemeProvider>
<Typography variant="h1" className={classes.h1}>
{'Telescope'}
</Typography>

<a
href={`${gitInfo.gitHubUrl}`}
Expand All @@ -281,6 +279,6 @@ export default function Banner() {
</ScrollDown>
</div>
</div>
</React.Fragment>
</>
);
}
30 changes: 15 additions & 15 deletions src/frontend/src/components/Posts/Posts.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,23 +15,23 @@ const useStyles = makeStyles({
const Posts = ({ posts }) => {
const classes = useStyles();

return (
return posts.length > 0 ? (
<Container className={classes.root}>
{posts.length > 0
? posts.map(({ id, feed, html, title, url, updated }) => (
<Post
key={id}
id={id}
author={feed.author}
url={url}
html={html}
title={title}
date={updated}
link={feed.link}
/>
))
: null}
{posts.map(({ id, feed, html, title, url, updated }) => (
<Post
key={id}
id={id}
author={feed.author}
url={url}
html={html}
title={title}
date={updated}
link={feed.link}
/>
))}
</Container>
) : (
<></>
);
};

Expand Down
4 changes: 2 additions & 2 deletions src/frontend/src/components/ScrollToTop/ScrollToTop.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -56,14 +56,14 @@ ScrollTop.propTypes = {

export default function BackToTop(props) {
return (
<React.Fragment>
<>
<CssBaseline />
<Toolbar id="back-to-top-anchor" />
<ScrollTop {...props}>
<Fab color="primary" aria-label="scroll back to top">
<KeyboardArrowUpIcon fontSize="large" />
</Fab>
</ScrollTop>
</React.Fragment>
</>
);
}
4 changes: 2 additions & 2 deletions src/frontend/src/components/SnackBar/SnackBar.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,11 @@ export default function SimpleSnackbar() {
onClose={handleClose}
message="There is new content available!"
action={
<React.Fragment>
<>
<IconButton size="small" aria-label="close" color="inherit" onClick={handleClose}>
<CloseIcon fontSize="small" />
</IconButton>
</React.Fragment>
</>
}
/>
</div>
Expand Down

0 comments on commit 301790a

Please sign in to comment.