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
21 changes: 15 additions & 6 deletions Sprint-3/quote-generator/index.html
Original file line number Diff line number Diff line change
@@ -1,15 +1,24 @@
<!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>
<link rel="stylesheet" href="style.css" />
<script defer src="quotes.js"></script>
</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="app">
<div class="quote-card">
<h1>Daily Motivation For You</h1>
<p id="quote"></p>
<p id="author"></p>
<button type="button" id="new-quote">New quote</button>
<label>
<input type="checkbox" id="autoplay-quote" />
Auto‑play
</label>
</div>
</div>
</body>
</html>
23 changes: 23 additions & 0 deletions Sprint-3/quote-generator/quotes.js
Original file line number Diff line number Diff line change
Expand Up @@ -491,3 +491,26 @@ const quotes = [
];

// call pickFromArray with the quotes array to check you get a random quote
function showRandomQuote() {
const randomQuote = pickFromArray(quotes);
const quoteElement = document.querySelector("#quote");
const authorElement = document.querySelector("#author");

quoteElement.textContent = randomQuote.quote;
authorElement.textContent = randomQuote.author;
}
showRandomQuote();
const button = document.querySelector("#new-quote");
button.addEventListener("click", showRandomQuote);

const autoplayQuote = document.querySelector("#autoplay-quote");
let autoplayInterval = null;

autoplayQuote.addEventListener("change", function () {
if (autoplayQuote.checked) {
autoplayInterval = setInterval(showRandomQuote, 5000);
} else {
clearInterval(autoplayInterval);
autoplayInterval = null;
}
});
69 changes: 68 additions & 1 deletion Sprint-3/quote-generator/style.css
Original file line number Diff line number Diff line change
@@ -1 +1,68 @@
/** Write your CSS in here **/
body {
margin: 0;
padding: 0;
font-family:
system-ui,
-apple-system,
BlinkMacSystemFont,
"Segoe UI",
sans-serif;
background-color: #5e77c2;
display: flex;
justify-content: center;
align-items: center;
min-height: 100vh;
}
.app {
display: flex;
justify-content: center;
align-items: center;
}
.quote-card {
background-color: #ffffff;
padding: 32px;
border-radius: 30px;
width: 900px;
min-height: 280px;
max-width: 800px;
text-align: center;
box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
position: relative;
display: flex;
flex-direction: column;
}
#quote {
color: #043d52;
font-size: 20px;
margin-bottom: 1px;
}
#author {
color: #555555;
font-size: 17px;
font-style: italic;
position: absolute;
bottom: 90px;
right: 60px;
}
#new-quote {
background-color: #5e77c2;
color: #ffffff;
border: none;
padding: 10px 22px;
border-radius: 4px;
font-size: 16px;
cursor: pointer;
position: absolute;
bottom: 40px;
right: 50px;
}

#new-quote:hover {
background-color: #3f3642;
}
.quote-card label {
position: absolute;
bottom: 40px;
left: 50px;
font-size: 16px;
}
Loading