Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 8 additions & 6 deletions Sprint-3/quote-generator/index.html
Original file line number Diff line number Diff line change
@@ -1,15 +1,17 @@
<!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>
<div id="borders">
<p id="quote"></p>
<p id="author"></p>
<button type="button" id="new-quote">New quote</button>
</div>
</body>
</html>
16 changes: 16 additions & 0 deletions Sprint-3/quote-generator/quotes.js
Original file line number Diff line number Diff line change
Expand Up @@ -491,3 +491,19 @@ const quotes = [
];

// call pickFromArray with the quotes array to check you get a random quote
//Show a random quotes when the page has fully loaded alongside the author
const quoteElement = document.querySelector("#quote");
const authorElement = document.querySelector("#author");
const buttonElement = document.querySelector("#new-quote");

document.addEventListener("DOMContentLoaded", generateQuote);

// 2. Change the quote when the button is clicked
buttonElement.addEventListener("click", generateQuote);

function generateQuote() {
const randomQuote = pickFromArray(quotes);

quoteElement.innerText = `❝ ${randomQuote.quote}"`;
authorElement.innerText = `- ${randomQuote.author}`; //I could also use textcontent to access this
Comment on lines +507 to +508

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 " and - appear to be for styling purposes. Keeping them in HTML or in CSS could make it easier to style or modify the view. This allows front-end developers to adjust the UI without changing any JavaScript code.

}
31 changes: 31 additions & 0 deletions Sprint-3/quote-generator/style.css
Original file line number Diff line number Diff line change
@@ -1 +1,32 @@
/** Write your CSS in here **/
body {
background-color: rgb(187, 58, 80);
}
#quote {
color: rgb(136, 38, 54);
text-align: center;
font-size: 30px;
font-weight: bold;
}
#author {
color: rgb(66, 11, 21);
text-align: right;
font-weight: bold;
font-size: 20px;
}
button {
background-color: rgb(121, 29, 29);
border: none;
color: white;
padding: 15px 25px;
margin-bottom: 50px;
text-align: center;
text-decoration: none;
font-size: 16px;
float: right;
}
#borders {
padding: 50px;
margin: 100px 40px;
background-color: white;
}
Loading