Skip to content

Add support for custom colors to FwbProgress and FwbSpinner #393

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
wants to merge 7 commits into
base: main
Choose a base branch
from

Conversation

wazeerc
Copy link
Contributor

@wazeerc wazeerc commented May 22, 2025

Summary by CodeRabbit

  • New Features

    • Progress bar and spinner components now support custom hex color values in addition to predefined color options.
    • Progress bar labels and spinner fills dynamically adapt to custom colors.
  • Documentation

    • Added new examples demonstrating custom color usage for both progress bar and spinner components.
    • Updated progress bar examples to use whole-number progress values and include a custom color instance.
    • Expanded API documentation to detail props and custom color support for progress bar and spinner components.

Copy link
Contributor

coderabbitai bot commented May 22, 2025

Warning

Rate limit exceeded

@wazeerc has exceeded the limit for the number of commits or files that can be reviewed per hour. Please wait 18 minutes and 4 seconds before requesting another review.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

📥 Commits

Reviewing files that changed from the base of the PR and between 92c2c9e and df7c59a.

📒 Files selected for processing (1)
  • src/components/FwbProgress/composables/useProgressClasses.ts (3 hunks)

Walkthrough

This update introduces support for custom hex color values in both the progress bar and spinner components. Type definitions and composables are modified to recognize and handle custom colors. Documentation and example files are updated to demonstrate usage with custom hex color values, including new examples for both components.

Changes

