Skip to content
23 changes: 18 additions & 5 deletions Sprint-3/quote-generator/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,26 @@
<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>
<blockquote class="container">
<p id="quote" class="quote"></p>
<cite id="author"></cite>

<div class="button-wrapper">
<button type="button" id="new-quote">New quote</button>
</div>

<div class="auto-refresh">
<label>
<input type="checkbox" id="auto-quote">
Random quote every minute
</label>
</div>
</blockquote>
<p id="autoplay-status">Auto-Play: ON</p>
</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

function newRandomQuote() {
const randomQuote = pickFromArray(quotes);

document.getElementById("quote").textContent = randomQuote.quote;
document.getElementById("author").textContent = randomQuote.author;
}

document.getElementById("new-quote").addEventListener("click", () => {
newRandomQuote();
});

let autoQuoteIntervalID = null;

document.getElementById("auto-quote").addEventListener("change", function () {
const autoplayStatus = document.getElementById("autoplay-status");

if (this.checked) {
const oneMinute = 60 * 1000;
autoQuoteIntervalID = setInterval(newRandomQuote, oneMinute);
autoplayStatus.style.display = "block";
} else {
clearInterval(autoQuoteIntervalID);
autoQuoteIntervalID = null;
autoplayStatus.style.display = "none";
}
});

newRandomQuote();
99 changes: 99 additions & 0 deletions Sprint-3/quote-generator/style.css
Original file line number Diff line number Diff line change
@@ -1 +1,100 @@
/** Write your CSS in here **/

html, body {
height: 100%;
margin: 0;
}

body {
display: flex;
justify-content: center;
align-items: center;
padding: 40px;
box-sizing: border-box;
background-color: #f3a83c;
overflow: hidden;
}

.container {
background: white;
border-radius: 10px;
padding: 60px 80px;
width: 65%;
max-width: 900px;
display: flex;
flex-direction: column;
}

#quote {
color: #f3a83c;
font-size: 2rem;
font-weight: 400;
line-height: 1.4;
position: relative;
padding-left: 60px;
/* Space for the quote icon */
}

/* Left floating quotation mark */
#quote::before {
content: "“";
font-size: 4rem;
color: #f3a83c;
position: absolute;
left: 0;
top: -10px;
}

#author {
color: #f3a83c;
text-align: right;
margin-top: 30px;
font-size: 1.2rem;
margin-bottom: 40px;
}

.button-wrapper {
text-align: right;
}

#new-quote {
background-color: #f3a83c;
color: white;
padding: 0.8em 1.4em;
border: none;
border-radius: 4px;
font-size: 1rem;
cursor: pointer;
}

.auto-refresh {
margin-top: 20px;
margin-bottom: 20px;
text-align: left;
}

.auto-refresh label {
font-size: 1rem;
color: #f3a83c;
cursor: pointer;
}

.auto-refresh input {
transform: scale(1.2);
margin-right: 10px;
}

#autoplay-status {
position: fixed;
bottom: 10px;
right: 15px;
font-size: 1rem;
color: white;
background: rgba(0, 0, 0, 0.4);
padding: 6px 10px;
border-radius: 5px;
display: none;
/* hidden by default */
pointer-events: none;
/* so clicks pass through */
}