diff --git a/Sprint-3/quote-generator/index.html b/Sprint-3/quote-generator/index.html index 30b434bcf..cf5754976 100644 --- a/Sprint-3/quote-generator/index.html +++ b/Sprint-3/quote-generator/index.html @@ -3,13 +3,23 @@ - Title here + Quote generator app + -

hello there

-

-

+

Quote Generator

+
+

+

+
+
+ +

auto-play:OFF

+
diff --git a/Sprint-3/quote-generator/quotes.js b/Sprint-3/quote-generator/quotes.js index 4a4d04b72..4c8eab6db 100644 --- a/Sprint-3/quote-generator/quotes.js +++ b/Sprint-3/quote-generator/quotes.js @@ -491,3 +491,50 @@ const quotes = [ ]; // call pickFromArray with the quotes array to check you get a random quote + +const quoteP = document.querySelector("#quote"); +const authorP = document.querySelector("#author"); +const newQuoteBtn = document.querySelector("#new-quote"); +const autoplayToggle = document.querySelector("#autoplay-toggle"); +const autoplayStatus = document.querySelector("#autoplay-status"); + +let autoplayId = null; + +function showRandomQuote() { + const randomQuote = pickFromArray(quotes); + quoteP.innerText = randomQuote.quote; + authorP.innerText = randomQuote.author; +} + +function setAutoplayStatus(isEnabled) { + autoplayStatus.innerText = isEnabled ? "auto-play:ON" : "auto-play:OFF"; +} + +function startAutoplay() { + if (autoplayId !== null) { + clearInterval(autoplayId); + } + autoplayId = setInterval(showRandomQuote, 60000); + setAutoplayStatus(true); +} + +function stopAutoplay() { + if (autoplayId !== null) { + clearInterval(autoplayId); + autoplayId = null; + } + setAutoplayStatus(false); +} + +function handleAutoplayToggle() { + if (autoplayToggle.checked) { + startAutoplay(); + } else { + stopAutoplay(); + } +} + +showRandomQuote(); +newQuoteBtn.addEventListener("click", showRandomQuote); +autoplayToggle.addEventListener("change", handleAutoplayToggle); +setAutoplayStatus(false); diff --git a/Sprint-3/quote-generator/style.css b/Sprint-3/quote-generator/style.css index 63cedf2d2..69c291dd4 100644 --- a/Sprint-3/quote-generator/style.css +++ b/Sprint-3/quote-generator/style.css @@ -1 +1,76 @@ /** Write your CSS in here **/ +body { + margin: 0; + min-height: 100vh; + display: grid; + place-items: center; + padding: 40px; + font-family: Helvetica, sans-serif; + background: #cc5500; +} + +.container { + width: 100%; + max-width: 650px; + background: #cc5500; + padding: 50px; + border-radius: 8px; +} + +h1 { + font-size: 26px; + line-height: 1.5; + color: white; + margin: 0; + text-align: center; +} + +.quote-box { + width: 100%; + max-width: 700px; + background: white; + padding: 30px; + border-radius: 6px; + box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15); + margin-bottom: 20px; +} + +#quote { + font-size: 26px; + line-height: 1.5; + color: #222; + margin: 0; + text-align: center; +} + +#author { + margin-top: 20px; + text-align: right; + color: #333; + font-weight: 600; +} + +#new-quote { + margin-top: 2px; + background: white; + color: black; + border: 2px solid #cc5500;; + padding: 10px 18px; + cursor: pointer; + border-radius: 4px; +} + +#autoplay-controls { + margin-top: 14px; + color: white; + text-align: center; +} + +#autoplay-status { + margin: 8px 0 0; +} + +* { + box-sizing: border-box; +} +