generated from CodeYourFuture/Module-Template
-
-
Notifications
You must be signed in to change notification settings - Fork 222
West Midlands | 25 Sep ITP | Iswat Bello | Sprint 3 | Build quote generator app #868
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
Closed
Closed
Changes from all commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
0823bcb
Update index.html <title> to "Quote Generator App"
Iswanna ecf423d
Add DOM element references for quote, author, and new quote button
Iswanna 7978167
Move quotes array to top of file so functions can access it on load
Iswanna d6cc826
Link the style.css file to the index.html file
Iswanna c47a65f
Wrap body content in a div container for styling purposes and update …
Iswanna a39b748
Format quote and author with template literals
Iswanna 58ee492
Add styles for quote generator layout and elements
Iswanna cc6a03d
Remove template literal from the quote and author inorder to align wi…
Iswanna 299c393
Updated displayRandomQuote function and event listener for predictabl…
Iswanna bf4104e
Merge branch '>feature/quote_generator' of https://github.com/Iswanna…
Iswanna e924c09
Downgrade @testing-library/user-event from v14.6.1 to v13.5.0 to fix …
Iswanna b3730bb
Fix failing tests by downgrading @testing-library/user-event to v13
Iswanna 189bed1
Merge remote-tracking branch 'origin/feature/quote_generator' to upda…
Iswanna 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
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 |
|---|---|---|
|
|
@@ -490,4 +490,23 @@ const quotes = [ | |
| }, | ||
| ]; | ||
|
|
||
| // call pickFromArray with the quotes array to check you get a random quote | ||
| // Function to display a random quote on the page | ||
| function displayRandomQuote() { | ||
| // Pick a random quote object from the quotes array | ||
| const randomQuote = pickFromArray(quotes); | ||
|
|
||
| // Update the quote text on the page | ||
| document.getElementById("quote").textContent = randomQuote.quote; | ||
|
|
||
| // Update the author name on the page | ||
| document.getElementById("author").textContent = randomQuote.author; | ||
| } | ||
|
|
||
| // Add a click event listener to the "New quote" button | ||
| document.getElementById("new-quote").addEventListener("click", () => { | ||
|
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. This is good! but we can make it cleaner by using a named function. |
||
| // When the button is clicked, display a new random quote | ||
| displayRandomQuote(); | ||
| }); | ||
|
|
||
| // show a random quote when page loads | ||
| displayRandomQuote(); | ||
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 +1,58 @@ | ||
| /** Write your CSS in here **/ | ||
| /* Reset some default styles */ | ||
| body { | ||
| font-family: "Helvetica", "Arial", sans-serif; | ||
| background-color: #ec8a09; | ||
| color: #333; | ||
| display: flex; | ||
| justify-content: center; | ||
| align-items: center; | ||
| min-height: 100vh; | ||
| margin: 0; | ||
| padding: 20px; | ||
| text-align: center; | ||
| } | ||
|
|
||
| .quote-container { | ||
| display: flex; | ||
| flex-direction: column; /* stack quote, author, button vertically */ | ||
| align-items: center; /* center quote and author horizontally */ | ||
| background-color: #f7f3ee; | ||
| padding: 30px 40px; | ||
| border-radius: 15px; | ||
| box-shadow: 0 8px 20px rgba(0, 0, 0, 0.1); | ||
| max-width: 600px; | ||
| width: 100%; | ||
| } | ||
|
|
||
| #quote { | ||
| font-size: 1.5rem; | ||
| font-style: italic; | ||
| margin-bottom: 15px; | ||
| color: #f86510; | ||
| } | ||
|
|
||
| #author { | ||
| font-size: 1.2rem; | ||
| font-weight: bold; | ||
| color: #f86510; | ||
| margin-bottom: 20px; | ||
| align-self: flex-end; /* moves author to the right */ | ||
| } | ||
|
|
||
| #new-quote { | ||
| align-self: flex-end; /* pushes button to the right edge of container */ | ||
| margin-top: 20px; /* optional spacing from the quote */ | ||
| background-color: #4caf50; | ||
| color: white; | ||
| border: none; | ||
| padding: 12px 25px; | ||
| border-radius: 8px; | ||
| font-size: 1rem; | ||
| cursor: pointer; | ||
| transition: background-color 0.3s ease; | ||
| } | ||
|
|
||
| #new-quote:hover { | ||
| background-color: #45a049; | ||
| } |
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.
Good job keeping displayRandomQuote() focused on a single responsibility — fetching a quote and updating the DOM. This helps keep the logic readable and easy to maintain.
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.
Thank you so much, @jaymes15.