Skip to content
Open
13 changes: 9 additions & 4 deletions Sprint-3/quote-generator/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,18 @@
<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>
<main class="container">
<h1>Quote Generator</h1>
<div class="quote-box">
<p id="quote"></p>
<p id="author"></p>
</div>
<button type="button" id="new-quote">New quote</button>
</main>
</body>
</html>
20 changes: 20 additions & 0 deletions Sprint-3/quote-generator/quotes.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,23 @@
function displayQuote(quoteObject) {
const quoteP = document.getElementById("quote");
const authorP = document.getElementById("author");
quoteP.innerText = quoteObject.quote;
authorP.innerText = quoteObject.author;
}

function showRandomQuote () {
const randomQuote = pickFromArray(quotes);
displayQuote(randomQuote);
}

window.onload = function () {
showRandomQuote();

const newQuoteBtn = document.getElementById("new-quote")
newQuoteBtn.addEventListener("click", () => {
showRandomQuote();
});
};
// DO NOT EDIT BELOW HERE

// pickFromArray is a function which will return one item, at
Expand Down
61 changes: 60 additions & 1 deletion Sprint-3/quote-generator/style.css
Original file line number Diff line number Diff line change
@@ -1 +1,60 @@
/** 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 {
background: black;
padding: 30px;
border-radius: 6px;
border: 2px solid #cc5500;
margin-bottom: 20px;
}

#quote {
font-size: 26px;
line-height: 1.5;
color: white;
margin: 0;
text-align: center;
}

#author {
margin-top: 20px;
text-align: right;
color: white;
font-weight: 600;
}

#new-quote {
margin-top: 2px;
background: white;
color: black;
border: 2px solid #cc5500;;
padding: 10px 18px;
cursor: pointer;
border-radius: 4px;
}