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

hello there

-

-

- + +
+

Quote Generator

+
+

+
+

+ +
+
+
diff --git a/Sprint-3/quote-generator/quotes.js b/Sprint-3/quote-generator/quotes.js index 4a4d04b72..c59d06fa0 100644 --- a/Sprint-3/quote-generator/quotes.js +++ b/Sprint-3/quote-generator/quotes.js @@ -16,10 +16,24 @@ // pickFromArray(['a','b','c','d']) // maybe returns 'c' // You don't need to change this function -function pickFromArray(choices) { - return choices[Math.floor(Math.random() * choices.length)]; +function randomQuoteGenerator(choices) { + const randomQuote = choices[Math.floor(Math.random() * choices.length)]; + // get the element by the 'id quote + const quoteElement = document.getElementById("quote"); + // get the element by the 'id author + const authorElement = document.getElementById("author"); + + quoteElement.textContent = `“ ${randomQuote.quote} ”`; + authorElement.textContent = `— ${randomQuote.author}`; + } +// then add event listener +document.getElementById("new-quote").addEventListener("click", () => { + randomQuoteGenerator(quotes); +}); + + // A list of quotes you can use in your app. // DO NOT modify this array, otherwise the tests may break! const quotes = [ @@ -490,4 +504,7 @@ const quotes = [ }, ]; -// call pickFromArray with the quotes array to check you get a random quote + + +// Display random quote when page first loads +randomQuoteGenerator(quotes); diff --git a/Sprint-3/quote-generator/style.css b/Sprint-3/quote-generator/style.css index 63cedf2d2..88032ce2e 100644 --- a/Sprint-3/quote-generator/style.css +++ b/Sprint-3/quote-generator/style.css @@ -1 +1,50 @@ /** Write your CSS in here **/ +:root { + --orange: #f1a61b; + --white: #ffffff; +} + +body { + background-color: var(--orange); + height: 100vh; + font-family: sans-serif; + font-size: 24px; +} + +h1 { + color: var(--white); + text-align: center; + margin-bottom: 50px; +} + +.container { + display: flex; + flex-direction: column; + justify-content: center; + align-items: center; + height: 100%; + color: var(--orange); +} + +.card { + margin: 0 auto; + width: 50%; + background-color: var(--white); + padding: 40px; + box-shadow: 0 0 10px rgba(0, 0, 0, 0.1); + text-align: center; + word-wrap: break-word; + border-radius: 10px; +} + +.elements-right { + text-align: right; +} + +.elements-right button { + background: orange; + padding: 10px; + border-radius: 3px; + color: white; + border-style: none; +}