Skip to content

Commit 1dc112c

Browse files
Vignesh S, ManojVignesh S, Manoj
authored andcommitted
Added loader svg
Fixed the location of html.js Added loader config in gatsby-browser.js
1 parent dcdaf92 commit 1dc112c

File tree

4 files changed

+122
-62
lines changed

4 files changed

+122
-62
lines changed

gatsby-browser.js

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,19 @@
11
export const onServiceWorkerUpdateReady = () => {
22
const answer = window.confirm(
33
`This tutorial has been updated. ` +
4-
`Reload to display the latest version?`
4+
`Reload to display the latest version?`
55
)
66
if (answer === true) {
77
window.location.reload()
88
}
9-
}
9+
}
10+
11+
export const onInitialClientRender = () => {
12+
setTimeout(function () {
13+
const elementById = document.getElementById("___loader");
14+
15+
if (elementById && elementById.style) {
16+
elementById.style.display = "none";
17+
}
18+
}, 1000)
19+
}

src/components/html.js

Lines changed: 0 additions & 60 deletions
This file was deleted.

src/components/images/loader.svg

Lines changed: 27 additions & 0 deletions
Loading

src/html.js

Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
1+
import React from 'react';
2+
import PropTypes from 'prop-types';
3+
import config from '../config';
4+
import Loader from './components/images/loader.svg';
5+
6+
export default class HTML extends React.Component {
7+
8+
render() {
9+
return (
10+
<html {...this.props.htmlAttributes} lang="en">
11+
<head>
12+
<meta charSet="utf-8"/>
13+
<meta httpEquiv="x-ua-compatible" content="ie=edge"/>
14+
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no"/>
15+
{config.siteMetadata.ogImage ? (
16+
<meta property="og:image" content={config.siteMetadata.ogImage}/>
17+
) : null}
18+
<meta property="twitter:card" content="summary_large_image"/>
19+
{config.siteMetadata.ogImage ? (
20+
<meta property="twitter:image" content={config.siteMetadata.ogImage}/>
21+
) : null}
22+
{config.siteMetadata.favicon ? (
23+
<link rel="shortcut icon" type="image/svg" href={config.siteMetadata.favicon}/>
24+
) : null}
25+
<noscript key="noscript"></noscript>
26+
{this.props.headComponents}
27+
</head>
28+
<body {...this.props.bodyAttributes}>
29+
{this.props.preBodyComponents}
30+
<div
31+
key={`loader`}
32+
id="___loader"
33+
style={{
34+
alignItems: "center",
35+
backgroundColor: "#FFFFFF",
36+
display: "flex",
37+
justifyContent: "center",
38+
position: "absolute",
39+
left: 0,
40+
top: 0,
41+
right: 0,
42+
bottom: 0,
43+
zIndex: 100,
44+
}}
45+
>
46+
<img
47+
src={Loader}
48+
alt="loading spinner"
49+
width="150"
50+
height="150"
51+
/>
52+
</div>
53+
<div key={`body`} id="___gatsby" dangerouslySetInnerHTML={{__html: this.props.body}}/>
54+
{this.props.postBodyComponents}
55+
<script
56+
defer
57+
dangerouslySetInnerHTML={{
58+
__html: `
59+
function navBarClose() {
60+
document.getElementById("navbar").classList.toggle("responsive");
61+
}
62+
document.addEventListener('click',function(e){
63+
if(e.target && e.target.tagName.toLowerCase() === 'a'){
64+
navBarClose();
65+
}
66+
});
67+
`,
68+
}}
69+
/>
70+
</body>
71+
</html>
72+
);
73+
}
74+
}
75+
76+
HTML.propTypes = {
77+
htmlAttributes: PropTypes.object,
78+
headComponents: PropTypes.array,
79+
bodyAttributes: PropTypes.object,
80+
preBodyComponents: PropTypes.array,
81+
body: PropTypes.string,
82+
postBodyComponents: PropTypes.array,
83+
};

0 commit comments

Comments
 (0)