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
5 changes: 3 additions & 2 deletions Sprint-3/quote-generator/index.html
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
<!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>
Expand Down
17 changes: 17 additions & 0 deletions Sprint-3/quote-generator/quotes.js

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you make the app to display a quote when the page is first loaded?

Original file line numberDiff line numberDiff line change
@@ -1,3 +1,20 @@
// Goal: page shows a random quote from the quotes array with displaying the author
// requirements:
// when clicking a button on the screen it changes the quote
const author = document.getElementById("author");
const quote = document.getElementById("quote");
const newQuoteButton = document.getElementById("new-quote");

newQuoteButton.addEventListener("click", () => {
displayQuote();
});

function displayQuote() {
const randomQuote = pickFromArray(quotes);
quote.textContent = randomQuote.quote;
author.textContent = randomQuote.author;
}
window.onload = displayQuote;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A better practice is to keep all the code that run once when the app starts in a function.

// DO NOT EDIT BELOW HERE

// pickFromArray is a function which will return one item, at
Expand Down
44 changes: 44 additions & 0 deletions Sprint-3/quote-generator/style.css
Original file line numberDiff line numberDiff line change
@@ -1 +1,45 @@
/** Write your CSS in here **/
body{
font-family: Arial,sans-serif;
min-height: 100vh;
margin:0;
display: flex;
padding: 0 1rem;
background-color: #e2c8c8
}

* {
box-sizing: border-box;
}
main.quote-box {
max-width : 600px;
padding :2rem;
text-align : center;
}

#quote {
font-size : 1.5rem;
font-style : italic;
line-height: 1.4;
margin-bottom : 1rem;
}
#author {
font-size: 1rem;
font-weight: 600;
color: #272ad3;
margin-bottom : 2rem;
}
#new-quote {
padding: 0.6rem 1.4rem;
font-size: 1rem;
border: none;
border-radius: 6px;
background-color: #2b2b2b;
color: #fff;
cursor: pointer;
transition: background-color 0.15s ease;
}

#new-quote:hover {
background-color: #444;
}
Loading