abhi-plugin-gatsby-preview
Advanced tools
Comparing version 0.0.1 to 0.0.2
@@ -10,22 +10,25 @@ "use strict"; | ||
}) { | ||
const [showReloadBar, setShowReloadBar] = React.useState(false); | ||
const [showInProgressBar, setInProgess] = React.useState(false); | ||
const [showStatusBar, setShowStatus] = React.useState(false); | ||
const [message, setMessage] = React.useState(""); | ||
React.useEffect(() => { | ||
const socket = io(); | ||
socket.on("connect", () => { | ||
console.log("Connected to cloud runner"); | ||
console.log("Connected to Gatsby Preview"); | ||
}); | ||
socket.on("reload", data => { | ||
socket.on("status", data => { | ||
console.log(`Received data for reload`, data); | ||
setInProgess(false); | ||
setShowReloadBar(true); | ||
setTimeout(() => { | ||
window.location.reload(); | ||
}, 1000); | ||
if (data && data.event) { | ||
showStatusBar(true); | ||
} | ||
if (data && data.event === "SUCCESS") { | ||
setMessage("You Gatsby Preview is reloading..."); | ||
setTimeout(() => { | ||
window.location.reload(); | ||
}, 1000); | ||
} else { | ||
setMessage("You Gatsby Preview is building, the page will reload when complete..."); | ||
} | ||
}); | ||
socket.on("building", data => { | ||
console.log(`Received data for building`, data); | ||
setInProgess(true); | ||
setShowReloadBar(false); | ||
}); | ||
return () => { | ||
@@ -35,3 +38,3 @@ return socket.close(); | ||
}); | ||
return /*#__PURE__*/React.createElement(React.Fragment, null, showReloadBar && /*#__PURE__*/React.createElement("div", { | ||
return /*#__PURE__*/React.createElement(React.Fragment, null, showStatusBar && /*#__PURE__*/React.createElement("div", { | ||
style: { | ||
@@ -46,13 +49,3 @@ position: `fixed`, | ||
} | ||
}, "Your Preview is reloading..."), showInProgressBar && /*#__PURE__*/React.createElement("div", { | ||
style: { | ||
position: `fixed`, | ||
width: `100%`, | ||
top: 0, | ||
left: 0, | ||
backgroundColor: `purple`, | ||
color: `white`, | ||
textAlign: `center` | ||
} | ||
}, "Your Preview is rebuilding..."), children); | ||
}, message), children); | ||
} | ||
@@ -59,0 +52,0 @@ |
{ | ||
"name": "abhi-plugin-gatsby-preview", | ||
"description": "A Gatsby plugin shows status of cloud preview", | ||
"version": "0.0.1", | ||
"version": "0.0.2", | ||
"author": "Abhi Aiyer", | ||
@@ -6,0 +6,0 @@ "keywords": [ |
2112
47