Skip to content

Conversation

@Arnab-Mandal1
Copy link
Collaborator

@Arnab-Mandal1 Arnab-Mandal1 commented Jan 21, 2026

Description

This PR introduces comprehensive TSDoc comments to the Spinner component. The goal is to improve code readability, maintainability, and provide better IDE support for developers using the component. The documentation now clearly outlines the component's purpose, its props, their types, default values, and provides usage examples.

Type of Change

  • Documentation update

Changes Made

  • Added a detailed TSDoc block for the Spinner functional component.
  • Documented the props.size property, including its accepted values ("sm", "md", "lg") and their corresponding pixel dimensions.
  • Documented the props.color property, explaining its usage and default value.
  • Included @component, @returns, and @example tags for rich documentation generation and IDE hints.

Testing Done

  • All tests pass (no functional changes were made, only documentation).
  • Added new tests (not applicable for documentation changes).
  • Manual testing completed (visually confirmed the spinner still renders correctly with various sizes and colors).

Screenshots (if applicable)

N/A (Documentation change, no visual impact on the component's rendering beyond what was already there).

Related Issues

Closes #issue_number (Please replace with actual issue number if applicable)

Checklist

  • Code follows project style guidelines
  • Self-review completed
  • Comments added for complex logic (TSDoc serves this purpose for the component)
  • Documentation updated (this is the primary change)
  • No console.log or debugging code
  • All tests passing

Summary by CodeRabbit

  • New Features
    • Added a new loading Spinner component with three size variants (small, medium, large) and customizable color options.
    • Component supports inheriting color from parent containers for seamless integration.
    • Includes comprehensive visual documentation and usage examples.

✏️ Tip: You can customize this high-level summary in your review settings.

## Description
Implemented a reusable `Spinner` atom component to indicate loading states or ongoing processes within the application. This component renders a lightweight, accessible SVG animation and supports customization for size and color to fit various UI contexts.
@Arnab-Mandal1 Arnab-Mandal1 self-assigned this Jan 21, 2026
@Arnab-Mandal1 Arnab-Mandal1 added the enhancement New feature or request label Jan 21, 2026
@coderabbitai
Copy link
Contributor

coderabbitai bot commented Jan 21, 2026

📝 Walkthrough

Walkthrough

A new Spinner component is introduced with type definitions and Storybook stories. The component renders an animated SVG circle with configurable size ("sm", "md", "lg"), color, and className. It dynamically computes SVG dimensions and stroke width, includes accessibility attributes, and demonstrates usage through four story variations.

Changes

Cohort / File(s) Summary
Spinner Component Implementation
src/components/atoms/spinner/SpinnerProps.ts, src/components/atoms/spinner/Spinner.tsx
New Spinner React component with TypeScript prop types. SpinnerProps defines optional size, color, and className. Spinner renders animated SVG with size-to-pixel mapping (sm=16, md=24, lg=32) and dynamic strokeWidth calculation. Includes accessible title and rotation animation.
Component Stories
src/components/atoms/spinner/Spinner.stories.tsx
Four Storybook stories: Default (single spinner), Sizes (three spinners with varying sizes), Colors (four distinct colored spinners), and InheritColor (spinner inheriting parent container's text color). Meta export provides Storybook configuration.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~8 minutes

Suggested reviewers

  • dbc2201
  • KARUNANS2004
  • rohit3171999

Poem

🐰 A spinner spins, round and round,
With sizes small to large it's found,
SVG strokes dance in the light,
Colors twirl, accessibility bright! ✨

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The pull request title accurately describes the main change: introducing a new Spinner component with accessibility features and SVG-based rendering.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing touches
  • 📝 Generate docstrings

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 Fix all issues with AI agents
In `@src/components/atoms/spinner/Spinner.tsx`:
- Around line 46-52: The SVG in the Spinner component is missing the
accessibility attributes promised in the docs; update the <svg> element in
Spinner.tsx (inside the Spinner component where width/height are set using
pixelSize and className) to include role="status" and aria-label="Loading" (keep
focusable="false") so the spinner is announced correctly by assistive
technologies.
🧹 Nitpick comments (1)
src/components/atoms/spinner/Spinner.stories.tsx (1)

16-20: Prefer Tailwind utility classes over inline styles/hex colors in stories.
Inline styles and hex values bypass the project’s Tailwind/DaisyUI styling rule; the stories can demonstrate currentColor via text color utilities. As per coding guidelines, ...

♻️ Suggested refactor
 export const Default: Story = {
     args: {
         size: "md",
-        color: "#2563eb",
+        className: "text-blue-600",
     },
 };

 export const Sizes: Story = {
     render: () => (
-        <div style={{display: "flex", gap: 16, alignItems: "center"}}>
-            <Spinner size="sm" color="#2563eb"/>
-            <Spinner size="md" color="#2563eb"/>
-            <Spinner size="lg" color="#2563eb"/>
+        <div className="flex items-center gap-4 text-blue-600">
+            <Spinner size="sm"/>
+            <Spinner size="md"/>
+            <Spinner size="lg"/>
         </div>
     ),
 };

 export const Colors: Story = {
     render: () => (
-        <div style={{display: "flex", gap: 16, alignItems: "center"}}>
-            <Spinner color="#ef4444"/> {/* red */}
-            <Spinner color="#22c55e"/> {/* green */}
-            <Spinner color="#f59e0b"/> {/* amber */}
-            <Spinner color="#0ea5e9"/> {/* sky */}
+        <div className="flex items-center gap-4">
+            <Spinner className="text-red-500"/> {/* red */}
+            <Spinner className="text-green-500"/> {/* green */}
+            <Spinner className="text-amber-500"/> {/* amber */}
+            <Spinner className="text-sky-500"/> {/* sky */}
         </div>
     ),
 };

 export const InheritColor: Story = {
     render: () => (
-        <div style={{color: "#7c3aed"}}>
+        <div className="text-violet-600">
             <Spinner/>
         </div>
     ),
 };

Also applies to: 27-33, 41-46, 55-56

Comment on lines +46 to +52
<svg
width={pixelSize}
height={pixelSize}
viewBox="0 0 50 50"
className={className}
focusable="false"
>
Copy link
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟠 Major

Add the advertised accessibility attributes to the SVG.
The docs state role="status" and aria-label="Loading", but the SVG omits them, weakening accessibility and contradicting the comment.

🔧 Proposed fix
         <svg
             width={pixelSize}
             height={pixelSize}
             viewBox="0 0 50 50"
             className={className}
+            role="status"
+            aria-label="Loading"
             focusable="false"
         >
📝 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.

Suggested change
<svg
width={pixelSize}
height={pixelSize}
viewBox="0 0 50 50"
className={className}
focusable="false"
>
<svg
width={pixelSize}
height={pixelSize}
viewBox="0 0 50 50"
className={className}
role="status"
aria-label="Loading"
focusable="false"
>
🤖 Prompt for AI Agents
In `@src/components/atoms/spinner/Spinner.tsx` around lines 46 - 52, The SVG in
the Spinner component is missing the accessibility attributes promised in the
docs; update the <svg> element in Spinner.tsx (inside the Spinner component
where width/height are set using pixelSize and className) to include
role="status" and aria-label="Loading" (keep focusable="false") so the spinner
is announced correctly by assistive technologies.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants