Skip to content

Commit 6968115

Browse files
committed
Sprint-3: implement quote-generator
1 parent de6889c commit 6968115

3 files changed

Lines changed: 27 additions & 3 deletions

File tree

‎Sprint-3/quote-generator/index.html‎

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,14 @@
33
<head>
44
<meta charset="UTF-8" />
55
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
6-
<title>Title here</title>
7-
<script defer src="quotes.js"></script>
6+
<title>Quote generator app</title>
7+
<link rel="stylesheet" href="style.css" />
88
</head>
99
<body>
1010
<h1>hello there</h1>
1111
<p id="quote"></p>
1212
<p id="author"></p>
1313
<button type="button" id="new-quote">New quote</button>
14+
<script defer src="quotes.js"></script>
1415
</body>
1516
</html>

‎Sprint-3/quote-generator/quotes.js‎

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -491,3 +491,14 @@ const quotes = [
491491
];
492492

493493
// call pickFromArray with the quotes array to check you get a random quote
494+
495+
function displayQuote() {
496+
const picked = pickFromArray(quotes);
497+
document.getElementById("quote").innerText = picked.quote;
498+
document.getElementById("author").innerText = picked.author;
499+
}
500+
501+
document.addEventListener("DOMContentLoaded", () => {
502+
displayQuote();
503+
document.getElementById("new-quote").addEventListener("click", displayQuote);
504+
});

‎Sprint-3/quote-generator/style.css‎

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,13 @@
1-
/** Write your CSS in here **/
1+
2+
h1, p, button{
3+
margin: 30px;
4+
text-align: center;
5+
}
6+
7+
#new-quote {
8+
margin: 20px;
9+
position: absolute;
10+
left: 50%;
11+
-webkit-transform: translate(-50%, -50%);
12+
transform: translate(-50%, -50%);
13+
}

0 commit comments

Comments
 (0)