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
16 changes: 11 additions & 5 deletions Sprint-3/quote-generator/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,19 @@
<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>
<button type="button" id="new-quote">New quote</button>
<main>
<h1>Quote Generator</h1>

<p id="quote"></p>
<p id="author"></p>

<button type="button" id="new-quote">New quote</button>
</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
Expand Up @@ -491,3 +491,20 @@ const quotes = [
];

// call pickFromArray with the quotes array to check you get a random quote

const quoteElement = document.querySelector("#quote");
const authorElement = document.querySelector("#author");
const buttonElement = document.querySelector("#new-quote");

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

quoteElement.textContent = randomQuote.quote;
authorElement.textContent = "— " + randomQuote.author;
}

// show a quote when the page loads
showRandomQuote();

// show a new quote when button is clicked
buttonElement.addEventListener("click", showRandomQuote);
34 changes: 34 additions & 0 deletions Sprint-3/quote-generator/style.css
Original file line number Diff line number Diff line change
@@ -1 +1,35 @@
/** Write your CSS in here **/
body {
background-color: orange;
font-family: Arial, sans-serif;
display: flex;
justify-content: center;
align-items: center;
height: 100vh;
}

main {
background: white;
padding: 40px;
max-width: 600px;
text-align: center;
}

#quote {
font-size: 28px;
font-weight: 500;
margin-bottom: 20px;
}

#author {
margin-bottom: 20px;
font-style: italic;
}

button {
background-color: orange;
color: white;
border: none;
padding: 10px 20px;
cursor: pointer;
}
Loading