-
Couldn't load subscription status.
- Fork 402
refactor(clerk-js): Make color ring and modal-backdrop full opacity when modified #7052
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
base: main
Are you sure you want to change the base?
Conversation
|
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
WalkthroughThe PR removes fixed transparency wrapping from parsed variables (HSLA strings returned directly) and moves transparent-default fallback construction into the Changes
Sequence Diagram(s)Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes Poem
Pre-merge checks and finishing touches✅ Passed checks (3 passed)
✨ Finishing touches
🧪 Generate unit tests (beta)
📜 Recent review detailsConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Disabled knowledge base sources:
📒 Files selected for processing (2)
🧰 Additional context used📓 Path-based instructions (7)packages/clerk-js/src/ui/**/*.{ts,tsx}📄 CodeRabbit inference engine (.cursor/rules/clerk-js-ui.mdc)
Files:
**/*.{js,jsx,ts,tsx}📄 CodeRabbit inference engine (.cursor/rules/development.mdc)
Files:
**/*.{js,jsx,ts,tsx,json,css,scss,md,yaml,yml}📄 CodeRabbit inference engine (.cursor/rules/development.mdc)
Files:
packages/**/*.{ts,tsx}📄 CodeRabbit inference engine (.cursor/rules/development.mdc)
Files:
packages/**/*.{ts,tsx,d.ts}📄 CodeRabbit inference engine (.cursor/rules/development.mdc)
Files:
**/*.{ts,tsx}📄 CodeRabbit inference engine (.cursor/rules/development.mdc)
Files:
**/*.{js,ts,tsx,jsx}📄 CodeRabbit inference engine (.cursor/rules/monorepo.mdc)
Files:
🧬 Code graph analysis (2)packages/clerk-js/src/ui/foundations/colors.ts (1)
packages/clerk-js/src/ui/customizables/parseVariables.ts (2)
⏰ 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). (5)
🔇 Additional comments (2)
Comment |
There was a problem hiding this 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: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
Disabled knowledge base sources:
- Linear integration is disabled by default for public repositories
You can enable these sources in your CodeRabbit configuration.
📒 Files selected for processing (2)
packages/clerk-js/src/ui/customizables/parseVariables.ts(1 hunks)packages/clerk-js/src/ui/foundations/colors.ts(1 hunks)
🧰 Additional context used
📓 Path-based instructions (7)
packages/clerk-js/src/ui/**/*.{ts,tsx}
📄 CodeRabbit inference engine (.cursor/rules/clerk-js-ui.mdc)
packages/clerk-js/src/ui/**/*.{ts,tsx}: Element descriptors should always be camelCase
Use element descriptors in UI components to enable consistent theming and styling via appearance.elements
Element descriptors should generate unique, stable CSS classes for theming
Element descriptors should handle state classes (e.g., cl-loading, cl-active, cl-error, cl-open) automatically based on component state
Do not render hard-coded values; all user-facing strings must be localized using provided localization methods
Use the useLocalizations hook and localizationKeys utility for all text and error messages
Use the styled system (sx prop, theme tokens, responsive values) for custom component styling
Use useCardState for card-level state, useFormState for form-level state, and useLoadingStatus for loading states
Always use handleError utility for API errors and use translateError for localized error messages
Use useFormControl for form field state, implement proper validation, and handle loading and error states in forms
Use localization keys for all form labels and placeholders
Use element descriptors for consistent styling and follow the theme token system
Use the Card and FormContainer patterns for consistent UI structure
Files:
packages/clerk-js/src/ui/customizables/parseVariables.tspackages/clerk-js/src/ui/foundations/colors.ts
**/*.{js,jsx,ts,tsx}
📄 CodeRabbit inference engine (.cursor/rules/development.mdc)
**/*.{js,jsx,ts,tsx}: All code must pass ESLint checks with the project's configuration
Follow established naming conventions (PascalCase for components, camelCase for variables)
Maintain comprehensive JSDoc comments for public APIs
Use dynamic imports for optional features
All public APIs must be documented with JSDoc
Provide meaningful error messages to developers
Include error recovery suggestions where applicable
Log errors appropriately for debugging
Lazy load components and features when possible
Implement proper caching strategies
Use efficient data structures and algorithms
Profile and optimize critical paths
Validate all inputs and sanitize outputs
Implement proper logging with different levels
Files:
packages/clerk-js/src/ui/customizables/parseVariables.tspackages/clerk-js/src/ui/foundations/colors.ts
**/*.{js,jsx,ts,tsx,json,css,scss,md,yaml,yml}
📄 CodeRabbit inference engine (.cursor/rules/development.mdc)
Use Prettier for consistent code formatting
Files:
packages/clerk-js/src/ui/customizables/parseVariables.tspackages/clerk-js/src/ui/foundations/colors.ts
packages/**/*.{ts,tsx}
📄 CodeRabbit inference engine (.cursor/rules/development.mdc)
TypeScript is required for all packages
Files:
packages/clerk-js/src/ui/customizables/parseVariables.tspackages/clerk-js/src/ui/foundations/colors.ts
packages/**/*.{ts,tsx,d.ts}
📄 CodeRabbit inference engine (.cursor/rules/development.mdc)
Packages should export TypeScript types alongside runtime code
Files:
packages/clerk-js/src/ui/customizables/parseVariables.tspackages/clerk-js/src/ui/foundations/colors.ts
**/*.{ts,tsx}
📄 CodeRabbit inference engine (.cursor/rules/development.mdc)
Use proper TypeScript error types
**/*.{ts,tsx}: Always define explicit return types for functions, especially public APIs
Use proper type annotations for variables and parameters where inference isn't clear
Avoidanytype - preferunknownwhen type is uncertain, then narrow with type guards
Useinterfacefor object shapes that might be extended
Usetypefor unions, primitives, and computed types
Preferreadonlyproperties for immutable data structures
Useprivatefor internal implementation details
Useprotectedfor inheritance hierarchies
Usepublicexplicitly for clarity in public APIs
Preferreadonlyfor properties that shouldn't change after construction
Prefer composition and interfaces over deep inheritance chains
Use mixins for shared behavior across unrelated classes
Implement dependency injection for loose coupling
Let TypeScript infer when types are obvious
Useconst assertionsfor literal types:as const
Usesatisfiesoperator for type checking without widening
Use mapped types for transforming object types
Use conditional types for type-level logic
Leverage template literal types for string manipulation
Use ES6 imports/exports consistently
Use default exports sparingly, prefer named exports
Use type-only imports:import type { ... } from ...
Noanytypes without justification
Proper error handling with typed errors
Consistent use ofreadonlyfor immutable data
Proper generic constraints
No unused type parameters
Proper use of utility types instead of manual type construction
Type-only imports where possible
Proper tree-shaking friendly exports
No circular dependencies
Efficient type computations (avoid deep recursion)
Files:
packages/clerk-js/src/ui/customizables/parseVariables.tspackages/clerk-js/src/ui/foundations/colors.ts
**/*.{js,ts,tsx,jsx}
📄 CodeRabbit inference engine (.cursor/rules/monorepo.mdc)
Support multiple Clerk environment variables (CLERK_, NEXT_PUBLIC_CLERK_, etc.) for configuration.
Files:
packages/clerk-js/src/ui/customizables/parseVariables.tspackages/clerk-js/src/ui/foundations/colors.ts
🧬 Code graph analysis (2)
packages/clerk-js/src/ui/customizables/parseVariables.ts (2)
packages/clerk-js/src/ui/utils/colors/index.ts (1)
colors(7-164)packages/clerk-js/src/ui/utils/colors/modern.ts (1)
colors(14-114)
packages/clerk-js/src/ui/foundations/colors.ts (1)
packages/clerk-js/src/ui/utils/cssVariables.ts (1)
clerkCssVar(252-252)
⏰ 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). (5)
- GitHub Check: Build Packages
- GitHub Check: Formatting | Dedupe | Changeset
- GitHub Check: Analyze (javascript-typescript)
- GitHub Check: semgrep-cloud-platform/scan
- GitHub Check: semgrep-cloud-platform/scan
🔇 Additional comments (1)
packages/clerk-js/src/ui/foundations/colors.ts (1)
99-102: LGTM! Correct restructuring of the transparency application.The refactoring correctly moves the transparency application from the outer layer (which would affect user-provided values) to the inner default fallback. This ensures:
- User-provided
--clerk-color-ringvalues are respected at full opacity- The default fallback (
defaultColorNeutral) maintains the 0.85 transparency for backward compatibility- A secondary fallback to
neutralAlphaScale.neutralAlpha200is preservedThe change aligns perfectly with the PR objective while maintaining sensible defaults.
| colorShimmer: colors.toHslaString(variables.colorShimmer), | ||
| colorMuted: variables.colorMuted ? colors.toHslaString(variables.colorMuted) : undefined, | ||
| colorRing: variables.colorRing ? colors.makeTransparent(colors.toHslaString(variables.colorRing), 0.85) : undefined, | ||
| colorRing: variables.colorRing ? colors.toHslaString(variables.colorRing) : undefined, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🧩 Analysis chain
LGTM! Verify the breaking change impact across the codebase.
The removal of the forced 0.85 transparency wrapper correctly implements the PR objective, allowing users to specify exact colors and opacities. The pattern now matches other optional color properties like colorMuted and colorShadow.
However, this is a breaking behavioral change. Existing code or user configurations that rely on the automatic transparency will now see colorRing at full opacity unless they explicitly specify a transparent value.
Run the following script to identify any usages that might be affected by this breaking change:
🏁 Script executed:
#!/bin/bash
# Description: Search for colorRing usage across the codebase to assess breaking change impact
# Search for colorRing property access and usage
rg -nP --type=ts --type=tsx -C3 '\bcolorRing\b'
# Search for --clerk-color-ring CSS variable usage
rg -nP -C3 '--clerk-color-ring'Length of output: 448
🏁 Script executed:
#!/bin/bash
# Fixed searches for colorRing usage assessment
# Search for colorRing property usage in TypeScript files
echo "=== Searching for colorRing property usage ==="
rg -n -C3 'colorRing' --type=ts
echo ""
echo "=== Searching for CSS variable reference ==="
# Search for --clerk-color-ring CSS variable usage
rg -n -C3 'clerk-color-ring'
echo ""
echo "=== Examining parseVariables.ts context around line 77 ==="
fd -t f parseVariables.ts -x cat {} -n | head -100Length of output: 13165
🏁 Script executed:
#!/bin/bash
# Understand how parseVariables output is used and merged with foundation defaults
echo "=== Examining parseVariables exports and usage ==="
fd -t f -e ts -e tsx parseVariables -x grep -l 'export\|createColorScales'
echo ""
echo "=== Search for imports of createColorScales ==="
rg -n 'createColorScales' --type=ts
echo ""
echo "=== Check how colors from foundations are used as fallback ==="
rg -n 'colorRing.*clerkCssVar\|clerkCssVar.*colorRing' --type=tsLength of output: 528
🏁 Script executed:
#!/bin/bash
# Trace how foundation colors merge with parseColorScales output
echo "=== Context around parseAppearance.ts line 162 ==="
fd -t f parseAppearance.ts -x sed -n '150,180p' {}
echo ""
echo "=== Check if foundation colors object is pre-populated ==="
rg -n -B5 -A5 'createColorScales\(theme\)' packages/clerk-js/src/ui/customizables/parseAppearance.ts
echo ""
echo "=== View entire parseAppearance.ts to understand initialization ==="
fd -t f parseAppearance.ts -x wc -l {}Length of output: 1598
Update JSDoc to reflect breaking change in colorRing opacity behavior.
The removal of makeTransparent(0.85) wrapper is a breaking change for users providing explicit colorRing values. The JSDoc at packages/types/src/appearance.ts:757-759 currently states the color is rendered "at 15% opacity," but this guarantee no longer applies when users provide a custom value—they now get full opacity unless explicitly specified.
Update the documentation to clarify:
- When
colorRingis undefined, the default uses 15% opacity - When
colorRingis explicitly provided, users control the opacity (no forced transparency)
The implementation itself is correct and matches the pattern of adjacent optional color properties (colorMuted, colorShadow). The consuming code across baseTheme.ts, styledSystem/common.ts, and UI components will work correctly with this change.
🤖 Prompt for AI Agents
In packages/clerk-js/src/ui/customizables/parseVariables.ts around line 77 and
in the JSDoc at packages/types/src/appearance.ts lines ~757-759, update the
documentation to reflect the breaking change: clarify that when colorRing is
undefined the library uses the default color rendered at 15% opacity, but when
colorRing is explicitly provided the value is used as-is (users control opacity
and no forced transparency is applied). Edit the JSDoc text to state both
behaviors succinctly and ensure examples/param description indicate that opacity
must be included in the custom color if the user wants transparency.
@clerk/agent-toolkit
@clerk/astro
@clerk/backend
@clerk/chrome-extension
@clerk/clerk-js
@clerk/dev-cli
@clerk/elements
@clerk/clerk-expo
@clerk/expo-passkeys
@clerk/express
@clerk/fastify
@clerk/localizations
@clerk/nextjs
@clerk/nuxt
@clerk/clerk-react
@clerk/react-router
@clerk/remix
@clerk/shared
@clerk/tanstack-react-start
@clerk/testing
@clerk/themes
@clerk/types
@clerk/upgrade
@clerk/vue
commit: |
Description
Issue
Allow users to exactly specify the ring color output. Currently when specifying the ring color, we always render with an opacity specified, which can make it difficult to output a specific color.
Fix
Instead we will just output the specified value, which allows them to control the opacity
Checklist
pnpm testruns as expected.pnpm buildruns as expected.Type of change
Summary by CodeRabbit