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
14 changes: 8 additions & 6 deletions Sprint-3/quote-generator/index.html
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 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="card">
<h1 id="quote"></h1>
<p id="author"></p>
<button type="button" id="new-quote">New quote</button>
</div>
</body>
</html>
</html>
6 changes: 5 additions & 1 deletion Sprint-3/quote-generator/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,9 @@
"bugs": {
"url": "https://github.com/CodeYourFuture/CYF-Coursework-Template/issues"
},
"homepage": "https://github.com/CodeYourFuture/CYF-Coursework-Template#readme"
"homepage": "https://github.com/CodeYourFuture/CYF-Coursework-Template#readme",
"devDependencies": {
"@testing-library/jest-dom": "^6.9.1",
"jest-environment-jsdom": "^30.3.0"
}
}
19 changes: 19 additions & 0 deletions Sprint-3/quote-generator/quotes.js
Original file line number Diff line number Diff line change
Expand Up @@ -491,3 +491,22 @@ const quotes = [
];

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

const quoteText = document.querySelector("#quote");
const authorText = document.querySelector("#author");
const newQuoteBtn = document.querySelector("#new-quote");

function displayRandomQuote() {
// Use the provided pickFromArray function
const randomQuote = pickFromArray(quotes);

// Update the text on the page
quoteText.innerText = randomQuote.quote;
authorText.innerText = randomQuote.author;
}

// Display a quote immediately when the script runs
displayRandomQuote();

// Add the click event to the button
newQuoteBtn.addEventListener("click", displayRandomQuote);
26 changes: 26 additions & 0 deletions Sprint-3/quote-generator/style.css
Original file line number Diff line number Diff line change
@@ -1 +1,27 @@
/** Write your CSS in here **/
body {
background-color: #f3a638; /* The orange background */
display: flex;
justify-content: center;
align-items: center;
height: 100vh;
margin: 0;
font-family: serif;
}

.container {
background-color: white;
padding: 40px;
width: 60%;
box-shadow: 0 4px 8px rgba(0,0,0,0.1);
position: relative;
}

#new-quote {
background-color: #f3a638;
color: white;
border: none;
padding: 10px 20px;
cursor: pointer;
float: right;
}
Loading