Skip to content
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

fix(theme): added stripe color gradients for progress #3938

Open
wants to merge 8 commits into
base: canary
Choose a base branch
from

Conversation

ShrinidhiUpadhyaya
Copy link
Contributor

@ShrinidhiUpadhyaya ShrinidhiUpadhyaya commented Oct 24, 2024

Closes #1933

📝 Description

  • Added stripe gradient colors for colors "primary", "secondary", "success", "warning" and "danger".
  • Renamed bg-stripe-gradient to bg-stripe-gradient-default
  • Changed color of bg-stripe-gradient-default to #3f3f46
  • Replaced colors format from rgba to hex.
  • Colors used
    • Default #3f3f46, transparent
    • Primary #004493, #006FEE
    • Secondary #6020A0, #9353d3
    • Success #0E793C, #17c964
    • Warning #936316, #f5a524
    • Danger #920B3A, #f31260

⛳️ Current behavior (updates)

image

🚀 New behavior

image

💣 Is this a breaking change (Yes/No):

📝 Additional Information

  • All the colors are used from NextUI Colors, please let me know if any color needs to be changed.
  • pnpm build to see the new colors.

Summary by CodeRabbit

  • New Features

    • Introduced stripe color gradients for progress indicators, enhancing the visual appeal of progress elements.
    • Added multiple gradient options for various color themes (default, primary, secondary, success, warning, danger).
  • Bug Fixes

    • Improved handling of theme configurations and gradient definitions.

Copy link

vercel bot commented Oct 24, 2024

@ShrinidhiUpadhyaya is attempting to deploy a commit to the NextUI Inc Team on Vercel.

A member of the Team first needs to authorize it.

Copy link

changeset-bot bot commented Oct 24, 2024

🦋 Changeset detected

Latest commit: 3775ca4

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 2 packages
Name Type
@nextui-org/theme Patch
@nextui-org/react Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

Copy link
Contributor

coderabbitai bot commented Oct 24, 2024

Walkthrough

The pull request introduces enhancements to the @nextui-org/theme package by adding stripe color gradients for progress indicators. It updates the progress component to utilize new gradient classes based on the color variant and modifies the theme configuration to include multiple gradient definitions. These changes aim to improve the visual representation of progress components in accordance with issue #1933.

Changes

File Change Summary
.changeset/poor-moose-double.md Added patch for stripe color gradients in @nextui-org/theme.
packages/core/theme/src/components/progress.ts Updated indicator class for isStriped variant and added new compound variants for color-specific indicators.
packages/core/theme/src/plugin.ts Enhanced theme configuration with multiple stripe gradient definitions and refined theme handling.
packages/core/theme/src/utils/tw-merge-config.ts Modified twMergeConfig to include new gradient class entries for background images.

Assessment against linked issues

