Skip to content

Commit 9927f3f

Browse files
committed
tune the quote generator
1 parent dab1b08 commit 9927f3f

3 files changed

Lines changed: 70 additions & 8 deletions

File tree

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

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,23 @@
55
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
66
<title>Quote generator app</title>
77
<script defer src="quotes.js"></script>
8+
<link rel="stylesheet" href="style.css">
89
</head>
910
<body>
10-
<h1>Quote Generator</h1>
11-
<p id="quote">Quote:</p>
12-
<p id="author">Author:</p>
13-
<button type="button" id="new-quote">New quote</button>
11+
<header>
12+
<h1>Quote Generator</h1>
13+
</header>
14+
<main>
15+
<section>
16+
<p id="quote"></p>
17+
<p id="author"></p>
18+
<div></div>
19+
</section>
20+
</main>
21+
<section>
22+
<button type="button" id="new-quote">New quote</button>
23+
</section>
24+
25+
1426
</body>
1527
</html>

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

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -491,19 +491,24 @@ const quotes = [
491491
];
492492

493493
// call pickFromArray with the quotes array to check you get a random quote
494-
console.log(pickFromArray(quotes));
495494

496495
// 1. get a button variable.
497496
// 2. listen to the event.
498497
// 3, when event happens produce a quote in one place <p>
499498
//4. when an event happens produce author of that quote in the other <p>
500499
const button = document.querySelector("#new-quote");
500+
const initialQuote = pickFromArray(quotes);
501+
const placeInitialQuote = document.querySelector("#quote");
502+
const placeInitialAuthor = document.querySelector("#author");
503+
placeInitialQuote.innerText = `${initialQuote.quote}`;
504+
placeInitialAuthor.innerText = `${initialQuote.author}`;
505+
501506
function newQuoteEveryTime() {
502507
const quote = pickFromArray(quotes);
503508
const quotePlace = document.querySelector("#quote");
504509
const authorPlace = document.querySelector("#author");
505-
quotePlace.innerText = `The quote of the day is: ${quote.quote}`;
506-
authorPlace.innerText = `By the author - ${quote.author}`;
510+
quotePlace.innerText = `${quote.quote}`;
511+
authorPlace.innerText = `${quote.author}`;
507512
}
508513

509-
button.addEventListener("mousedown", newQuoteEveryTime);
514+
button.addEventListener("click", newQuoteEveryTime);

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

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,46 @@
1+
h1 {
2+
font-size: 24px;
3+
text-align: center;
4+
color: rgb(225, 71, 36);
5+
}
6+
7+
body {
8+
font-family: Arial, sans-serif;
9+
background: rgb(24, 25, 24);
10+
11+
display: flex;
12+
flex-direction: column;
13+
align-items: center;
14+
15+
min-height: 100vh;
16+
}
17+
#quote {
18+
max-width: 700px;
19+
min-height: 160px;
20+
21+
text-align: center;
22+
font-size: 24px;
23+
color: rgb(225, 71, 36);
24+
}
25+
26+
#author {
27+
width: 700px;
28+
text-align: right;
29+
font-style: italic;
30+
color: rgb(225, 71, 36);
31+
}
32+
33+
#new-quote {
34+
padding: 12px 30px;
35+
font-size: 18px;
36+
color: white;
37+
background-color: rgb(225, 71, 36);
38+
39+
cursor: pointer;
40+
}
41+
42+
43+
44+
45+
146
/** Write your CSS in here **/

0 commit comments

Comments
 (0)