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
9 changes: 7 additions & 2 deletions Sprint-3/quote-generator/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,19 @@
<html lang="en">
<head>
<meta charset="UTF-8" />
<link rel="stylesheet" href="/Sprint-3/quote-generator/style.css" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Title here</title>
<title>Quote generator app</title>
<script defer src="quotes.js"></script>
</head>
<body>
<h1>hello there</h1>
<div class="quote-box">
<h1>Hello there Welcome to Adnan's Quote-Generator</h1>
<p id="quote"></p>
<div class="name-button">
<p id="author"></p>
<button type="button" id="new-quote">New quote</button>
</div>
</div>
</body>
</html>
13 changes: 13 additions & 0 deletions Sprint-3/quote-generator/quotes.js
Original file line number Diff line number Diff line change
Expand Up @@ -491,3 +491,16 @@ const quotes = [
];

// call pickFromArray with the quotes array to check you get a random quote
function displayRandomQuote() {
const random = pickFromArray(quotes);
document.getElementById("quote").textContent = `"${random.quote}"`;
document.getElementById("author").textContent = `– ${random.author}`;
}

// Display a quote when the page loads
displayRandomQuote();

// Add click event to the "New quote" button
document
.getElementById("new-quote")
.addEventListener("click", displayRandomQuote);
44 changes: 43 additions & 1 deletion Sprint-3/quote-generator/style.css
Original file line number Diff line number Diff line change
@@ -1 +1,43 @@
/** Write your CSS in here **/
body {
font-family: Arial, sans-serif;
background-color: #f7a6;
display: flex;
justify-content: center;
text-align: center;
padding: 50px;
}
.quote-box {
background: white;
padding: 20px;
border-radius: 5px;
box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1);
display: inline-block;
}
#quote {
font-size: 24px;
margin-bottom: 10px;
}
#author {
padding: 10px 2px;
font-size: 20px;
color: #f7a6;
margin-bottom: 2px;
font-weight: bold;
}
#new-quote {
padding: 10px 20px;
font-size: 16px;
background-color: #f7a6;
color: rgb(0, 0, 0);
font-weight: bold;
border: none;
border-radius: 5px;
}
#new-quote:hover {
background-color: rgba(196, 64, 112, 0.4);
cursor: pointer;
}
.name-button {
text-align: right;
float: right;
}