Objective Addressed Explanation
Enhance progress component to support color variants (#1933)

Possibly related PRs

Suggested reviewers

  • wingkwong
  • jrgarciadev

Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

❤️ 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.
    • Generate unit testing code for this file.
    • 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 generate unit testing code for this file.
    • @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 generate unit testing code.
    • @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.

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 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.

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

🧹 Outside diff range and nitpick comments (3)
.changeset/poor-moose-double.md (1)

1-5: Enhance the changeset description for better changelog clarity.

The patch version bump is appropriate for this bug fix. However, the description could be more detailed to better document the changes in the changelog.

Consider expanding the description to:

---
"@nextui-org/theme": patch
---

-added stripe color gradients for progress (#1933)
+fix(progress): add stripe color gradients for progress component (#1933)
+
+- Fixed progress component not displaying specified colors with isStriped property
+- Added new gradient classes for primary, secondary, success, warning, and danger variants
+- Updated background gradient colors from RGBA to HEX format
packages/core/theme/src/components/progress.ts (1)

153-161: Maintain consistent spacing between compound variants.

There are inconsistent empty lines between the compound variants. Consider removing the extra empty lines at 153 and 161 to maintain consistent spacing throughout the configuration.

packages/core/theme/src/plugin.ts (1)

220-231: LGTM! The gradient definitions effectively address the Progress component color issue.

The implementation provides a comprehensive set of stripe gradients for different color variants, effectively fixing issue #1933. The consistent 45-degree angle and 25% color stops create a visually appealing striped pattern.

Consider adding comments to document the color pairs and their use cases. This would help future maintainers understand the color relationships and make updates easier.

Example:

 backgroundImage: {
+  // Default: Neutral gray stripes (zinc-700)
   "stripe-gradient-default":
     "linear-gradient(45deg, #3f3f46 25%, transparent 25%, transparent 50%, #3f3f46 50%, #3f3f46 75%, transparent 75%, transparent)",
+  // Primary: Blue stripes (darker -> lighter)
   "stripe-gradient-primary":
     "linear-gradient(45deg, #004493 25%, #006FEE 25%, #006FEE 50%, #004493 50%, #004493 75%, #006FEE 75%, #006FEE)",
   // ... (document remaining color pairs)
📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL

📥 Commits

Files that changed from the base of the PR and between c847ffb and 781d13a.

📒 Files selected for processing (4)
  • .changeset/poor-moose-double.md (1 hunks)
  • packages/core/theme/src/components/progress.ts (2 hunks)
  • packages/core/theme/src/plugin.ts (1 hunks)
  • packages/core/theme/src/utils/tw-merge-config.ts (1 hunks)
🔇 Additional comments (4)
packages/core/theme/src/utils/tw-merge-config.ts (1)

14-21: LGTM! The gradient class configuration looks complete.

The changes correctly implement all the required color variants for the striped progress bars, following a consistent naming convention.

Let's verify that these gradients are properly defined in the theme configuration:

✅ Verification successful

Let me explain the new approach:

  1. First command searches for any files containing "stripe-gradient" to locate relevant configuration files
  2. Second command looks for background image configurations which might define these gradients using a broader pattern match

This should help us verify if the gradients are properly defined in the theme configuration.


The previous search revealed that gradient definitions are likely in plugin.ts, but we only saw the default gradient. Let's verify if all the required variants (primary, secondary, success, warning, danger) are properly defined.


The previous search had a regex error, but we found important information in progress.ts showing that all stripe gradient classes are being used in compound variants. Let's examine plugin.ts directly to verify if all these gradients are properly defined in the theme configuration.


All gradient definitions are properly configured and match the tw-merge config

The verification is complete and successful. The code shows that:

  1. All stripe gradients are properly defined in plugin.ts under backgroundImage configuration
  2. Each variant (default, primary, secondary, success, warning, danger) has its corresponding gradient definition
  3. The gradients are properly used in the Progress component's compound variants
  4. The naming convention in tw-merge-config.ts matches exactly with the actual implementations

Points of verification:

  • ✓ Gradient classes in tw-merge-config.ts match the theme definitions
  • ✓ Each gradient has a proper linear-gradient implementation with appropriate color values
  • ✓ The Progress component correctly utilizes these gradients in its compound variants
🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify that all gradient classes have corresponding definitions in the theme configuration

# Test: Search for gradient definitions in theme files
# Expect: Each bg-stripe-gradient-* class should have a corresponding gradient definition
rg -A 1 "backgroundImage.*stripe-gradient-" packages/core/theme/src/

Length of output: 70


Script:

#!/bin/bash
# Let's try a broader search for gradient-related configurations
# First, let's check theme configuration files
rg -l "stripe-gradient" packages/core/theme/src/

# Then, let's look for any backgroundImage or background-image configurations
rg -A 2 "backgroundImage|background-image" packages/core/theme/src/

Length of output: 760


Script:

#!/bin/bash
# Let's check the content of plugin.ts to see all gradient definitions
rg -A 10 "backgroundImage: {" packages/core/theme/src/plugin.ts

# Also check progress.ts since it was found in the previous search
cat packages/core/theme/src/components/progress.ts

Length of output: 4469


Script:

#!/bin/bash
# Let's try a different approach to search for backgroundImage in plugin.ts
cat packages/core/theme/src/plugin.ts

Length of output: 10850

packages/core/theme/src/components/progress.ts (2)

95-95: LGTM! Clear and consistent naming convention.

The renamed class bg-stripe-gradient-default follows a more explicit naming pattern that aligns well with other color variants.


132-168: Verify visual appearance of all color variants.

The implementation looks correct, but please ensure that all color variants have been tested with the isStriped property, especially edge cases:

  1. Color transitions during progress updates
  2. Appearance at different progress values (0%, 50%, 100%)
  3. Interaction with different size variants
  4. Interaction with different radius variants
✅ Verification successful

Let me check the gradient definitions in the theme files to ensure they are properly defined and consistent.


Stripe gradients implementation is correctly configured and consistent

The verification shows that:

  • All color variants (default, primary, secondary, success, warning, danger) have proper gradient definitions in plugin.ts
  • The gradients use consistent color pairs for each variant, creating a proper striped effect
  • The gradient utilities are correctly registered in the Tailwind merge configuration
  • The implementation in progress.ts correctly references these gradient classes

The original review comment's request for visual testing remains valid, but the technical implementation is sound and complete.

Points to manually verify during testing:

  • Progress bar animations with the new gradients
  • Color contrast between stripe pairs in each variant
  • Gradient scaling across different progress bar sizes
🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Verify that all color variants are properly exported and accessible

# Check if all color variants are consistently defined across theme files
rg -l "stripe-gradient-(default|primary|secondary|success|warning|danger)"

Length of output: 206


Script:

#!/bin/bash
# Check gradient definitions in theme files
echo "=== Checking plugin.ts ==="
rg "stripe-gradient-" packages/core/theme/src/plugin.ts -A 2 -B 2

echo -e "\n=== Checking tw-merge-config.ts ==="
rg "stripe-gradient-" packages/core/theme/src/utils/tw-merge-config.ts -A 2 -B 2

Length of output: 1665

packages/core/theme/src/plugin.ts (1)

220-231: Verify color contrast ratios for accessibility.

The gradient color pairs should maintain sufficient contrast for accessibility. Let's verify the contrast ratios between the color pairs.

Comment on lines 132 to 168
{
color: "primary",
isStriped: true,
class: {
indicator: "bg-stripe-gradient-primary bg-[length:1.25rem_1.25rem]",
},
},
{
color: "secondary",
isStriped: true,
class: {
indicator: "bg-stripe-gradient-secondary bg-[length:1.25rem_1.25rem]",
},
},
{
color: "success",
isStriped: true,
class: {
indicator: "bg-stripe-gradient-success bg-[length:1.25rem_1.25rem]",
},
},

{
color: "warning",
isStriped: true,
class: {
indicator: "bg-stripe-gradient-warning bg-[length:1.25rem_1.25rem]",
},
},

{
color: "danger",
isStriped: true,
class: {
indicator: "bg-stripe-gradient-danger bg-[length:1.25rem_1.25rem]",
},
},
Copy link
Contributor

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion

Consider extracting repeated background size to reduce duplication.

The bg-[length:1.25rem_1.25rem] is repeated across all color variants. Consider extracting this to a shared class in your Tailwind configuration to follow the DRY principle.

 compoundVariants: [
   {
     color: "primary",
     isStriped: true,
     class: {
-      indicator: "bg-stripe-gradient-primary bg-[length:1.25rem_1.25rem]",
+      indicator: "bg-stripe-gradient-primary stripe-bg-size",
     },
   },
   // ... repeat for other colors
 ],

Then define the shared class in your Tailwind configuration:

// tailwind.config.js
module.exports = {
  theme: {
    extend: {
      utilities: {
        '.stripe-bg-size': {
          'background-size': '1.25rem 1.25rem'
        }
      }
    }
  }
}

@ShrinidhiUpadhyaya ShrinidhiUpadhyaya changed the title Fix/progress fix(theme): added stripe color gradients for progress #1933 Oct 24, 2024
@wingkwong wingkwong changed the title fix(theme): added stripe color gradients for progress #1933 fix(theme): added stripe color gradients for progress Oct 24, 2024
@wingkwong wingkwong added this to the v2.5.0 milestone Oct 24, 2024
Copy link

vercel bot commented Oct 24, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
nextui-docs-v2 ✅ Ready (Inspect) Visit Preview 💬 Add feedback Oct 24, 2024 7:15pm
nextui-storybook-v2 ✅ Ready (Inspect) Visit Preview 💬 Add feedback Oct 24, 2024 7:15pm

Copy link
Member

@wingkwong wingkwong left a comment

Choose a reason for hiding this comment

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

  1. please check coderabbitai comment
  2. for the colors, are they same as nextui theme ones?
  3. if so, can we use sth like var(--{prefix}-primary) in plugin.ts?

@ShrinidhiUpadhyaya
Copy link
Contributor Author

  1. please check coderabbitai comment
  2. for the colors, are they same as nextui theme ones?
  3. if so, can we use sth like var(--{prefix}-primary) in plugin.ts?

Yes the colors are same as NextUI theme.

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

🧹 Outside diff range and nitpick comments (1)
packages/core/theme/src/plugin.ts (1)

155-156: LGTM! Consider improving readability.

The createStripeGradient function correctly implements the stripe pattern using linear gradients and properly integrates with the theme system using HSL colors.

Consider breaking down the long string into multiple lines for better readability:

-  const createStripeGradient = (stripeColor: string, backgroundColor: string) =>
-    `linear-gradient(45deg,  hsl(var(--${prefix}-${stripeColor})) 25%,  hsl(var(--${prefix}-${backgroundColor})) 25%,  hsl(var(--${prefix}-${backgroundColor})) 50%,  hsl(var(--${prefix}-${stripeColor})) 50%,  hsl(var(--${prefix}-${stripeColor})) 75%,  hsl(var(--${prefix}-${backgroundColor})) 75%,  hsl(var(--${prefix}-${backgroundColor})))`;
+  const createStripeGradient = (stripeColor: string, backgroundColor: string) => `
+    linear-gradient(
+      45deg,
+      hsl(var(--${prefix}-${stripeColor})) 25%,
+      hsl(var(--${prefix}-${backgroundColor})) 25%,
+      hsl(var(--${prefix}-${backgroundColor})) 50%,
+      hsl(var(--${prefix}-${stripeColor})) 50%,
+      hsl(var(--${prefix}-${stripeColor})) 75%,
+      hsl(var(--${prefix}-${backgroundColor})) 75%,
+      hsl(var(--${prefix}-${backgroundColor}))
+    )`;
📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL

📥 Commits

Files that changed from the base of the PR and between 781d13a and 676e840.

📒 Files selected for processing (2)
  • packages/core/theme/src/components/progress.ts (2 hunks)
  • packages/core/theme/src/plugin.ts (2 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • packages/core/theme/src/components/progress.ts
🔇 Additional comments (2)
packages/core/theme/src/plugin.ts (2)

222-224: LGTM! Background size is well-defined.

The stripe size of 1.25rem provides a good visual balance and uses appropriate rem units for accessibility.


226-231: LGTM! Verify color contrast ratios.

The gradient definitions correctly implement all required color variants, addressing issue #1933. The use of -200 variants for stripes provides good visual distinction.

Let's verify that the color pairs meet WCAG contrast guidelines:

@wingkwong wingkwong self-assigned this Oct 27, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[BUG] - Progress does't have color
2 participants