Skip to content

ITP_London | Maryna Romanova | Module_Data_Groups | Sprint-3 | QuoteGenerator #501

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 1 commit into
base: main
Choose a base branch
from
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
17 changes: 14 additions & 3 deletions Sprint-3/quote-generator/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,24 @@
<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>

<div id="div">

<div id="div-in">
<h1 id="quote"></h1>
<p id="author"></p>
<button type="button" id="new-quote">New quote</button>
</div>

</div>

</body>
</html>


5 changes: 5 additions & 0 deletions Sprint-3/quote-generator/jest.setup.js
Original file line number Diff line number Diff line change
@@ -1 +1,6 @@
require("@testing-library/jest-dom");





17 changes: 17 additions & 0 deletions Sprint-3/quote-generator/quotes.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,16 @@ function pickFromArray(choices) {
return choices[Math.floor(Math.random() * choices.length)];
}

function showRandomQuote() {
document.getElementById("new-quote").addEventListener("click", () => {
const randomQuote = pickFromArray(quotes);
document.getElementById("quote").textContent = `"${randomQuote.quote}"`;
document.getElementById("author").textContent = `— ${randomQuote.author}`;
});
}
showRandomQuote();


// A list of quotes you can use in your app.
// DO NOT modify this array, otherwise the tests may break!
const quotes = [
Expand Down Expand Up @@ -491,3 +501,10 @@ const quotes = [
];
Copy link

Choose a reason for hiding this comment

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

should be closing it off with this }

Copy link

Choose a reason for hiding this comment

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

The last quote I mean


// call pickFromArray with the quotes array to check you get a random quote



// const randomQuote = pickFromArray(quotes);
// console.log(randomQuote.quote);
// console.log(randomQuote.author);

54 changes: 54 additions & 0 deletions Sprint-3/quote-generator/style.css
Original file line number Diff line number Diff line change
@@ -1 +1,55 @@
/** Write your CSS in here **/
body {
background-color:bisque;
}

#div-in {
background-color: white;
border-radius: 20px;
padding: 30px;
box-shadow: 0 15px 30px rgba(0, 0, 0, 0.2);
width: 600px;
height: 200px;
text-align: center;

justify-content: center;
margin-left: 30%;
margin-top:10%;

}



#quote {
font-size: 1.5em;
font-style: italic;
margin-bottom: 15px;
color: #333;
}

#author {
font-size: 1.1em;
font-weight: bold;
color: #555;
}

#new-quote {
position: fixed;
bottom: 40%;
left: 50%;

margin-bottom: 20px;
padding: 12px 24px;
background-color:orange;
color: white;
border: none;
border-radius: 12px;
cursor: pointer;
transition: background-color 0.3s ease;
}

#new-quote:hover {
background-color: red;
}