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
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,15 @@
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Title here</title>
<title>Quote Generator</title>
<link rel="stylesheet" href="style.css" />
<script defer src="quotes.js"></script>
</head>
<body>
<h1>hello there</h1>
<div class="container">
<p id="quote"></p>
<p id="author"></p>
<button type="button" id="new-quote">New quote</button>
</div>
</body>
</html>
22 changes: 22 additions & 0 deletions Sprint-3/quote-generator/quotes.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,25 @@
// Wait until the DOM is fully loaded
window.addEventListener("DOMContentLoaded", () => {
// Get references to the HTML elements
const quoteEl = document.getElementById("quote");
const authorEl = document.getElementById("author");
const newQuoteBtn = document.getElementById("new-quote");

// Function to display a random quote
function displayRandomQuote() {
const randomQuote = pickFromArray(quotes); // get random quote object
quoteEl.innerHTML = `<div class="quote-symbol">“</div>${randomQuote.quote}`;
authorEl.innerText = `- ${randomQuote.author}`;

}

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

// Display a new quote when button is clicked
newQuoteBtn.addEventListener("click", displayRandomQuote);
});

// DO NOT EDIT BELOW HERE

// pickFromArray is a function which will return one item, at
Expand Down
72 changes: 71 additions & 1 deletion Sprint-3/quote-generator/style.css
Original file line number Diff line number Diff line change
@@ -1 +1,71 @@
/** Write your CSS in here **/
/* Make the whole page background yellow and center the content */
body {
background-color: #ff8904;
display: flex;
justify-content: center;
align-items: center;
height: 100vh;
/* full viewport height */
margin: 0;
font-family: Arial, sans-serif;
}

/* The frame container for quote, author, and button */
.container {
background-color: #ffffff;
/* white */
padding: 40px;
border-radius: 15px;
box-shadow: 0 4px 10px rgba(0, 0, 0, 0.2);
text-align: center;
display: flex;
flex-direction: column;
align-items: center;
gap: 20px;
/* space between elements */
max-width: 500px;
width: 90%;
}

/* Style the quote */
#quote {
color: #ff8904;
font-size: 1.2rem;
line-height: 1;
max-width: 100%;
text-align: left;
justify-content: left;
}


/* Style the author */
#author {
color: #ff8904;
font-size: 1.2rem;
margin: 0;
text-align: right;
}

/* Style the button */
#new-quote {
background-color: #ff8904;
color: #ffffff;
border: none;
padding: 10px 10px;
font-size: 1rem;
border-radius: 8px;
width: 100px;
text-align: right;
}

/* Hover effect for button */
#new-quote:hover {
background-color: hsl(32, 90%, 65%);
}
.quote-symbol {
font-size: 7rem;
color: #ff8904;
margin-right: 6px;
text-align: left;
justify-content: left;
}