-
-
Notifications
You must be signed in to change notification settings - Fork 280
London | 26-ITP-Jan | Zadri Abdule | Sprint 3 | Quote Generator App #1145
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
Zadri415
wants to merge
1
commit into
CodeYourFuture:main
Choose a base branch
from
Zadri415:sprint-3/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.
+138
−7
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,15 +1,18 @@ | ||
| <!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> | ||
| <h1>hello there</h1> | ||
| <p id="quote"></p> | ||
| <p id="author"></p> | ||
| <button type="button" id="new-quote">New quote</button> | ||
| <div class="quote-app"> | ||
| <h1>hello there</h1> | ||
| <p id="quote" class="quote-text"></p> | ||
| <p id="author" class="quote-author"></p> | ||
| <button type="button" id="new-quote" class="quote-btn">New quote</button> | ||
| </div> | ||
| </body> | ||
| </html> |
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,54 @@ | ||
| function getRandomQuote(obj) { | ||
| const quoteEl = document.getElementById("quote"); | ||
| const authorEl = document.getElementById("author"); | ||
| if (!quoteEl || !authorEl) return; | ||
| quoteEl.innerText = obj.quote; | ||
| authorEl.innerText = obj.author; | ||
| } | ||
|
|
||
| function setupQuotes() { | ||
| getRandomQuote(pickFromArray(quotes)); | ||
| const quoteBtn = document.getElementById("new-quote"); | ||
| if (quoteBtn) | ||
| quoteBtn.addEventListener("click", () => | ||
| getRandomQuote(pickFromArray(quotes)) | ||
| ); | ||
| } | ||
|
|
||
| // New DOM wiring using window.onload (replaces previous readiness block) | ||
| window.onload = () => { | ||
| const quoteText = document.getElementById("quote"); | ||
| const authorText = document.getElementById("author"); | ||
| const newQuoteBtn = document.getElementById("new-quote"); | ||
| const autoPlayCheckbox = document.getElementById("auto-play"); | ||
| const autoPlayStatus = document.getElementById("auto-play-txt"); | ||
|
|
||
| let autoPlayInterval; | ||
|
|
||
| function generateQuote() { | ||
| const randomQuote = pickFromArray(quotes); | ||
| if (!randomQuote) return; | ||
| if (quoteText) quoteText.innerText = randomQuote.quote; | ||
| if (authorText) authorText.innerText = `- ${randomQuote.author}`; | ||
| } | ||
|
|
||
| generateQuote(); | ||
|
|
||
| if (newQuoteBtn) newQuoteBtn.addEventListener("click", generateQuote); | ||
|
|
||
| if (autoPlayCheckbox) { | ||
| autoPlayCheckbox.addEventListener("change", (event) => { | ||
| if (event.target.checked) { | ||
| if (autoPlayStatus) autoPlayStatus.innerText = "Auto-Play: ON"; | ||
| autoPlayInterval = setInterval(generateQuote, 5000); | ||
| } else { | ||
| if (autoPlayStatus) autoPlayStatus.innerText = "Auto-Play: OFF"; | ||
| clearInterval(autoPlayInterval); | ||
| } | ||
| }); | ||
|
Comment on lines
+39
to
+48
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. I don't see the autoplay checkbox on the web page |
||
| } | ||
| }; | ||
|
|
||
| // DO NOT EDIT BELOW HERE | ||
|
|
||
| // pickFromArray is a function which will return one item, at | ||
|
|
||
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,78 @@ | ||
| /** Write your CSS in here **/ | ||
| :root { | ||
| --mustard: #e6a918; /* main mustard */ | ||
| --mustard-dark: #c58f00; /* darker for accents */ | ||
| --panel: #ffffff; | ||
| --muted: #555555; | ||
| } | ||
|
|
||
| html, | ||
| body { | ||
| height: 100%; | ||
| margin: 0; | ||
| } | ||
|
|
||
| body { | ||
| font-family: | ||
| system-ui, | ||
| -apple-system, | ||
| "Segoe UI", | ||
| Roboto, | ||
| Helvetica, | ||
| Arial, | ||
| sans-serif; | ||
| background-color: var(--mustard); | ||
| display: flex; | ||
| align-items: center; | ||
| justify-content: center; | ||
| padding: 3rem 1rem; | ||
| } | ||
|
|
||
| .quote-app { | ||
| display: grid; | ||
| gap: 16px; | ||
| max-width: 900px; | ||
| width: 100%; | ||
| margin: 0 auto; | ||
| padding: 48px; | ||
| background-color: var(--panel); | ||
| box-shadow: 0 6px 18px rgba(0, 0, 0, 0.08); | ||
| } | ||
|
|
||
| .quote-text { | ||
| font-size: 1.9rem; | ||
| line-height: 1.3; | ||
| margin: 0 0 16px; | ||
| color: var(--mustard-dark); | ||
| } | ||
|
|
||
| .quote-author { | ||
| font-size: 1rem; | ||
| color: var(--mustard-dark); | ||
| margin: 0 0 12px 0; | ||
| text-align: right; | ||
| } | ||
|
|
||
| .quote-btn { | ||
| justify-self: end; | ||
| padding: 10px 18px; | ||
| border-radius: 6px; | ||
| border: none; | ||
| background: var(--mustard-dark); | ||
| color: #fff; | ||
| cursor: pointer; | ||
| box-shadow: 0 3px 6px rgba(0, 0, 0, 0.12); | ||
| } | ||
| .quote-btn:focus { | ||
| outline: 3px solid rgba(197, 143, 0, 0.25); | ||
| } | ||
|
|
||
| /* small responsive tweak */ | ||
| @media (max-width: 640px) { | ||
| .quote-text { | ||
| font-size: 1.25rem; | ||
| } | ||
| .quote-app { | ||
| padding: 24px; | ||
| } | ||
| } |
Oops, something went wrong.
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.
Nice that you ensure the elements exist before using them