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
10 changes: 7 additions & 3 deletions Sprint-3/quote-generator/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,17 @@
<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>
<div id="centre">
<p id="quote"></p>
<p id="author"></p>
<button type="button" id="new-quote">New quote</button>
<input type="checkbox" id="auto-quote" onclick="autoQuote()">
<label id="auto-quote-label" for="auto-quote">auto play off</label>
</div>
</body>
</html>
</html>
26 changes: 26 additions & 0 deletions Sprint-3/quote-generator/quotes.js
Original file line number Diff line number Diff line change
Expand Up @@ -491,3 +491,29 @@ const quotes = [
];

// call pickFromArray with the quotes array to check you get a random quote
const quote = document.querySelector("#quote");
const author = document.querySelector("#author");
const quoteButton = document.querySelector("#new-quote");
const autoQuoteCheckBox = document.querySelector("#auto-quote");
const autoQuoteLabel = document.querySelector("#auto-quote-label");
let interval;
function generateQuote() {
const randomQuote = pickFromArray(quotes);
quote.innerText = randomQuote.quote;
author.innerText = randomQuote.author;
}
quoteButton.addEventListener("click", () => {
generateQuote();
});

generateQuote();

function autoQuote() {
if (autoQuoteCheckBox.checked === true) {
interval = setInterval(generateQuote, 60000);
autoQuoteLabel.innerText = "auto play on";
} else {
clearInterval(interval);
autoQuoteLabel.innerText = "auto play off";
}
}
37 changes: 37 additions & 0 deletions Sprint-3/quote-generator/style.css
Original file line number Diff line number Diff line change
@@ -1 +1,38 @@
/** Write your CSS in here **/

body{
background-color: rgba(255, 183, 0, 0.912);
}

#centre {
background-color: white;
margin: 100px;
padding: 100px;
align-content: center;
}

p{
color: rgba(255, 183, 0, 0.912);
font-size: xx-large;
}
#author{
display: flex;
flex-direction: column;
align-items: flex-end;
}
h1 {
text-align: center;
}
#new-quote{
display: block;
margin-left: auto;
margin-right: 0;
padding: 10pt;
background-color: rgba(255, 183, 0, 0.912);
border: 0cap;
color: white;
font-size: large;
}
#auto-quote{
font-size: large;
}
Loading