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
21 changes: 15 additions & 6 deletions Sprint-3/quote-generator/index.html
Original file line number Diff line number Diff line change
@@ -1,15 +1,24 @@
<!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 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">
<img
src="https://img.icons8.com/ios-filled/50/f39c12/quote-left.png"
alt="quote mark"
class="quote-icon"
/>

<h1>hello there</h1>
<p id="quote"></p>
<p id="author"></p>
<button type="button" id="new-quote">New quote</button>
</div>
</body>
</html>
2 changes: 1 addition & 1 deletion Sprint-3/quote-generator/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "quote-generator",
"version": "1.0.0",
"license": "CC-BY-SA-4.0",
"description": "You must update this package",
"description": "A quote generator app completed for Sprint 3",
"scripts": {
"test": "jest --config=../jest.config.js quote-generator"
},
Expand Down
29 changes: 29 additions & 0 deletions Sprint-3/quote-generator/quotes.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,32 @@
window.onload = () => {
const quoteText = document.getElementById("quote");
const authorText = document.getElementById("author");
const newQuoteBtn = document.getElementById("new-quote");
const autoPlayCheckbox = document.getElementById("auto-play");
const autoPlayStatus = document.getElementById("auto-play-txt");

let autoPlayInterval;

function generateQuote() {
const randomQuote = pickFromArray(quotes);
quoteText.innerText = randomQuote.quote;
authorText.innerText = `- ${randomQuote.author}`;
}

generateQuote();

newQuoteBtn.addEventListener("click", generateQuote);

autoPlayCheckbox.addEventListener("change", (event) => {
if (event.target.checked) {
autoPlayStatus.innerText = "Auto-Play: ON";
autoPlayInterval = setInterval(generateQuote, 5000);
} else {
autoPlayStatus.innerText = "Auto-Play: OFF";
clearInterval(autoPlayInterval);
}
});
};
// DO NOT EDIT BELOW HERE

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

.container {
background-color: white;
width: 70%;
max-width: 800px;
padding: 50px 50px 80px 50px;
box-shadow: 0 4px 8px rgba(0,0,0,0.1);
position: relative;
}

h1 {
display: none;
}

.quote-icon {
width: 45px;
float: left;
margin-right: 15px;
margin-top: -10px;
}

#quote {
font-size: 32px;
color: #fba21c;
margin: 0;
line-height: 1.4;
}

#author {
color: #fba21c;
font-size: 20px;
font-weight: bold;
text-align: right;
margin-top: 30px;
margin-bottom: 30px;
}

#new-quote {
background-color: #fba21c;
color: white;
border: none;
padding: 12px 24px;
font-size: 18px;
cursor: pointer;
position: absolute;
bottom: 40px;
right: 50px;
}
Loading