Skip to content

Scotland | ITP-May-2025 | Nataliia Volkova | Module-Data-Groups/Sprint 3/Feature/quote generator #597

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 5 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 4 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>
<h1>Quotes</h1>
<div class="card" , id="wildCard">

Choose a reason for hiding this comment

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

you don't need to put comments separating the properties of HTML elements. a space is fine

Copy link
Author

Choose a reason for hiding this comment

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

Hi Leon, thank you for reviewing my code.

<p id="quote"></p>
<p id="author"></p>
<button type="button" id="new-quote">New quote</button>
</div>
</body>
</html>
24 changes: 24 additions & 0 deletions Sprint-3/quote-generator/quotes.js
Original file line number Diff line number Diff line change
Expand Up @@ -491,3 +491,27 @@ const quotes = [
];

// call pickFromArray with the quotes array to check you get a random quote
const card = document.querySelector("#wildCard");
console.log(card);
const author = document.querySelector("#author");
console.log(author);
const quote = document.querySelector("#quote");
console.log(quote);
const quoteButton = document.querySelector("#new-quote");
console.log(quoteButton);

window.addEventListener("load", function () {
// to invoke quotes when page loads
const result = pickFromArray(quotes);

quote.textContent = `${result.quote}`;
author.textContent = `- ${result.author}`;
});

quoteButton.addEventListener("click", function () {
// invoke quotes when the button is clicked
const result = pickFromArray(quotes);

quote.textContent = `${result.quote}`;
author.textContent = `- ${result.author}`;
});
70 changes: 69 additions & 1 deletion Sprint-3/quote-generator/style.css
Original file line number Diff line number Diff line change
@@ -1 +1,69 @@
/** Write your CSS in here **/
body {
background-color: orange;
padding-left: 75px;
padding-right: 75px;
padding-bottom: 150px;
padding-top: 150px;
align-items: center;
justify-content: center;
display: flex;
}

h1 {
display: none;
}

#wildCard.card {
border-radius: 5px;
text-align: justify;
background-color: white;
height: 300px;
width: 900px;
padding: 30px;
position: relative;
display: flex;
flex-direction: column;
justify-content: space-between;
}

#quote {
color: orange;
font-size: 25px;
font-family: Arial, Helvetica, sans-serif;
font-style: italic;
position: relative;
margin-right: 30px;
}

#quote::before {
content: "❝";
font-family: "Playfair Display", serif;
position: relative;
color: orange;
font-size: 35px;
margin-top: 90px;
margin-left: 20px;
}

#author {
color: orange;
font-size: 20px;
font-family: Arial, Helvetica, sans-serif;
font-style: italic;
text-align: right;
margin-top: 50px;
margin-right: 30px;
margin-bottom: 20px;
}

#new-quote {
color: white;
align-self: self-end;
background-color: orange;
border-radius: 5px;
border-color: orange;
width: 110px;
height: 35px;
margin-top: auto;
margin-right: 30px;
}