Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 25 additions & 0 deletions app/globals.css
Original file line number Diff line number Diff line change
Expand Up @@ -205,6 +205,31 @@ left: 2vw; /* Adjust as needed */
transform: rotate(270deg);
}

/*
===========================
REFRESH BUTTON STYLES
===========================
*/

.refreshBtn {
margin-top: 20px;
}

.btn {
cursor: pointer;
background-color: #ffffff;
border: 1px solid #dddddd;
padding: 5px 10px;
border-radius: 5px;
font-size: 1.2em;
font-family: 'Bellefair', serif;
text-shadow: 1px 1px 1px #ddd, 2px 2px 1px #ccc, 0 0 1em black;
transition: all 0.3s;
}
.btn:hover {
background-color: #dddddd;
}

/*
===========================
MEDIA QUERIES
Expand Down
17 changes: 15 additions & 2 deletions app/page.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,15 @@ export default function Home() {
// State for storing the selected quote
const [selectedQuote, setSelectedQuote] = useState(null);

// Effect hook to select a random quote on component mount
useEffect(() => {
// Always generate a random quote
const generateRandomQuote = () => {
const randomIndex = Math.floor(Math.random() * quotes.length); // Get a random index
setSelectedQuote(quotes[randomIndex]); // Set the selected quote to the quote at the random index
}

// Effect hook to select a random quote on component mount
useEffect(() => {
generateRandomQuote();
}, []);

// If no quote is selected, return null (or a loading state)
Expand Down Expand Up @@ -96,6 +101,14 @@ export default function Home() {
<a>HexCodeHQ | Quote Submitted By {selectedQuote.submitter}</a>
</p>
</div>

{/* Button to generate a random quote without refreshing the page */}
<div className="refreshBtn">
<button className="btn" onClick={generateRandomQuote}>
Generate me another Quote
</button>
</div>

</div>
</div>
{/* Add a film grain effect */}
Expand Down