diff --git a/Sprint-3/quote-generator/index.html b/Sprint-3/quote-generator/index.html index 30b434bcf..674b21837 100644 --- a/Sprint-3/quote-generator/index.html +++ b/Sprint-3/quote-generator/index.html @@ -1,15 +1,25 @@ - + - Title here + Quote Generator App + + -

hello there

-

-

- +
+

+

+ + + + +

auto-play: OFF

+
diff --git a/Sprint-3/quote-generator/script.js b/Sprint-3/quote-generator/script.js new file mode 100644 index 000000000..427c3dc1d --- /dev/null +++ b/Sprint-3/quote-generator/script.js @@ -0,0 +1,34 @@ +const quoteElement = document.querySelector("#quote"); +const authorElement = document.querySelector("#author"); +const buttonElement = document.querySelector("#new-quote"); +const autoPlayElement = document.querySelector("#auto-play"); +const statusElement = document.querySelector("#status"); + +function displayRandomQuote() { + const randomQuote = pickFromArray(quotes); + + quoteElement.textContent = randomQuote.quote; + authorElement.textContent = `- ${randomQuote.author}`; +} + +displayRandomQuote(); + +buttonElement.addEventListener("click", displayRandomQuote); + +let intervalId = null; + +function toggleAutoPlay() { + if (autoPlayElement.checked) { + statusElement.textContent = "auto-play: ON"; + + clearInterval(intervalId); + intervalId = setInterval(displayRandomQuote, 3000); + } else { + statusElement.textContent = "auto-play: OFF"; + + clearInterval(intervalId); + intervalId = null; + } +} + +autoPlayElement.addEventListener("change", toggleAutoPlay); diff --git a/Sprint-3/quote-generator/style.css b/Sprint-3/quote-generator/style.css index 63cedf2d2..aea449d70 100644 --- a/Sprint-3/quote-generator/style.css +++ b/Sprint-3/quote-generator/style.css @@ -1 +1,62 @@ /** Write your CSS in here **/ +body { + margin: 0; + min-height: 100vh; + display: flex; + justify-content: center; + align-items: center; + background-color: orange; + font-family: Georgia, serif; +} + +.quote-card { + background-color: #e9e9e9; + width: 700px; + max-width: 90%; + padding: 40px; + box-sizing: border-box; +} + +h1 { + margin-top: 0; + color: #333; + font-size: 2rem; +} + +#quote { + font-size: 2rem; + line-height: 1.5; + color: orange; + margin-bottom: 30px; +} + +#author { + font-size: 1.5rem; + color: orange; + text-align: right; + margin-bottom: 30px; +} + +#new-quote { + display: block; + margin-left: auto; + padding: 12px 20px; + border: none; + border-radius: 4px; + background-color: orange; + color: white; + font-size: 1rem; + cursor: pointer; +} + +.auto-play-label { + display: block; + margin-top: 20px; + color: #333; +} + +#status { + margin-top: 10px; + color: #333; + font-size: 1rem; +}