Skip to content

Commit 87e8368

Browse files
committed
Adds loading spinner to page.tsx file
1 parent 695dd1b commit 87e8368

File tree

3 files changed

+33
-0
lines changed

3 files changed

+33
-0
lines changed

package.json

+1
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
"react": "^18.2.0",
2626
"react-dom": "^18.2.0",
2727
"react-simple-typewriter": "^5.0.1",
28+
"react-spinners": "^0.13.8",
2829
"react-tsparticles": "^2.10.1",
2930
"tabler-icons-react": "^1.56.0",
3031
"typescript": "5.1.3"

src/app/page.tsx

+27
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
// https://stackoverflow.com/questions/74965849/youre-importing-a-component-that-needs-usestate-it-only-works-in-a-client-comp
22
"use client"; // This is a client component 👈🏽
3+
import { PuffLoader } from "react-spinners";
34

45
// css styling
56
// import styles from "./page.module.css";
@@ -11,6 +12,8 @@ import { Skills } from "./components/Skills";
1112
import { Contact } from "./components/Contact";
1213
import { HeroImageBackground } from "./components/HeroImageBackground";
1314

15+
import { useState, useEffect } from "react";
16+
1417
const useStyles = createStyles((theme) => ({
1518
main: {
1619
// minHeight: "100vh",
@@ -32,6 +35,30 @@ const useStyles = createStyles((theme) => ({
3235

3336
export default function Home() {
3437
const { classes } = useStyles();
38+
const [loading, setLoading] = useState(true);
39+
useEffect(() => {
40+
setLoading(false);
41+
}, []);
42+
43+
if (loading) {
44+
return (
45+
<div
46+
style={{
47+
display: "flex",
48+
justifyContent: "center",
49+
alignItems: "center",
50+
height: "100vh",
51+
}}
52+
>
53+
<PuffLoader
54+
color="#1db954"
55+
size={100}
56+
loading={loading}
57+
aria-label="Loading Spinner"
58+
/>
59+
</div>
60+
);
61+
}
3562
return (
3663
<main className={classes.main}>
3764
<HeroImageBackground />

yarn.lock

+5
Original file line numberDiff line numberDiff line change
@@ -2405,6 +2405,11 @@ react-simple-typewriter@^5.0.1:
24052405
resolved "https://registry.yarnpkg.com/react-simple-typewriter/-/react-simple-typewriter-5.0.1.tgz#cfdb896c868a55ed4d5f1f06d62b3a9d0f5ad9d7"
24062406
integrity sha512-vA5HkABwJKL/DJ4RshSlY/igdr+FiVY4MLsSQYJX6FZG/f1/VwN4y1i3mPXRyfaswrvI8xii1kOVe1dYtO2Row==
24072407

2408+
react-spinners@^0.13.8:
2409+
version "0.13.8"
2410+
resolved "https://registry.yarnpkg.com/react-spinners/-/react-spinners-0.13.8.tgz#5262571be0f745d86bbd49a1e6b49f9f9cb19acc"
2411+
integrity sha512-3e+k56lUkPj0vb5NDXPVFAOkPC//XyhKPJjvcGjyMNPWsBKpplfeyialP74G7H7+It7KzhtET+MvGqbKgAqpZA==
2412+
24082413
react-style-singleton@^2.2.1:
24092414
version "2.2.1"
24102415
resolved "https://registry.yarnpkg.com/react-style-singleton/-/react-style-singleton-2.2.1.tgz#f99e420492b2d8f34d38308ff660b60d0b1205b4"

0 commit comments

Comments
 (0)