Skip to content

Commit 8e18b52

Browse files
committed
Quote-Generator Excercise
1 parent 9285ca4 commit 8e18b52

File tree

3 files changed

+83
-4
lines changed

3 files changed

+83
-4
lines changed

Sprint-3/quote-generator/index.html

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,15 @@
33
<head>
44
<meta charset="UTF-8" />
55
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
6-
<title>Title here</title>
6+
<link rel="stylesheet" href="style.css">
7+
<title>Quote Generator App</title>
78
<script defer src="quotes.js"></script>
89
</head>
910
<body>
10-
<h1>hello there</h1>
11+
1112
<p id="quote"></p>
1213
<p id="author"></p>
13-
<button type="button" id="new-quote">New quote</button>
14+
15+
<button type="button" id="new-quote" onclick="pickFromArray(choices)">New quote</button>
1416
</body>
1517
</html>

Sprint-3/quote-generator/quotes.js

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,19 @@
1515
// ---------------
1616
// pickFromArray(['a','b','c','d']) // maybe returns 'c'
1717

18+
let quoteDisplay = document.getElementById("quote");
19+
let authorDisplay = document.getElementById("author");
20+
let newQuoteButton = document.getElementById("new-quote");
21+
22+
1823
// You don't need to change this function
1924
function pickFromArray(choices) {
2025
return choices[Math.floor(Math.random() * choices.length)];
2126
}
2227

28+
29+
30+
2331
// A list of quotes you can use in your app.
2432
// DO NOT modify this array, otherwise the tests may break!
2533
const quotes = [
@@ -490,4 +498,12 @@ const quotes = [
490498
},
491499
];
492500

493-
// call pickFromArray with the quotes array to check you get a random quote
501+
function displayNewQuote() {
502+
const randomQuoteObject = pickFromArray(quotes);
503+
quoteDisplay.innerHTML = ' " ' + randomQuoteObject.quote;
504+
authorDisplay.innerHTML = ' - ' + randomQuoteObject.author;
505+
}
506+
507+
newQuoteButton.addEventListener("click", displayNewQuote);
508+
509+
displayNewQuote();//disply quote when open the page

Sprint-3/quote-generator/style.css

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,62 @@
11
/** Write your CSS in here **/
2+
3+
body {
4+
font-family: 'Times New Roman',Times, serif;
5+
display: flex;
6+
flex-direction: column;
7+
justify-content: center;
8+
align-items: center;
9+
min-height: 100vh;
10+
margin: 0;
11+
background-color: #fcf1ea;
12+
color: #333;
13+
padding: 20px;
14+
box-sizing: border-box;
15+
}
16+
17+
h1 {
18+
color: #2c3e50;
19+
margin-bottom: 30px;
20+
font-size: 2.5em;
21+
text-align: center;
22+
}
23+
24+
#quote {
25+
font-size: 1.8em;
26+
font-style: italic;
27+
text-align: center;
28+
max-width: 800px;
29+
margin-bottom: 15px;
30+
line-height: 1.5;
31+
color: #555;
32+
}
33+
34+
#author {
35+
font-size: 1.1em;
36+
font-weight: bold;
37+
text-align: center;
38+
margin-bottom: 40px;
39+
color: #777;
40+
}
41+
42+
#new-quote {
43+
background-color: #eb9428;
44+
color: white;
45+
border: none;
46+
padding: 15px 30px;
47+
font-size: 1.1em;
48+
border-radius: 8px;
49+
cursor: pointer;
50+
transition: background-color 0.3s ease, transform 0.2s ease;
51+
box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
52+
}
53+
54+
#new-quote:hover {
55+
background-color: #473408;
56+
transform: translateY(-2px);
57+
}
58+
59+
#new-quote:active {
60+
background-color: #2c3e50;
61+
transform: translateY(0);
62+
}

0 commit comments

Comments
 (0)