Skip to content

London | May-2025 | Ikenna Agulobi | Data Groups |Sprint-3 | Quote generator app #689

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 7 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
18 changes: 13 additions & 5 deletions Sprint-3/quote-generator/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,21 @@
<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" />
<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>

<div class="container">
<h1>Quote Generator</h1>
<section class="card">
<p id="quote"></p>
<div class="elements-right">
<p id="author"></p>
<button type="button" id="new-quote">New quote</button>
</div>
</section>
</div>
</body>
</html>
19 changes: 18 additions & 1 deletion Sprint-3/quote-generator/quotes.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,23 @@

// You don't need to change this function
function pickFromArray(choices) {
return choices[Math.floor(Math.random() * choices.length)];
const randomQuote = choices[Math.floor(Math.random() * choices.length)];
// get the element by the 'id quote
const quoteElement = document.getElementById("quote");
// get the element by the 'id author
const authorElement = document.getElementById("author");

quoteElement.textContent = `“ ${randomQuote.quote} ”`;
authorElement.textContent = `— ${randomQuote.author}`;

}

// then add event listener
document.getElementById("new-quote").addEventListener("click", () => {
pickFromArray(quotes);
});


// A list of quotes you can use in your app.
// DO NOT modify this array, otherwise the tests may break!
const quotes = [
Expand Down Expand Up @@ -490,4 +504,7 @@ const quotes = [
},
];



// call pickFromArray with the quotes array to check you get a random quote
const allQuotes = pickFromArray(quotes);
49 changes: 49 additions & 0 deletions Sprint-3/quote-generator/style.css
Original file line number Diff line number Diff line change
@@ -1 +1,50 @@
/** Write your CSS in here **/
:root {
--orange: #f1a61b;
--white: #ffffff;
}


body {
background-color: var(--orange);
height: 100vh;
font-family:sans-serif;
font-size: 24px;
}
h1{
color: var(--white);
text-align: center;
margin-bottom: 50px;
}


.container {
display: flex;
flex-direction: column;
justify-content: center;
align-items: center;
height: 100%;
color: var(--orange);
}

.card {
margin: 0 auto;
width: 50%;
background-color: var(--white);
padding: 40px;
box-shadow: 0 0 10px rgba(0, 0, 0, 0.1);
text-align: center;
word-wrap: break-word;
border-radius: 10px;
}

.elements-right {
text-align: right;
}
.elements-right button {
background: orange;
padding: 10px;
border-radius: 3px;
color: white;
border-style: none;
}