Skip to content

Refactor: Extract SparkleEffect component#23

Merged
codewithaman07 merged 1 commit into
mainfrom
refactor/extract-sparkle-effect-10973287183591162512
Feb 26, 2026
Merged

Refactor: Extract SparkleEffect component#23
codewithaman07 merged 1 commit into
mainfrom
refactor/extract-sparkle-effect-10973287183591162512

Conversation

@codewithaman07
Copy link
Copy Markdown
Owner

Extracted the SparkleEffect component from app/affirmations/page.tsx to app/components/SparkleEffect.tsx to improve code reusability and maintainability.
Verified that the component renders correctly using a temporary test page and confirmed with a screenshot.
Verified that the build passes with no errors.


PR created automatically by Jules for task 10973287183591162512 started by @codewithaman07

Co-authored-by: codewithaman07 <135147451+codewithaman07@users.noreply.github.com>
@google-labs-jules
Copy link
Copy Markdown
Contributor

👋 Jules, reporting for duty! I'm here to lend a hand with this pull request.

When you start a review, I'll add a 👀 emoji to each comment to let you know I've read it. I'll focus on feedback directed at me and will do my best to stay out of conversations between you and other bots or reviewers to keep the noise down.

I'll push a commit with your requested changes shortly after. Please note there might be a delay between these steps, but rest assured I'm on the job!

For more direct control, you can switch me to Reactive Mode. When this mode is on, I will only act on comments where you specifically mention me with @jules. You can find this option in the Pull Request section of your global Jules UI settings. You can always switch back!

New to Jules? Learn more at jules.google/docs.


For security, I will only act on instructions from the user who triggered this task.

Copilot AI review requested due to automatic review settings February 26, 2026 17:12
@vercel
Copy link
Copy Markdown
Contributor

vercel Bot commented Feb 26, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
stablemind Building Building Preview, Comment Feb 26, 2026 5:12pm

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR refactors the affirmations page by extracting the inline sparkle particle/canvas effect into a reusable client component, improving reuse and keeping page-level code focused on page behavior.

Changes:

  • Added a new SparkleEffect client component under app/components/.
  • Removed the inline SparkleEffect implementation from app/affirmations/page.tsx and replaced it with an import + usage.
  • Cleaned up React imports in app/affirmations/page.tsx to match updated usage.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 3 comments.

File Description
app/components/SparkleEffect.tsx New extracted canvas particle effect component.
app/affirmations/page.tsx Removes inline component and uses extracted SparkleEffect.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +37 to +80
let animationId: number;
const animate = () => {
ctx.clearRect(0, 0, canvas.width, canvas.height);
let alive = false;

particles.forEach(p => {
p.x += p.vx;
p.y += p.vy;
p.vy += 0.1;
p.life -= 0.02;
p.opacity = Math.max(0, p.life);
p.size *= 0.99;

if (p.life > 0) {
alive = true;
ctx.save();
ctx.globalAlpha = p.opacity;
ctx.fillStyle = p.color;
ctx.beginPath();

// Draw star shape
const s = p.size;
for (let j = 0; j < 5; j++) {
const angle = (j * 4 * Math.PI) / 5 - Math.PI / 2;
const method = j === 0 ? 'moveTo' : 'lineTo';
ctx[method](
p.x + Math.cos(angle) * s,
p.y + Math.sin(angle) * s
);
}
ctx.closePath();
ctx.fill();
ctx.restore();
}
});

if (alive) {
animationId = requestAnimationFrame(animate);
}
};

animate();
return () => cancelAnimationFrame(animationId);
}, [active]);
Copy link

Copilot AI Feb 26, 2026

Choose a reason for hiding this comment

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

animationId is declared without an initializer and is always passed to cancelAnimationFrame in cleanup. Initializing it (e.g., to 0) and/or guarding the cleanup avoids any chance of calling cancelAnimationFrame with an unassigned value if the animation never schedules a frame.

Copilot uses AI. Check for mistakes.
<canvas
ref={canvasRef}
className="absolute inset-0 pointer-events-none z-50"
style={{ width: '100%', height: '100%' }}
Copy link

Copilot AI Feb 26, 2026

Choose a reason for hiding this comment

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

The canvas is purely decorative, but it isn't hidden from assistive tech. Consider adding aria-hidden="true" (or an appropriate accessible name if it conveys meaning) so screen readers don't announce an unlabeled canvas element.

Suggested change
style={{ width: '100%', height: '100%' }}
style={{ width: '100%', height: '100%' }}
aria-hidden="true"

Copilot uses AI. Check for mistakes.
Comment on lines +14 to +15
canvas.width = canvas.offsetWidth;
canvas.height = canvas.offsetHeight;
Copy link

Copilot AI Feb 26, 2026

Choose a reason for hiding this comment

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

Canvas is sized using CSS pixels (offsetWidth/offsetHeight) without accounting for devicePixelRatio, which will render blurry on HiDPI/retina displays. Consider scaling the backing store by DPR (set width/height to cssSize * dpr and ctx.scale(dpr, dpr)) while keeping the CSS size unchanged.

Suggested change
canvas.width = canvas.offsetWidth;
canvas.height = canvas.offsetHeight;
const dpr = (typeof window !== 'undefined' && window.devicePixelRatio) ? window.devicePixelRatio : 1;
const rect = canvas.getBoundingClientRect();
canvas.width = rect.width * dpr;
canvas.height = rect.height * dpr;
ctx.setTransform(dpr, 0, 0, dpr, 0, 0);

Copilot uses AI. Check for mistakes.
@codewithaman07 codewithaman07 merged commit e1ac88b into main Feb 26, 2026
9 of 10 checks passed
@codewithaman07 codewithaman07 deleted the refactor/extract-sparkle-effect-10973287183591162512 branch March 9, 2026 20:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants