Skip to content

Conversation

@jjagielka
Copy link
Contributor

@jjagielka jjagielka commented Nov 17, 2025

🔗 Related issue (optional)

Closes #1839


📑 Description

Button in loading mode used hard coded svg. Not it is changed to Spinner that follows the button color.


🔍 PR Type

  • Bug fix
  • Feature
  • Documentation
  • Refactor / Code cleanup
  • Build / Tooling
  • Other (please describe)

🚦 PR Status

  • Draft (work in progress, not ready for review)
  • Ready for review ✅

✅ Checklist

  • My code follows the existing code style
  • I have run pnpm check && pnpm test:e2e and all tests pass
  • CoderabbitAI review has been completed and actionable suggestions were reviewed
  • I have updated documentation if my changes require it
  • I have updated the api-check directory if a component API changed
  • My PR is based on the latest main branch (not the published npm version)
  • I have checked accessibility where applicable (ARIA, keyboard nav, etc.)
  • I have reviewed the rendered component in the browser

🧪 Screenshots / Demos (optional)


⚠️ Breaking Changes (optional)


ℹ️ Additional Information

Summary by CodeRabbit

  • New Features

    • Added a new "loading" spinner variant with refined animation and sizing.
    • Introduced three spinner color options: light, dark, and alternative.
    • Buttons now use the shared spinner component when showing loading state.
  • Documentation

    • Added an example demonstrating the new loading spinner type and color variants.

@vercel
Copy link

vercel bot commented Nov 17, 2025

@jjagielka is attempting to deploy a commit to the Themesberg Team on Vercel.

A member of the Team first needs to authorize it.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Nov 17, 2025

Walkthrough

Replaces the inline SVG spinner in Button.svelte with the new Spinner component (type="loading"), adds a loading rendering branch in Spinner.svelte, extends spinner theming with loading type and new color variants, and refactors SpinnerProps to inherit spinner variants via types.

Changes

Cohort / File(s) Summary
Button integration
src/lib/buttons/Button.svelte
Replaced inline SVG spinner with <Spinner size="4" class="ms-2" type="loading" color={actualColor} /> when loading is true so the spinner receives the button's color.
Spinner implementation
src/lib/spinner/Spinner.svelte
Added a new {:else if type === "loading"} branch that renders a compact 24×24 SVG spinner for type="loading".
Spinner theming
src/lib/spinner/theme.ts
Added type.loading = "animate-spin" and extended color variants with light, dark, and alternative mappings.
Type definitions
src/lib/types.ts
Changed SpinnerProps to `extends SpinnerVaraiants, Omit<SVGAttributes, "color"
Docs / examples
src/routes/docs-examples/components/spinner/Type.svelte
Added example usage: <Spinner type="loading" color="light" />.

Sequence Diagram(s)

sequenceDiagram
    autonumber
    actor User
    participant Button
    participant Spinner
    participant Theme

    User->>Button: render (color="light", loading=true)
    activate Button
    Button->>Spinner: render(type="loading", color=actualColor, size="4")
    deactivate Button

    activate Spinner
    Spinner->>Theme: resolve color variant for "light"
    activate Theme
    Theme-->>Spinner: classes (fill-white text-gray-900)
    deactivate Theme
    Spinner-->>User: render loading SVG with resolved classes
    deactivate Spinner
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

  • Pay attention to type propagation and the SpinnerProps change (now inherits SpinnerVaraiants and omits "color"|"type" from SVG attrs).
  • Verify Button.svelte passes the correct color prop/name expected by Spinner.
  • Confirm new loading SVG integrates with existing spinner branches and theme classes.

Possibly related PRs

Poem

🐰
I twitched my nose and hopped on by,
A button's spinner learned to try—
To wear the color that it shares,
No more lone white in midnight airs.
Hooray! the loading lights up fair. ✨

Pre-merge checks and finishing touches

❌ Failed checks (1 inconclusive)
Check name Status Explanation Resolution
Out of Scope Changes check ❓ Inconclusive Changes to Spinner component (new loading type, theme extensions) and types.ts are necessary to support the Button spinner refactor, though they extend beyond the minimal scope of the issue. Clarify whether extending Spinner capabilities (new loading type, color variants, TypeScript interface refactoring) was necessary or if a simpler solution exists.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately summarizes the main change: replacing the Button's hard-coded SVG loading spinner with the Spinner component.
Linked Issues check ✅ Passed The PR successfully addresses issue #1839 by replacing the hard-coded SVG spinner with a Spinner component that respects the button's color prop via the actualColor variable.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Description check ✅ Passed PR description follows the template structure with all required sections completed: Related issue (#1839), Description, PR Type (Bug fix selected), PR Status (Ready for review selected), and comprehensive Checklist completion.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

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: 2

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 28a4278 and 5b19d24.

📒 Files selected for processing (5)
  • src/lib/buttons/Button.svelte (2 hunks)
  • src/lib/spinner/Spinner.svelte (1 hunks)
  • src/lib/spinner/theme.ts (2 hunks)
  • src/lib/types.ts (2 hunks)
  • src/routes/docs-examples/components/spinner/Type.svelte (1 hunks)
🧰 Additional context used
🧠 Learnings (1)
📚 Learning: 2024-10-18T09:38:03.879Z
Learnt from: Chizaruu
Repo: themesberg/flowbite-svelte PR: 1465
File: src/lib/forms/Timepicker.svelte:105-116
Timestamp: 2024-10-18T09:38:03.879Z
Learning: In `Timepicker.svelte`, the `Dropdown` opens as intended and is used exclusively with the 'dropdown' and 'timerange-dropdown' Timepicker types.

Applied to files:

  • src/lib/types.ts
🧬 Code graph analysis (1)
src/lib/types.ts (1)
src/lib/spinner/theme.ts (1)
  • SpinnerVaraiants (3-3)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
  • GitHub Check: Playwright and Lint
🔇 Additional comments (6)
src/routes/docs-examples/components/spinner/Type.svelte (1)

10-10: LGTM! Documentation example added.

The new example demonstrates the loading spinner type with the light color variant, aligning with the new Spinner API.

src/lib/spinner/theme.ts (2)

14-14: LGTM! New spinner variants added correctly.

The new loading type with animate-spin animation and the three new color variants (light, dark, alternative) properly support the Button component's loading state integration.

Also applies to: 37-39


13-13: The orbit variant empty string is intentional and correct.

The orbit spinner uses SVG's native <animateTransform> element to rotate three circles continuously, which doesn't require Tailwind CSS animation classes. Unlike other types (default, pulse, loading) that rely on CSS animations, the orbit type's animation is handled entirely by SVG animation primitives. The empty string is the appropriate value for this variant.

src/lib/types.ts (2)

1554-1557: LGTM! SpinnerProps correctly refactored to use variants.

The change properly delegates color and type handling to SpinnerVaraiants while preserving currentFill and currentColor as explicit fields. This aligns with the new variant system introduced in the spinner theme.


981-981: Minor whitespace change, no semantic impact.

The formatting adjustment in the onselect callback type has no functional impact.

src/lib/buttons/Button.svelte (1)

7-7: No color type compatibility issue exists.

All values of ButtonProps["color"] are valid for SpinnerProps["color"]. The Button component uses only the button theme variant (which has 23 supported colors), and all of these colors are supported by the Spinner component. The gradient-only color variants (e.g., purpleToBlue, cyanToBlue) belong to GradientButtonProps, not ButtonProps, and are never passed to the Spinner, which only receives the button component's colors.

Likely an incorrect or invalid review comment.

@jjagielka
Copy link
Contributor Author

Oops! Haven't seen this is already tackled by PR #1838

@jjagielka jjagielka closed this Nov 25, 2025
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.

Button: Loading spinner doesn't respect color prop

1 participant