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
18 changes: 12 additions & 6 deletions Sprint-3/quote-generator/index.html
Original file line number Diff line number Diff line change
@@ -1,15 +1,21 @@
<!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>
<link rel="stylesheet" href="style.css" />
<title>Quote generator app</title>
<script defer src="quotes.js"></script>
</head>
<body>
<h1>hello there</h1>
<p id="quote"></p>
<p id="author"></p>
<button type="button" id="new-quote">New quote</button>
<main>
<section>
<p id="quote" class="quote"></p>
<div>
<p id="author" class="author"></p>
<button type="button" id="new-quote">New quote</button>
</div>
</section>
</main>
</body>
</html>
17 changes: 17 additions & 0 deletions Sprint-3/quote-generator/quotes.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
const quoteEl = document.getElementById("quote");
const authorEl = document.getElementById("author");
const newQuoteBtn = document.getElementById("new-quote");

// DO NOT EDIT BELOW HERE

// pickFromArray is a function which will return one item, at
Expand Down Expand Up @@ -491,3 +495,16 @@ const quotes = [
];

// call pickFromArray with the quotes array to check you get a random quote
const pickRandomQuote = () => {
const quoteIndex = Math.floor(Math.random() * quotes.length);
return quotes[quoteIndex];
};

const displayRandomQuote = () => {
const { quote, author } = pickRandomQuote();
quoteEl.textContent = `"${quote}`;
authorEl.textContent = `- ${author}`;
};
displayRandomQuote();

newQuoteBtn.addEventListener("click", displayRandomQuote);
50 changes: 49 additions & 1 deletion Sprint-3/quote-generator/style.css
Original file line number Diff line number Diff line change
@@ -1 +1,49 @@
/** Write your CSS in here **/
:root {
margin: 0;
}

main {
display: flex;
justify-content: center;
align-items: center;
position: fixed;
inset: 0;
background-color: #ffa500;
color: #ffa500;
}
section {
width: 60%;
height: 60%;
background-color: #ffffff;
display: flex;
flex-direction: column;
align-items: center;
padding: 2rem;
}

.quote {
max-width: 100%;
font-size: 2.5rem;
}

section div {
width: 90%;
max-width: 90%;

display: flex;
flex-direction: column;
align-items: flex-end;
}

.author {
font-size: 1.5rem;
font-weight: 300;
}

button {
border: 0;
font-size: 1.5rem;
color: #ffffff;
background-color: #ffa500;
padding: 1rem;
}
Loading