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
22 changes: 16 additions & 6 deletions Sprint-3/quote-generator/index.html
Original file line number Diff line number Diff line change
@@ -1,15 +1,25 @@
<!DOCTYPE html>
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Title here</title>
<title>Quote generator app</title>
<script defer src="quotes.js"></script>
<link rel="stylesheet" href="style.css" />
<link rel="stylesheet" href="style.css" />
</head>
<body>
<h1>hello there</h1>
<p id="quote"></p>
<p id="author"></p>
<button type="button" id="new-quote">New quote</button>
<div class="container">
<div class="quote-box">
<h1>Quote Generator</h1>
<p id="quote"></p>
<p id="author"></p>
<button type="button" id="new-quote">New quote</button>
<div>
<input type="checkbox" id="auto-checkbox" />
<label for="auto-checkbox">Turn on auto</label>
</div>
</div>
</div>
</body>
</html>
32 changes: 32 additions & 0 deletions Sprint-3/quote-generator/quotes.js
Original file line number Diff line number Diff line change
Expand Up @@ -491,3 +491,35 @@ const quotes = [
];

// call pickFromArray with the quotes array to check you get a random quote

function handleCheckBox() {
if (checkBox.checked) {
clearInterval(intervalId);
intervalId = setInterval(displayRandomQuote, 5000);
} else {
clearInterval(intervalId);
}
}
const newQuoteButton = document.getElementById("new-quote");

const checkBox = document.getElementById("auto-checkbox");

const quoteText = document.getElementById("quote");

const authorText = document.getElementById("author");

let intervalId = null;

newQuoteButton.addEventListener("click", displayRandomQuote);

checkBox.addEventListener("click", handleCheckBox);

function displayRandomQuote() {
const selectedQuote = pickFromArray(quotes);

quoteText.textContent = `"${selectedQuote.quote}"`;

authorText.textContent = `${selectedQuote.author}`;
}

window.onload = displayRandomQuote;
47 changes: 47 additions & 0 deletions Sprint-3/quote-generator/style.css
Original file line number Diff line number Diff line change
@@ -1 +1,48 @@
/** Write your CSS in here **/
body {
margin: 0;
font-family: Arial, sans-serif;
background: linear-gradient(90deg, #0700b8 0%, #00ff88 100%);
}

.container {
height: 100vh;
display: flex;
justify-content: center;
align-items: center;
}

.quote-box {
background: white;
padding: 30px;
width: 350px;
text-align: center;
border-radius: 12px;
box-shadow: 0 8px 20px rgba(0, 0, 0, 0.2);
}

.quote {
font-size: 18px;
margin-bottom: 15px;
color: #444;
}

.author {
font-size: 14px;
color: #777;
margin-bottom: 20px;
}

button {
padding: 10px 20px;
border: none;
background: #0700b8;
color: white;
cursor: pointer;
border-radius: 6px;
font-size: 14px;
}

button:hover {
background: #5a67d8;
}