Skip to content

Commit

Permalink
Text now zooms in and out
Browse files Browse the repository at this point in the history
  • Loading branch information
JMessina000 committed Feb 2, 2023
1 parent 881d34e commit 4b0666f
Showing 1 changed file with 16 additions and 1 deletion.
17 changes: 16 additions & 1 deletion pages/jack.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ import React, { useState, useEffect } from "react";
export default function Jack() {
const [colorIndex, setColorIndex] = useState(0);
const colors = ["red", "orange", "yellow", "green", "blue", "indigo", "violet"];
const [fontSize, setFontSize] = useState(20);
const [fontDirection, setFontDirection] = useState(1);

useEffect(() => {
const intervalId = setInterval(() => {
Expand All @@ -14,6 +16,18 @@ export default function Jack() {
return () => clearInterval(intervalId);
}, [colorIndex]);

useEffect(() => {
const intervalId = setInterval(() => {
if (fontSize >= 40) {
setFontDirection(-1);
} else if (fontSize <= 10) {
setFontDirection(1);
}
setFontSize(fontSize + fontDirection);
}, 50);
return () => clearInterval(intervalId);
}, [fontSize]);

return (
<div className={styles.container} style={{ backgroundColor: colors[colorIndex] }}>
<Head>
Expand All @@ -27,14 +41,15 @@ export default function Jack() {
style={{
fontFamily: "Comic Sans",
fontWeight: 550,
fontSize: "20px",
fontSize: `${fontSize}px`,
}}
>
I'm Jack and I really hope you don't have epilepsy
</div>
</main>
</div>
);

}

// Written using a trained version of ChatGPT

0 comments on commit 4b0666f

Please sign in to comment.