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
19 changes: 14 additions & 5 deletions Sprint-3/quote-generator/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,22 @@
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Title here</title>
<link rel="preconnect" href="https://fonts.googleapis.com" />
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin />
<link
href="https://fonts.googleapis.com/css2?family=Roboto:ital,wght@0,100..900;1,100..900&display=swap"
rel="stylesheet"
/>
<link rel="stylesheet" href="style.css" />
<title>Quote Generator App</title>
<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>
<section id="card">
<h1>Quote of the day</h1>
<p id="quote"></p>
<p id="author"></p>
<button type="button" id="new-quote">New quote</button>
</section>
</body>
</html>
19 changes: 19 additions & 0 deletions Sprint-3/quote-generator/quotes.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,22 @@
function displayQuote() {
const firstQuote = pickFromArray(quotes);
const initialQuote = document.querySelector("#quote");
initialQuote.innerText = firstQuote.quote;

const author = document.querySelector("#author");
author.innerText = firstQuote.author;
}

function generateQuote() {
displayQuote();

document.querySelector("#new-quote").addEventListener("click", () => {
displayQuote();
});
}

window.onload = generateQuote;

// DO NOT EDIT BELOW HERE

// pickFromArray is a function which will return one item, at
Expand Down
17 changes: 17 additions & 0 deletions Sprint-3/quote-generator/readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,25 @@ First off, once you've branched off `main`, then update the title element in `in

When the page loads it should show a random quote from the `quotes` array on the screen. It should also show who said the quote.

- onload get random quote from array
- get the length of the array
- generate random number between 0 and last index of array
- use number to fetch quote from array and store in variable randomQuote
- display quote
- display quote stored in randomQuote
- display author associated with quote

When you click a button on the screen it should change the quote on the screen.

- when button clicked
- get random quote from array
- get the length of the array
- generate random number between 0 and last index of array
- use number to fetch quote from array and store in variable randomQuote
- display quote
- display quote stored in randomQuote
- display author associated with quote

It can look however you like but there is an example in this folder at `quote_generator_example.png`

## Need Help?
Expand Down
53 changes: 53 additions & 0 deletions Sprint-3/quote-generator/style.css
Original file line number Diff line number Diff line change
@@ -1 +1,54 @@
/** Write your CSS in here **/
body {
font-family: "Roboto", sans-serif;
text-align: center;
margin: 50px;
color: #222843;
background-color: #5372ef;
}

#card {
background-color: #ffffff;
border-radius: 10px;
box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
padding: 20px;
max-width: 600px;
margin: auto;
}

#quote {
font-size: 1.5rem;
margin-bottom: 10px;
padding: 0 2rem;
}

#quote::before,
#quote::after {
content: '"';
font-size: 1.5rem;
}

#author {
font-style: italic;
margin-top: 10px;
margin-bottom: 2rem;
padding-right: 2rem;
padding-bottom: 1.5rem;
color: #555555;
text-align: right;
border-bottom: #e8e8e8 1px solid;
}

#author::before {
content: "— ";
}

#new-quote {
background-color: #5372ef;
color: white;
border: none;
padding: 10px 20px;
border-radius: 25px;
cursor: pointer;
font-size: 16px;
}