-
Notifications
You must be signed in to change notification settings - Fork 0
Quote generator #5
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
base: main
Are you sure you want to change the base?
Conversation
📝 WalkthroughWalkthroughThis change adds a functional quote generator web application with automatic rotation capability. The HTML is restructured with a styled container and auto-play control, JavaScript implements quote selection and interval-based cycling with event listeners, and CSS provides centered layout with flexbox positioning. Changes
Sequence Diagram(s)sequenceDiagram
participant User
participant Browser as Browser/DOM
participant JS as JavaScript
participant Timer as Timer System
User->>Browser: Click "New quote" button
Browser->>JS: Trigger "new-quote" click event
JS->>JS: Call showNewQuote()
JS->>JS: Select random quote
JS->>Browser: Update `#quote` and `#author`
Browser->>User: Display new quote
Note over User,Timer: Auto-play flow
User->>Browser: Check "auto-play" checkbox
Browser->>JS: Trigger "auto-play" change event
JS->>JS: Call autoPlay()
JS->>Timer: Start 60-second interval
Timer->>JS: Fire interval callback
JS->>JS: Call showNewQuote()
JS->>Browser: Update `#quote` and `#author`
Browser->>User: Display new quote
Note over User,Timer: Repeats every 60 seconds until unchecked
User->>Browser: Uncheck "auto-play" checkbox
Browser->>JS: Trigger "auto-play" change event
JS->>Timer: Clear interval (timerId)
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes 🚥 Pre-merge checks | ✅ 1 | ❌ 2❌ Failed checks (1 warning, 1 inconclusive)
✅ Passed checks (1 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing touches
Comment |
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.
Actionable comments posted: 2
🤖 Fix all issues with AI agents
In `@Sprint-3/quote-generator/quotes.js`:
- Around line 9-10: The quote string currently opens with a double-quote but
never closes it; update the assignment to quoteTextP (use quoteTextP.innerText
and the quoteProperty.quote value) so the displayed text wraps the quote in both
opening and closing quotes (e.g., concatenate or template the closing " after
quoteProperty.quote) to produce a properly formatted quoted string.
In `@Sprint-3/quote-generator/style.css`:
- Around line 2-16: `#quoteContent` is positioned absolutely with fixed width and
negative margins which bypasses the body flex centering and will overflow on
small viewports; remove position: absolute and the negative margin, let body
(display:flex) center it, and make `#quoteContent` responsive by replacing fixed
width with max-width (e.g., max-width:900px) and a percentage-based width (e.g.,
width:90% or similar) plus appropriate padding and box-sizing so the container
scales on phones while staying centered by the body flex rules.
🧹 Nitpick comments (1)
Sprint-3/quote-generator/index.html (1)
11-21: Make dynamic text a live region for screen readersBecause the quote and auto‑play state update via JS, screen readers may not announce those changes. Would you consider marking them as live regions so updates are read out automatically?
♿ Suggested accessibility tweak
- <p id="quote"></p> - <p id="author"></p> + <p id="quote" aria-live="polite"></p> + <p id="author" aria-live="polite"></p> ... - <p id="auto-play-state"></p> + <p id="auto-play-state" role="status" aria-live="polite"></p>
📜 Review details
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
⛔ Files ignored due to path filters (1)
Sprint-3/quote-generator/package-lock.jsonis excluded by!**/package-lock.json
📒 Files selected for processing (3)
Sprint-3/quote-generator/index.htmlSprint-3/quote-generator/quotes.jsSprint-3/quote-generator/style.css
🔇 Additional comments (1)
Sprint-3/quote-generator/quotes.js (1)
1-20: Tighten up variable scoping to avoid implicit globals and fix the quote formattingI've noticed that
quoteTextP,quoteAuthorP, andtimerIdare assigned without being declared. This creates implicit globals—which works today, but what happens if this code ever moves into strict mode or becomes a module? They'll fail silently or throw. Also, on line 9, there's an opening quote"that never closes, so your quote text will display as"[quote]instead of"[quote]".Have you considered pulling those DOM element lookups out to the top level (like you did with
button,checkbox, andautoPlayState) and declaringtimerIdonce? That way you'd look up the elements once, reuse them, and keep everything declared properly.🔧 Suggested adjustment
const button = document.getElementById("new-quote"); const checkbox = document.getElementById("auto-play"); const autoPlayState = document.getElementById("auto-play-state"); +const quoteTextP = document.getElementById("quote"); +const quoteAuthorP = document.getElementById("author"); +let timerId = null; function showNewQuote() { const quoteProperty = pickFromArray(quotes); - quoteTextP = document.querySelector("#quote"); - quoteAuthorP = document.querySelector("#author"); quoteTextP.innerText = `"${quoteProperty.quote}"`; quoteAuthorP.innerText = `- ${quoteProperty.author}`; }
✏️ Tip: You can disable this entire section by setting review_details to false in your review settings.
| quoteTextP.innerText = `"${quoteProperty.quote}`; | ||
| quoteAuthorP.innerText = `- ${quoteProperty.author}`; |
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.
🧩 Analysis chain
🏁 Script executed:
find . -name "quotes.js" -type fRepository: Droid-An/Module-Data-Groups
Length of output: 107
🏁 Script executed:
cat -n ./Sprint-3/quote-generator/quotes.js | head -20Repository: Droid-An/Module-Data-Groups
Length of output: 912
Add a closing quotation mark to complete the quote formatting
I've noticed the quote display opens with " but never closes it—so users will see "Some quote text instead of "Some quote text". How could you adjust line 9 to include both opening and closing quotation marks for consistent formatting?
🪧 Suggested fix
- quoteTextP.innerText = `"${quoteProperty.quote}`;
+ quoteTextP.innerText = `"${quoteProperty.quote}"`;📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| quoteTextP.innerText = `"${quoteProperty.quote}`; | |
| quoteAuthorP.innerText = `- ${quoteProperty.author}`; | |
| quoteTextP.innerText = `"${quoteProperty.quote}"`; | |
| quoteAuthorP.innerText = `- ${quoteProperty.author}`; |
🤖 Prompt for AI Agents
In `@Sprint-3/quote-generator/quotes.js` around lines 9 - 10, The quote string
currently opens with a double-quote but never closes it; update the assignment
to quoteTextP (use quoteTextP.innerText and the quoteProperty.quote value) so
the displayed text wraps the quote in both opening and closing quotes (e.g.,
concatenate or template the closing " after quoteProperty.quote) to produce a
properly formatted quoted string.
| body { | ||
| display: flex; | ||
| justify-content: center; | ||
| align-items: center; | ||
| background-color: aqua; | ||
| } | ||
|
|
||
| #quoteContent { | ||
| position: absolute; | ||
| top: 50%; | ||
| width: 900px; | ||
| margin: -100px 0 0 -100px; | ||
| background-color: aliceblue; | ||
| padding: 20px; | ||
| } |
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.
Rely on flexbox + responsive width for centering
Line 2-16: with body as flex, #quoteContent being position: absolute plus a fixed width and negative margins sidesteps flex centering and can overflow on smaller screens—what would happen on a phone viewport? Could we let flex do the centering and make the container responsive instead?
🔧 Suggested adjustment
body {
display: flex;
justify-content: center;
align-items: center;
background-color: aqua;
+ min-height: 100vh;
}
`#quoteContent` {
- position: absolute;
- top: 50%;
- width: 900px;
- margin: -100px 0 0 -100px;
+ position: relative;
+ width: min(900px, 90vw);
+ margin: 0;
background-color: aliceblue;
padding: 20px;
}📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| body { | |
| display: flex; | |
| justify-content: center; | |
| align-items: center; | |
| background-color: aqua; | |
| } | |
| #quoteContent { | |
| position: absolute; | |
| top: 50%; | |
| width: 900px; | |
| margin: -100px 0 0 -100px; | |
| background-color: aliceblue; | |
| padding: 20px; | |
| } | |
| body { | |
| display: flex; | |
| justify-content: center; | |
| align-items: center; | |
| background-color: aqua; | |
| min-height: 100vh; | |
| } | |
| `#quoteContent` { | |
| position: relative; | |
| width: min(900px, 90vw); | |
| margin: 0; | |
| background-color: aliceblue; | |
| padding: 20px; | |
| } |
🤖 Prompt for AI Agents
In `@Sprint-3/quote-generator/style.css` around lines 2 - 16, `#quoteContent` is
positioned absolutely with fixed width and negative margins which bypasses the
body flex centering and will overflow on small viewports; remove position:
absolute and the negative margin, let body (display:flex) center it, and make
`#quoteContent` responsive by replacing fixed width with max-width (e.g.,
max-width:900px) and a percentage-based width (e.g., width:90% or similar) plus
appropriate padding and box-sizing so the container scales on phones while
staying centered by the body flex rules.
Summary by CodeRabbit
Release Notes
New Features
Style
✏️ Tip: You can customize this high-level summary in your review settings.