generated from CodeYourFuture/Module-Template
-
-
Notifications
You must be signed in to change notification settings - Fork 147
NW | ITP-May-25 | Geraldine Edwards | Module-Data-Groups | Sprint-3 | Quote Generator App #586
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
Geraldine-Edwards
wants to merge
1
commit into
CodeYourFuture:main
Choose a base branch
from
Geraldine-Edwards:feature/quote-generator
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,29 @@ | ||
//test expects this initial quote to be displayed | ||
window.addEventListener("load", () => { | ||
const initialQuote = { | ||
quote: "Strive not to be a success, but rather to be of value.", | ||
author: "Albert Einstein", | ||
}; | ||
|
||
//display the initial quote and author on page load | ||
document.querySelector("#quote").innerText = initialQuote.quote; | ||
document.querySelector("#author").innerText = initialQuote.author; | ||
}); | ||
|
||
function displayRandomQuote() { | ||
//pick a random quote from the quotes array | ||
const randomQuote = pickFromArray(quotes); | ||
|
||
//display the random quote and author in the HTML elements | ||
document.querySelector("#quote").innerText = randomQuote.quote; | ||
document.querySelector("#author").innerText = randomQuote.author; | ||
} | ||
|
||
//add an event listener to the button to generate a new random quote | ||
document | ||
.querySelector("#new-quote") | ||
.addEventListener("click", displayRandomQuote); | ||
|
||
// DO NOT EDIT BELOW HERE | ||
|
||
// pickFromArray is a function which will return one item, at | ||
|
@@ -491,3 +517,4 @@ const quotes = [ | |
]; | ||
|
||
// call pickFromArray with the quotes array to check you get a random quote | ||
const randomQuote = pickFromArray(quotes); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. What does this variable do, and how is it used? What would break if you removed it? |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,88 @@ | ||
:root { | ||
--font-family: "Helvetica Neue", Arial, sans-serif; | ||
--font-size: 1.5rem; | ||
--primary-colour: darkolivegreen; | ||
--secondary-colour: linen; | ||
--text-colour: rgb(41, 58, 11); | ||
--padding: 20px; | ||
--border-radius: 10px; | ||
--box-shadow: 0 4px 8px rgba(0, 0, 0, 0.3); | ||
} | ||
|
||
h1 { | ||
font-family: var(--font-family); | ||
font-size: 2.5rem; | ||
color: var(--text-colour); | ||
text-align: center; | ||
margin-bottom: 30px; | ||
font-weight: bold; | ||
letter-spacing: 1px; | ||
} | ||
body { | ||
font-family: var(--font-family); | ||
background-color: var(--secondary-colour); | ||
margin: 0; | ||
padding: 40px 20px; | ||
display: flex; | ||
flex-direction: column; | ||
align-items: center; | ||
min-height: 100vh; | ||
} | ||
button { | ||
background-color: var(--secondary-colour); | ||
color: var(--text-colour); | ||
font-family: var(--font-family); | ||
font-size: 1.2rem; | ||
padding: var(--padding); | ||
margin-top: 30px; | ||
border: none; | ||
border-radius: var(--border-radius); | ||
box-shadow: var(--box-shadow); | ||
cursor: pointer; | ||
transition: background-color 0.3s ease; | ||
} | ||
button:hover { | ||
transform: translateY(-2px); | ||
box-shadow: 0 6px 12px rgba(0, 0, 0, 0.4); | ||
} | ||
|
||
/* Add click down effect */ | ||
button:active { | ||
transform: translateY(2px); | ||
box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2); | ||
} | ||
|
||
#quote-container { | ||
background-color: var(--primary-colour); | ||
width: 600px; | ||
height: 400px; | ||
padding: var(--padding); | ||
border-radius: var(--border-radius); | ||
box-shadow: var(--box-shadow); | ||
display: flex; | ||
flex-direction: column; | ||
justify-content: center; | ||
align-items: center; | ||
} | ||
|
||
#quote-box { | ||
background-color: var(--secondary-colour); | ||
padding: var(--padding); | ||
color: var(--text-colour); | ||
border-radius: var(--border-radius); | ||
box-shadow: var(--box-shadow); | ||
display: flex; | ||
flex-direction: column; | ||
justify-content: center; | ||
align-items: center; | ||
} | ||
|
||
#quote { | ||
font-size: var(--font-size); | ||
text-align: center; | ||
} | ||
#author { | ||
font-size: 1rem; | ||
font-style: italic; | ||
font-weight: bold; | ||
} |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This "set both elements to show the quote details" behaviour is repeated twice in your app - if we needed to change it in the future, we'd need to change both locations. Can you think of a way to avoid this?