Skip to content
15 changes: 9 additions & 6 deletions Sprint-3/quote-generator/index.html
Original file line number Diff line number Diff line change
@@ -1,15 +1,18 @@
<!DOCTYPE html>
<!doctype html>
<html lang="en">
<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>
<script defer src="quotes.js"></script>
<link rel="stylesheet" href="style.css" />
</head>
<body>
<h1>hello there</h1>
<p id="quote"></p>
<p id="author"></p>
<button type="button" id="new-quote">New quote</button>
<main>
<h1>"</h1>
<p id="quote"></p>
<p id="author"></p>
<button type="button" id="new-quote">New quote</button>
</main>
</body>
</html>
14 changes: 14 additions & 0 deletions Sprint-3/quote-generator/quotes.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,17 @@
const newQuoteButton = document.querySelector("#new-quote");

function displayQuote() {
const randomQuote = pickFromArray(quotes);
const quote = document.querySelector("#quote");
const author = document.querySelector("#author");

quote.textContent = randomQuote.quote;
author.textContent = `- ${randomQuote.author}`;
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The leading - appears to be for styling purposes. Keeping it in the CSS or in HTML could allow us to adjust the view without changing any JavaScript code.

}

newQuoteButton.addEventListener("click", displayQuote);
window.addEventListener("load", displayQuote);
Comment on lines +12 to +13
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The code that setup the event listener once is also part of the "run on load" code.
You can consider including all the "run on load" code in a function to make it clearer
that "this is what runs when the page loads."

For examples,

function setup() {
  // code to be executed on page load
}

window.addEventListener('load', setup);

or

window.addEventListener('load', function() {
  // code to be executed on page load
});


// DO NOT EDIT BELOW HERE

// pickFromArray is a function which will return one item, at
Expand Down
65 changes: 65 additions & 0 deletions Sprint-3/quote-generator/style.css
Original file line number Diff line number Diff line change
@@ -1 +1,66 @@
/** Write your CSS in here **/
:root {
--primary-color: #ffa500;
--secondary-color: #ffffff;
}

* {
box-sizing: border-box;
margin: 0;
padding: 0;
}

body {
background-color: var(--primary-color);
display: flex;
justify-content: center;
align-items: center;
min-height: 100vh;
padding: 1rem;
font-family:
system-ui,
-apple-system,
sans-serif;
}

main {
background-color: var(--secondary-color);
color: var(--primary-color);
width: 100%;
max-width: 850px;
min-height: 300px;
padding: clamp(3rem, 6vw, 5rem);
text-align: right;
padding: 4rem;
}

h1,
#quote {
display: inline;
font-weight: bold;
}

h1 {
font-size: clamp(2.5rem, 6vw, 3rem);
font-family: Theseadow, serif;
}

#quote {
font-size: clamp(1rem, 3vw, 1.5rem);
}

#author {
margin-top: 1rem;
margin-bottom: 1rem;
font-style: italic;
}

button {
background-color: var(--primary-color);
color: var(--secondary-color);
border: none;
padding: 0.5rem 1rem;
cursor: pointer;
font-weight: bold;
font-size: large;
}
Loading