Files/Paths Change Summary
docs/components/progress.md
docs/components/progress/examples/FwbProgressExampleColor.vue
Updated progress bar examples: progress values changed to integer increments, and a new example with a custom hex color (#3fb984) and label "Custom color" was added.
docs/components/spinner.md
docs/components/spinner/examples/FwbSpinnerExampleColor.vue
Added a new spinner example using a custom hex color (#3fb984) to the color demonstration section.
src/components/FwbProgress/types.ts
src/components/FwbSpinner/types.ts
Introduced CustomColor type as a template literal for hex colors. Expanded ProgressVariant and SpinnerColor to include CustomColor as a valid option.
src/components/FwbProgress/composables/useProgressClasses.ts Updated composable to compute and expose customColor. Adjusted class logic to apply custom colors when provided, omitting default color classes.
src/components/FwbProgress/FwbProgress.vue Applied conditional inline styles for custom colors to labels and progress bar. Used customColor from composable to dynamically style component elements.
src/components/FwbSpinner/composables/useSpinnerClasses.ts Modified composable to return customColor and handle cases where the color is not a predefined value, enabling custom color support.
src/components/FwbSpinner/FwbSpinner.vue Updated spinner SVG to use custom color via CSS variable and dynamic fill when a custom color is provided. Adjusted destructure from composable to include customColor.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant ProgressComponent
    participant SpinnerComponent

    User->>ProgressComponent: Set color prop (named or hex)
    ProgressComponent->>useProgressClasses: Compute classes and customColor
    useProgressClasses-->>ProgressComponent: Return classes, customColor
    ProgressComponent->>ProgressComponent: Render bar/labels with styles
    Note right of ProgressComponent: If customColor, apply inline style

    User->>SpinnerComponent: Set color prop (named or hex)
    SpinnerComponent->>useSpinnerClasses: Compute classes and customColor
    useSpinnerClasses-->>SpinnerComponent: Return classes, customColor
    SpinnerComponent->>SpinnerComponent: Render SVG with fill/CSS var
    Note right of SpinnerComponent: If customColor, apply CSS variable
Loading

Possibly related issues

Suggested labels

🔧 enhancement

Poem

A rabbit hopped up, its code all aglow,
With colors so vivid, in hex they now show!
Progress and spinners, in custom delight,
#3fb984 shining so bright.
Docs and examples, all fresh and anew—
Oh what a colorful thing we now do!
🐇✨

✨ 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
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Explain this complex logic.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai explain this code block.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and explain its main purpose.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link

netlify bot commented May 22, 2025

Deploy Preview for sensational-seahorse-8635f8 ready!

Name Link
🔨 Latest commit df7c59a
🔍 Latest deploy log https://app.netlify.com/projects/sensational-seahorse-8635f8/deploys/682f213fa0399800082381d8
😎 Deploy Preview https://deploy-preview-393--sensational-seahorse-8635f8.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

@wazeerc
Copy link
Contributor Author

wazeerc commented May 22, 2025

Fixes issue #390

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

🧹 Nitpick comments (1)
docs/components/spinner.md (1)

75-75: Consider updating API documentation to mention custom colors

While the example shows custom hex colors, the API props table still only lists the predefined colors without mentioning that custom hex values are supported.

Consider updating the props table to indicate that custom hex colors are also supported:

| Name  | Values                                                                                  | Default |
|-------|-----------------------------------------------------------------------------------------|---------|
- | color | `blue`, `gray`, `green`, `pink`, `purple`, `red`, `white`, `yellow`                     | `blue`  |
+ | color | `blue`, `gray`, `green`, `pink`, `purple`, `red`, `white`, `yellow`, or custom hex value (e.g., `#3fb984`) | `blue`  |
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 570e238 and 4eacdd2.

📒 Files selected for processing (10)
  • docs/components/progress.md (1 hunks)
  • docs/components/progress/examples/FwbProgressExampleColor.vue (1 hunks)
  • docs/components/spinner.md (1 hunks)
  • docs/components/spinner/examples/FwbSpinnerExampleColor.vue (1 hunks)
  • src/components/FwbProgress/FwbProgress.vue (3 hunks)
  • src/components/FwbProgress/composables/useProgressClasses.ts (4 hunks)
  • src/components/FwbProgress/types.ts (1 hunks)
  • src/components/FwbSpinner/FwbSpinner.vue (3 hunks)
  • src/components/FwbSpinner/composables/useSpinnerClasses.ts (2 hunks)
  • src/components/FwbSpinner/types.ts (1 hunks)
🧰 Additional context used
🧬 Code Graph Analysis (3)
src/components/FwbSpinner/composables/useSpinnerClasses.ts (1)
src/components/FwbSpinner/types.ts (1)
  • SpinnerColor (2-2)
src/components/FwbSpinner/types.ts (1)
src/components/FwbProgress/types.ts (1)
  • CustomColor (3-3)
src/components/FwbProgress/composables/useProgressClasses.ts (1)
src/components/FwbProgress/types.ts (1)
  • CustomColor (3-3)
🔇 Additional comments (22)
src/components/FwbProgress/types.ts (1)

3-4: Custom hex color support added correctly

The implementation adds a CustomColor type alias that enforces hex color format using a template literal type, and extends the existing ProgressVariant to support these custom colors. This is a clean approach to extend the color options without breaking existing functionality.

docs/components/spinner/examples/FwbSpinnerExampleColor.vue (1)

11-11: Custom hex color example is well integrated

The new spinner instance with a custom hex color demonstrates the feature nicely, maintaining consistency with the existing examples. This gives users a clear visual reference for how custom colors work alongside the predefined options.

docs/components/spinner.md (1)

62-62: Clear custom color example with helpful comment

Adding the custom color example with an explanatory comment is helpful for users learning the API. It clearly shows how to use a hex color value instead of a named color constant.

docs/components/progress/examples/FwbProgressExampleColor.vue (2)

5-5: Progress values updated for better visual progression

The progress values have been updated from fractional values to a clearer increasing progression (11, 22, 33, etc.), which improves the visual demonstration of the different progress states.

Also applies to: 10-10, 15-15, 20-20, 25-25, 30-30, 35-35, 40-40


42-46: Custom color progress bar example added successfully

The custom hex color progress bar example is well implemented and positioned at the end of the examples, maintaining a consistent pattern with the spinner component examples. Using a 99% progress value clearly demonstrates the custom color's appearance when the progress bar is nearly complete.

docs/components/progress.md (1)

89-97: Well-implemented documentation for custom color support.

The example has been updated to show incremental progress values and now includes a demonstration of the new custom hex color feature with #3fb984. This clearly illustrates how users can apply custom colors to the progress bar component.

src/components/FwbProgress/FwbProgress.vue (4)

7-7: Good implementation of custom color for label text.

The conditional styling ensures the label text color matches the custom color when provided, maintaining visual consistency.


13-13: Consistent styling for progress percentage text.

The progress percentage text styling matches the approach used for the label text, ensuring visual consistency when using custom colors.


24-26: Well-implemented background color application for progress bar.

The conditional styling for the progress bar background correctly applies the custom color when provided, while maintaining the existing width styling in all cases.


66-66: Appropriate destructuring of customColor property.

Adding customColor to the destructured properties ensures the component has access to the custom color value from the composable.

src/components/FwbSpinner/types.ts (1)

1-2: Well-defined type system for custom colors.

The CustomColor type definition effectively ensures type safety by requiring strings to start with '#' (for hex colors). The extension of SpinnerColor to include CustomColor maintains backward compatibility while adding support for custom hex colors.

The approach is consistent with the implementation in the progress component, promoting a unified API across components.

src/components/FwbSpinner/FwbSpinner.vue (3)

4-4: Good implementation of CSS variable for custom fill.

Using a CSS variable for the custom fill color provides flexibility for styling while ensuring the custom color is properly applied to the SVG.


16-16: Effective fallback mechanism for fill attribute.

The conditional binding ensures the path uses the custom color when provided, with a graceful fallback to 'currentFill' when no custom color is specified.


38-38: Appropriate destructuring of customColor property.

Updating the destructuring to include customColor ensures the component has access to the custom color value from the composable.

src/components/FwbSpinner/composables/useSpinnerClasses.ts (3)

41-41: Added return value customColor supports custom hex colors

The function now returns both spinnerClasses and customColor, allowing the component to handle custom hex color values alongside predefined colors.

Also applies to: 56-56


44-44: Added null coalescing operator to handle unknown colors

Good addition of the null coalescing operator to return an empty string when the color isn't found in the predefined colors map.


45-45: Added computed property for custom color handling

The customColor computed property correctly identifies when to use a custom color (when no predefined color class exists) and returns the original color value as a string in those cases.

src/components/FwbProgress/composables/useProgressClasses.ts (5)

4-4: Added import for CustomColor type

Correctly imported the CustomColor type to support hex color strings.


41-46: Updated return type to include customColor

The function's return type now properly includes the new customColor property.


52-52: Conditionally applying color classes

Good implementation to conditionally omit the default color classes when a custom color is used.


62-65: Conditionally applying outside label classes

Correctly implemented to conditionally omit the outside label color classes when a custom color is used.


71-71: Added customColor to the return object

The function now correctly returns the customColor computed property.

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 4eacdd2 and fba013c.

📒 Files selected for processing (1)
  • src/components/FwbProgress/composables/useProgressClasses.ts (4 hunks)
🧰 Additional context used
🧬 Code Graph Analysis (1)
src/components/FwbProgress/composables/useProgressClasses.ts (1)
src/components/FwbProgress/types.ts (1)
  • CustomColor (3-3)
🪛 GitHub Check: lint (18.x)
src/components/FwbProgress/composables/useProgressClasses.ts

[failure] 44-44:
Unexpected separator (,)


[failure] 43-43:
Unexpected separator (,)


[failure] 42-42:
Unexpected separator (,)


[failure] 62-62:
Expected newline between consequent and alternate of ternary expression


[failure] 62-62:
Expected newline between test and consequent of ternary expression

🪛 GitHub Actions: Node.js CI
src/components/FwbProgress/composables/useProgressClasses.ts

[error] 42-42: ESLint: Unexpected separator (,) (@stylistic/member-delimiter-style)

🔇 Additional comments (3)
src/components/FwbProgress/composables/useProgressClasses.ts (3)

47-49: Custom color implementation looks good.

The implementation correctly checks if the color value is a predefined variant before treating it as a custom color, which matches the pattern suggested in previous reviews.


52-52: Good conditional logic for custom colors.

The implementation correctly skips the predefined color classes when a custom color is provided.


71-71: Good addition of customColor to the returned object.

This properly exposes the custom color property for use in the component.

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

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between fba013c and 36b7cc1.

📒 Files selected for processing (3)
  • docs/components/progress.md (1 hunks)
  • docs/components/spinner.md (2 hunks)
  • src/components/FwbProgress/composables/useProgressClasses.ts (3 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • docs/components/spinner.md
🧰 Additional context used
🧬 Code Graph Analysis (1)
src/components/FwbProgress/composables/useProgressClasses.ts (1)
src/components/FwbProgress/types.ts (1)
  • CustomColor (3-3)
🪛 markdownlint-cli2 (0.17.2)
docs/components/progress.md

104-104: Fenced code blocks should have a language specified
null

(MD040, fenced-code-language)

🪛 GitHub Check: lint (18.x)
src/components/FwbProgress/composables/useProgressClasses.ts

[failure] 45-45:
Unexpected separator (;)


[failure] 44-44:
Unexpected separator (;)


[failure] 43-43:
Unexpected separator (;)


[failure] 42-42:
Unexpected separator (;)

🪛 GitHub Actions: Node.js CI
src/components/FwbProgress/composables/useProgressClasses.ts

[error] 42-42: ESLint: Unexpected separator (;) (@stylistic/member-delimiter-style)

🔇 Additional comments (6)
src/components/FwbProgress/composables/useProgressClasses.ts (4)

47-49: Implementation checks for custom colors properly.

The customColor computed property now correctly checks if the color value exists in the predefined variants before treating it as a custom color.


52-52: Color classes conditionally applied.

The implementation correctly omits the default color classes when a custom color is used.


61-67: Proper formatting of ternary expression.

The ternary expression is now properly formatted with line breaks, resolving previous linting issues.


73-73: Custom color property exposed.

The customColor computed property is now properly returned from the composable, allowing parent components to access it.

docs/components/progress.md (2)

89-97: Comprehensive color examples with consistent progression.

The progress examples now use incremental values (11, 22, 33, etc.) instead of arbitrary values, making the demonstration clearer. The addition of a custom hex color example effectively demonstrates the new feature.


106-116: Well-documented API props.

The API documentation clearly defines all props including the newly supported hex color values for the color prop. This provides clear guidance for developers using the component.

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.

1 participant