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
13 changes: 8 additions & 5 deletions Sprint-3/quote-generator/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,16 @@
<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>
<h1 id="h1">Dare to be inspired.....</h1>
<p id="quote"></p>
<p id="author"></p>
<button type="button" id="new-quote">New quote</button>
</div>
</body>
</html>
16 changes: 16 additions & 0 deletions Sprint-3/quote-generator/quotes.js
Original file line number Diff line number Diff line change
Expand Up @@ -491,3 +491,19 @@ const quotes = [
];

// call pickFromArray with the quotes array to check you get a random quote
const fetchQuote = document.getElementById("quote");
const fetchAuthor = document.getElementById("author");
const newQuote = document.getElementById("new-quote");

// function to display a random quote
function displayRandomQuote() {
const randomQuote = pickFromArray(quotes);
fetchQuote.innerText = randomQuote.quote;
fetchAuthor.innerText = randomQuote.author;
}

// show one quote when page loads
displayRandomQuote();

// change quote when button is clicked
newQuote.addEventListener("click", displayRandomQuote);
46 changes: 46 additions & 0 deletions Sprint-3/quote-generator/style.css
Original file line number Diff line number Diff line change
@@ -1 +1,47 @@
/** Write your CSS in here **/
body {
font-family: Arial, sans-serif;
text-align: center;
margin: 40px;
background-color: lightgray;
}

div {
background: white;
padding: 20px;
border-radius: 8px;
max-width: 500px;
margin: auto;
box-shadow: 0 2px 6px gray;
}

h1 {
color: black;
margin-bottom: 20px;
}

#quote {
font-size: 1.2em;
margin: 20px 0;
color: darkblue;
}

#author {
font-style: italic;
color: darkgreen;
margin-bottom: 25px;
}

button {
padding: 10px 20px;
font-size: 1em;
background-color: magenta;
color: white;
border: none;
border-radius: 5px;
cursor: pointer;
}

button:hover {
background-color: navy;
}