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
23 changes: 17 additions & 6 deletions Sprint-3/quote-generator/index.html
Original file line number Diff line number Diff line change
@@ -1,15 +1,26 @@
<!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>
<main class="card">
<h1>Quote Generator</h1>
<p id="quote"></p>
<p id="author"></p>
<button type="button" id="new-quote">New quote</button>

<div class="autoplay">
<label for="auto-play-toggle">
<input type="checkbox" id="auto-play-toggle" />
Auto-play
</label>
<p id="auto-play-status">auto-play:OFF</p>
</div>
</main>
</body>
</html>
38 changes: 38 additions & 0 deletions Sprint-3/quote-generator/quotes.js
Original file line number Diff line number Diff line change
Expand Up @@ -491,3 +491,41 @@ const quotes = [
];

// call pickFromArray with the quotes array to check you get a random quote
const quoteElement = document.getElementById("quote");
const authorElement = document.getElementById("author");
const newQuoteButton = document.getElementById("new-quote");

function showRandomQuote() {
const randomQuote = pickFromArray(quotes);
quoteElement.textContent = randomQuote.quote;
authorElement.textContent = "- " + randomQuote.author;
}

showRandomQuote();

newQuoteButton.addEventListener("click", showRandomQuote);

const AUTO_PLAY_DELAY = 5000;
const autoPlayToggle = document.getElementById("auto-play-toggle");
const autoPlayStatus = document.getElementById("auto-play-status");

let autoPlayTimer = null;

function startAutoPlay() {
autoPlayTimer = setInterval(showRandomQuote, AUTO_PLAY_DELAY);
autoPlayStatus.textContent = "auto-play:ON";
}

function stopAutoPlay() {
clearInterval(autoPlayTimer);
autoPlayTimer = null;
autoPlayStatus.textContent = "auto-play:OFF";
}

autoPlayToggle.addEventListener("change", function () {
if (autoPlayToggle.checked) {
startAutoPlay();
} else {
stopAutoPlay();
}
});
62 changes: 61 additions & 1 deletion Sprint-3/quote-generator/style.css
Original file line number Diff line number Diff line change
@@ -1 +1,61 @@
/** Write your CSS in here **/
* {
box-sizing: border-box;
}

body {
margin: 0;
min-height: 100vh;
display: flex;
justify-content: center;
align-items: center;
background: linear-gradient(135deg, #667eea, #764ba2);
font-family: Georgia, "Times New Roman", Times, serif;
padding: 1rem;
}

.card {
background: #ffffff;
max-width: 600px;
width: 100%;
padding: 2rem;
border-radius: 12px;
box-shadow: 0 10px 30px rgba(0, 0, 0, 0.25);
text-align: center;
}

h1 {
margin-top: 0;
font-size: 1rem;
letter-spacing: 0.15em;
text-transform: uppercase;
color: #888;
}

#quote {
font-size: 1.5rem;
line-height: 1.5;
font-style: italic;
color: #222;
margin: 1.5rem 0 1rem;
}

button {
background: #764ba2;
color: #ffffff;
border: none;
padding: 0.75rem 1.75rem;
font-size: 1rem;
border-radius: 999px;
cursor: pointer;
transition:
background 0.2s,
transform 0.1s;
}

button:hover {
background: #5d3a85;
}

button:active {
transform: scale(0.96);
}
Loading