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
7 changes: 4 additions & 3 deletions Sprint-3/quote-generator/index.html
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
<!DOCTYPE html>
<!doctype html>
<html lang="en">
<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>
<h1>Quote Generator</h1>
<p id="quote"></p>
<p id="author"></p>
<button type="button" id="new-quote">New quote</button>
Expand Down
13 changes: 13 additions & 0 deletions Sprint-3/quote-generator/quotes.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,15 @@
const quoteP = document.querySelector("#quote");
const authorP = document.querySelector("#author");
const button = document.querySelector("#new-quote");

function displayQuote() {
const randomQuote = pickFromArray(quotes);
quoteP.innerText = randomQuote.quote;
authorP.innerText = randomQuote.author;
}

button.addEventListener("click", displayQuote);
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Placing all the "run on load" code (lines 11 and 506) inside a function can make it clearer that
"this is what runs when the page loads." For examples,

function setup() {
  // code to be executed on page load
}

window.addEventListener('load', setup);

or

window.addEventListener('load', function() {
  // code to be executed on page load
});


// DO NOT EDIT BELOW HERE

// pickFromArray is a function which will return one item, at
Expand Down Expand Up @@ -491,3 +503,4 @@ const quotes = [
];

// call pickFromArray with the quotes array to check you get a random quote
displayQuote();
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This version still have this function call beyond the // DO NOT EDIT BELOW HERE marker.

64 changes: 63 additions & 1 deletion Sprint-3/quote-generator/style.css
Original file line number Diff line number Diff line change
@@ -1 +1,63 @@
/** Write your CSS in here **/
body {
margin: 0;
padding: 0;
font-family: "Poppins", sans-serif;
background: linear-gradient(135deg, #ff9ecf, #ffc3a0);
display: flex;
flex-direction: column;
justify-content: center;
align-items: center;
height: 100vh;
}

h1 {
color: white;
margin-bottom: 20px;
}

#quote {
background: #fff0f6;
padding: 2rem;
border-radius: 20px 20px 0 0;
width: 60%;
max-width: 700px;
color: #d63384;
font-size: 1.6rem;
position: relative;
}

#quote::before {
content: "❝";
position: absolute;
left: 15px;
top: 5px;
font-size: 3rem;
color: #ff85c1;
}

#author {
background: #fff0f6;
width: 60%;
max-width: 700px;
padding: 1rem 2rem;
text-align: right;
color: #c2185b;
border-radius: 0 0 20px 20px;
}

#new-quote {
margin-top: 20px;
background: #ff85c1;
color: white;
border: none;
padding: 0.7rem 1.4rem;
border-radius: 20px;
cursor: pointer;
font-size: 0.95rem;
transition: all 0.3s ease;
}

#new-quote:hover {
background: #ff4fa3;
transform: translateY(-2px) scale(1.05);
}
Loading