Skip to content

London | ITP-May-2025 | Mo Muchunu | Module-Data-Groups | Sprint 3 | Quote Generator #627

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
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
28 changes: 18 additions & 10 deletions Sprint-3/quote-generator/index.html
Original file line number Diff line number Diff line change
@@ -1,15 +1,23 @@
<!DOCTYPE html>
<html lang="en">
<head>
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Title here</title>
<title>Quote Generator app</title>
<link rel="stylesheet" href="style.css" />
<link
href="https://api.fontshare.com/v2/css?f[]=cabinet-grotesk@100&f[]=boska@400,501&f[]=gambarino@400&f[]=technor@300&display=swap"
rel="stylesheet">
<script defer src="quotes.js"></script>
</head>
<body>
<h1>hello there</h1>
<p id="quote"></p>
<p id="author"></p>
<button type="button" id="new-quote">New quote</button>
</body>
</html>
</head>
<body>
<div class="title">
<h1>Be inspired...</h1>
</div>
<div class="container">
<p id="quote"></p>
<p id="author"></p>
<button type="button" id="new-quote">New quote</button>
</div>
</body>
</html>
14 changes: 14 additions & 0 deletions Sprint-3/quote-generator/quotes.js
Original file line number Diff line number Diff line change
Expand Up @@ -491,3 +491,17 @@ const quotes = [
];

// call pickFromArray with the quotes array to check you get a random quote

function updateQuote() {
const randomQuote = pickFromArray(quotes); // Random quote from the quotes array

document.getElementById("quote").textContent = `❝ ${randomQuote.quote} ❞`; // Wrap quote in decorative quotation marks and display in "quote" element
document.getElementById("author").textContent = `- ${randomQuote.author}`; // Display the author's name in the "author" element
};

document.addEventListener("DOMContentLoaded", function () { // Wait for HTML document to finish loading before running scripts
updateQuote(); // Show an initial quote when page loads


document.getElementById("new-quote").addEventListener("click", updateQuote); // Event listener to load a new quote when button is clicked
});
75 changes: 74 additions & 1 deletion Sprint-3/quote-generator/style.css
Original file line number Diff line number Diff line change
@@ -1 +1,74 @@
/** Write your CSS in here **/
* {
margin: 5;
padding: 2;
box-sizing: border-box;
}

body {
background-color: rgb(209, 191, 237);
margin: 0;
padding: 10px;
display: flex;
flex-direction: column;
align-items: center;
min-height: 100vh;
justify-content: flex-start;
}

h1 {
color: #634592;
font-size: 4rem;
font-family: "Technor", sans-serif;
}

.title {
width: 80%;
justify-content: flex-start;
display: flex;
padding: 3px;
margin-bottom: 10px;
}

.container {
background: rgb(236, 236, 230);
padding: 30px;
border-radius: 5px;
width: 80%;
text-align: center;
margin-bottom: 30px;
}

#quote {
color: rgb(3, 14, 16);
font-family: "Cabinet Grotesk", sans-serif;
font-size: 2.5rem;
font-weight: 400;
margin-bottom: 10px;
margin-top: 30px;
}

#author {
font-size: 20px;
font-style: italic;
margin-bottom: 50px;
border-radius: 5px;
background-color: rgba(127, 255, 212, 0.304);
}

#new-quote {
background-color: rgb(209, 191, 237);
color: rgb(18, 15, 39);
padding: 5px 10px;
font-family: "Lucida Console";
font-size: 1rem;
border-radius: 3px;
cursor: pointer;
border: none;
transition: 0.3s ease;
display: block;
margin-left: auto;
}

#new-quote:hover {
background: rgb(214, 220, 237);
}