Skip to content
Closed
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>
<script defer src="quotes.js"></script>
<link rel="stylesheet" href="style.css" />
</head>
<body>
<h1>hello there</h1>
<p id="quote"></p>
<p id="author"></p>
<button type="button" id="new-quote">New quote</button>
<h1>Inspirational Quotes</h1>
<div id="quote-display">
<p id="quote"></p>
<p id="author"></p>
<button type="button" id="new-quote">New quote</button>
<div class="auto-play-toggle">
<input type="checkbox" id="auto-play-toggle" />
<label for="auto-play-toggle">
Auto Play <span id="auto-play-status">OFF</span>
</label>
</div>
</div>
</body>
</html>
29 changes: 29 additions & 0 deletions Sprint-3/quote-generator/quotes.js
Original file line number Diff line number Diff line change
Expand Up @@ -491,3 +491,32 @@ const quotes = [
];

// call pickFromArray with the quotes array to check you get a random quote
const quoteDisplay = document.querySelector("#quote");
const authorDisplay = document.querySelector("#author");
const newQuoteButton = document.querySelector("#new-quote");

//Function to update the text on the screen
function displayNewQuote() {
const randomQuote = pickFromArray(quotes);
quoteDisplay.textContent = randomQuote.quote;
authorDisplay.textContent = randomQuote.author;
}

//add event listener to the button
newQuoteButton.addEventListener("click", displayNewQuote);
displayNewQuote();

const autoPlayToggle = document.querySelector("#auto-play-toggle");
const autoPlayStatus = document.querySelector("#auto-play-status");
let autoPlayInterval = null;

//function for starting/stopping the timer
autoPlayToggle.addEventListener("change", function () {
if (this.checked) {
autoPlayStatus.textContent = "ON";
autoPlayInterval = setInterval(displayNewQuote, 60000);
} else {
autoPlayStatus.textContent = "OFF";
clearInterval(autoPlayInterval);
}
});
138 changes: 137 additions & 1 deletion Sprint-3/quote-generator/style.css
Original file line number Diff line number Diff line change
@@ -1 +1,137 @@
/** Write your CSS in here **/
@import url("https://fonts.googleapis.com/css2?family=Roboto:ital,wght@0,100..900;1,100..900&family=WindSong:wght@400;500&display=swap");

/*variables */
:root {
--primary: #a5521f; /* darker orange */
--accent: #e07a2f; /* slightly deeper hover */
--accent2: #f6b47f;
--text-main: #4a2404; /* darker brown */
--text-dark: #3b1d03;
--heading: #3a1d03;
--white: #ffffff;
--transition: 0.3s ease;
--small-text: 0.85rem;
--cursive: "WindSong", "Times New Roman", Times, serif;
}

/*body*/
body {
margin: 0;
padding: 0;
height: 100vh;
font-family: "Roboto", Arial, Helvetica, sans-serif;
display: flex;
flex-direction: column;
justify-content: center;
align-items: center;
background: var(--accent);
}

/* heading */
h1 {
color: var(--heading);
font-family: var(--cursive);
font-size: 3rem;
font-weight: 300;
}

/*quote card container */
#quote-display {
background: var(--white);
padding: 3cqh 3rem;
max-width: 50%;
display: flex;
flex-direction: column;
align-items: flex-end;
color: var(--text-main);
border-radius: 1rem;
}

/*quote text */
#quote {
position: relative;
font-size: 1.5rem;
text-align: justify;
text-align-last: left;
line-height: 1.2;
font-weight: 200;
}

#quote::before {
content: "\201c";
position: absolute;
left: -2.5rem;
top: -0.9rem;
font-size: 5.5rem;
font-family: "Times New Roman", Times, serif;
color: var(--accent);
line-height: 1;
}

/* author text */
#author {
font-family: var(--cursive);
text-align: right;
font-size: 1.5rem;
color: var(--text-dark);
margin-bottom: 2.5rem;
}

#author::before {
content: "\2014";
margin-right: 2px;
}

/* button for new quotes */
button {
background-color: #d46f2a;
color: var(--white);
border: none;
padding: 0.7rem 1.5rem;
font-size: 1rem;
border-radius: 5px;
cursor: pointer;
transition:
background-color var(--transition),
color var(--transition);
}

button:hover {
background-color: var(--primary);
color: var(--white);
}

/*auto-play*/
.auto-play-toggle {
margin-top: 1rem;
margin-bottom: 1rem;
display: flex;
align-items: center;
gap: 0.5rem;
font-size: var(--small-text);
cursor: pointer;
accent-color: var(--primary);
}

#auto-play-status {
font-size: var(--small-text);
font-weight: bold;
margin-left: 0.5rem;
color: var(--text-dark);
}

button:focus-visible,
#auto-play-toggle:focus-visible {
outline: 3px solid #000;
outline-offset: 3px;
}

/* input label */
.auto-play-toggle label {
cursor: pointer;
transition: color var(--transition);
}

.auto-play-toggle label:hover {
color: var(--accent);
}
Loading