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
34 changes: 23 additions & 11 deletions Sprint-3/quote-generator/index.html
Original file line number Diff line number Diff line change
@@ -1,15 +1,27 @@
<!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>
<script defer src="quotes.js"></script>
</head>
<body>
<h1>hello there</h1>

<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Quote generator app</title>
<link rel="stylesheet" href="style.css" />
<script defer src="quotes.js"></script>
</head>

<body>
<div class="card">
<p id="quote"></p>
<p id="author"></p>
<button type="button" id="new-quote">New quote</button>
</body>
</html>

<div class="controls">
<label class="toggle-label">
<input type="checkbox" id="autoplay-toggle" />
<span id="autoplay-status">Auto Play: OFF</span>
</label>
<button type="button" id="new-quote">New quote</button>
</div>
</div>
</body>

</html>
29 changes: 29 additions & 0 deletions Sprint-3/quote-generator/quotes.js
Original file line number Diff line number Diff line change
Expand Up @@ -491,3 +491,32 @@ const quotes = [
];

// call pickFromArray with the quotes array to check you get a random quote
const quoteEl = document.getElementById("quote");
const authorEl = document.getElementById("author");
const btn = document.getElementById("new-quote");
const toggle = document.getElementById("autoplay-toggle");
const statusEl = document.getElementById("autoplay-status");

let interval = null;

function showQuote() {
const picked = pickFromArray(quotes);
console.log(picked);
quoteEl.textContent = picked.quote;
authorEl.textContent = "- " + picked.author;
}

btn.addEventListener("click", showQuote);

toggle.addEventListener("change", () => {
if (toggle.checked) {
statusEl.textContent = "Auto Play: ON";
interval = setInterval(showQuote, 3000);
} else {
statusEl.textContent = "Auto Play: OFF";
clearInterval(interval);
interval = null;
}
});

showQuote();
108 changes: 107 additions & 1 deletion Sprint-3/quote-generator/style.css
Original file line number Diff line number Diff line change
@@ -1 +1,107 @@
/** Write your CSS in here **/
* {
margin: 0;
padding: 0;
box-sizing: border-box;
}

body {
min-height: 100vh;
background-color: #f5a800;
display: flex;
align-items: center;
justify-content: center;
font-family: Georgia, serif;
}

.card {
background: #fff;
padding: 60px 50px 40px;
max-width: 780px;
width: 90%;
border-radius: 4px;
position: relative;
}

.card::before {
content: "\201C";
font-size: 120px;
color: #f5a800;
line-height: 0.6;
position: absolute;
top: 40px;
left: 40px;
}

#quote {
font-size: 1.4rem;
color: #f5a800;
margin-bottom: 20px;
padding-left: 60px;
line-height: 1.6;
}

#author {
font-size: 1.1rem;
color: #f5a800;
text-align: right;
margin-bottom: 30px;
}

.controls {
display: flex;
align-items: center;
justify-content: flex-end;
gap: 20px;
}

button#new-quote {
background-color: #f5a800;
color: #fff;
border: none;
padding: 14px 28px;
font-size: 1rem;
cursor: pointer;
}

button#new-quote:hover {
background-color: #d99200;
}

/* Toggle switch */
.toggle-label {
display: flex;
align-items: center;
gap: 10px;
cursor: pointer;
font-size: 0.9rem;
color: #f5a800;
}

.slider {
width: 44px;
height: 24px;
background: #ccc;
border-radius: 999px;
position: relative;
transition: background 0.3s;
}

.slider::after {
content: "";
position: absolute;
width: 18px;
height: 18px;
background: #fff;
border-radius: 50%;
top: 3px;
left: 3px;
transition: transform 0.3s;
}

.toggle-label input:checked + .slider {
background: #f5a800;
}

.toggle-label input:checked + .slider::after {
transform: translateX(20px);
}
Loading