-
Notifications
You must be signed in to change notification settings - Fork 392
feat(clerk-js,nextjs,clerk-react,testing,types,vue): UserAvatar component #6808
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
Conversation
🦋 Changeset detectedLatest commit: 1f41968 The changes in this PR will be included in the next version bump. This PR includes changesets to release 22 packages
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 |
The latest updates on your projects. Learn more about Vercel for GitHub.
|
WalkthroughAdds a new UserAvatar UI component and integrates it across client libraries, types, contexts, lazy loading, mounting APIs, sandbox UI, framework wrappers/pages/routes, tests, Playwright page objects, and package exports. Changes
Sequence Diagram(s)sequenceDiagram
autonumber
actor User
participant App as App Route (/user-avatar)
participant Wrapper as Framework Wrapper (React/Vue/Next)
participant Iso as IsomorphicClerk
participant ClerkJS as Clerk (clerk-js)
participant UI as UI module (UserAvatar)
participant Telemetry as Telemetry
User->>App: Navigate to /user-avatar
App->>Wrapper: Render <UserAvatar fallback=...>
alt Clerk not loaded
Wrapper->>Wrapper: Render fallback UI
Wrapper->>Iso: premountUserAvatar(node, props)
Iso-->>Wrapper: stored premount node
else Clerk loaded
Wrapper->>Iso: mountUserAvatar(node, props)
Iso->>ClerkJS: mountUserAvatar(node, props)
ClerkJS->>UI: Mount component (appearanceKey="userAvatar")
ClerkJS->>Telemetry: record "UserAvatar mounted"
UI-->>Wrapper: Avatar rendered
end
User->>App: Navigate away / unmount
App->>Wrapper: Unmount component
Wrapper->>Iso: unmountUserAvatar(node)
Iso->>ClerkJS: unmountUserAvatar(node)
ClerkJS-->>Wrapper: Unmounted
Estimated code review effort🎯 4 (Complex) | ⏱️ ~60 minutes Poem
Pre-merge checks and finishing touches❌ Failed checks (2 warnings)
✅ Passed checks (3 passed)
✨ Finishing touches
🧪 Generate unit tests
Comment |
@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: |
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: 4
🧹 Nitpick comments (8)
packages/react/src/components/__tests__/UserAvatar.test.tsx (1)
6-13
: Type test is fine; consider adding a minimal runtime render test.Add a React Testing Library test that renders
<UserAvatar fallback="..." />
and asserts the avatar mounts and becomes visible after Clerk loads (mirroring other components’ tests).packages/testing/src/playwright/unstable/page-objects/userAvatar.ts (1)
5-5
: Prefer stable data attribute over CSS class for selection.Target
[data-clerk-component="UserAvatar"]
to decouple tests from styling.Apply this diff:
-const SELECTOR = '.cl-userAvatarBox'; +const SELECTOR = '[data-clerk-component="UserAvatar"]';Also applies to: 18-20
packages/react/src/isomorphicClerk.ts (2)
978-984
: Add explicit return type.Match our TS guidelines and nearby APIs.
- mountUserAvatar = (node: HTMLDivElement, props?: UserAvatarProps) => { + mountUserAvatar = (node: HTMLDivElement, props?: UserAvatarProps): void => {
986-992
: Add explicit return type.Same rationale as above.
- unmountUserAvatar = (node: HTMLDivElement) => { + unmountUserAvatar = (node: HTMLDivElement): void => {packages/types/src/clerk.ts (1)
411-424
: JSDoc param mentions wrong component (“UserButton”).Update to “UserAvatar” to avoid confusion in public docs.
- * @param targetNode Target node to mount the UserButton component. + * @param targetNode Target node to mount the UserAvatar component.integration/templates/react-vite/src/main.tsx (1)
18-18
: React route and import for UserAvatar — OKRoute is added and resolves to the new page. Consider guarding to mirror Vue (optional).
Wrap with a SignedIn gate or redirect if you want parity with Vue’s auth guard.
Also applies to: 72-75
integration/templates/vue-vite/src/router.ts (1)
80-80
: Auth guard updated to include UserAvatar — minor maintainability nitConsider using per-route meta (requiresAuth) instead of a central list.
Example:
- { - name: 'UserAvatar', - path: '/user-avatar', - component: () => import('./views/UserAvatar.vue'), - }, + { + name: 'UserAvatar', + path: '/user-avatar', + component: () => import('./views/UserAvatar.vue'), + meta: { requiresAuth: true }, + },Then:
-} else if (!isSignedIn.value && authenticatedPages.includes(to.name)) { +} else if (!isSignedIn.value && to.meta?.requiresAuth) {packages/react/src/components/index.ts (1)
12-12
: Public exportUserAvatar
— OK. Re-exportUserAvatarProps
for DX consistencyUserAvatarProps is declared in packages/react/src/components/uiComponents.tsx but is not re‑exported from packages/react/src/components/index.ts; add
export type { UserAvatarProps } from './uiComponents';
to packages/react/src/components/index.ts.
📜 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 (30)
integration/templates/next-app-router/src/app/user-avatar/page.tsx
(1 hunks)integration/templates/react-vite/src/main.tsx
(2 hunks)integration/templates/react-vite/src/user-avatar/index.tsx
(1 hunks)integration/templates/vue-vite/src/router.ts
(2 hunks)integration/templates/vue-vite/src/views/UserAvatar.vue
(1 hunks)integration/tests/components.test.ts
(1 hunks)integration/tests/user-avatar.test.ts
(1 hunks)integration/tests/vue/components.test.ts
(1 hunks)packages/clerk-js/sandbox/app.ts
(4 hunks)packages/clerk-js/sandbox/template.html
(1 hunks)packages/clerk-js/src/core/clerk.ts
(2 hunks)packages/clerk-js/src/ui/components/UserAvatar/index.tsx
(1 hunks)packages/clerk-js/src/ui/contexts/ClerkUIComponentsContext.tsx
(2 hunks)packages/clerk-js/src/ui/contexts/components/UserAvatar.ts
(1 hunks)packages/clerk-js/src/ui/contexts/components/index.ts
(1 hunks)packages/clerk-js/src/ui/customizables/elementDescriptors.ts
(1 hunks)packages/clerk-js/src/ui/lazyModules/components.ts
(3 hunks)packages/clerk-js/src/ui/types.ts
(5 hunks)packages/nextjs/src/client-boundary/uiComponents.tsx
(1 hunks)packages/nextjs/src/index.ts
(1 hunks)packages/react/src/components/__tests__/UserAvatar.test.tsx
(1 hunks)packages/react/src/components/index.ts
(1 hunks)packages/react/src/components/uiComponents.tsx
(2 hunks)packages/react/src/isomorphicClerk.ts
(3 hunks)packages/testing/src/playwright/unstable/page-objects/index.ts
(2 hunks)packages/testing/src/playwright/unstable/page-objects/userAvatar.ts
(1 hunks)packages/types/src/appearance.ts
(3 hunks)packages/types/src/clerk.ts
(3 hunks)packages/vue/src/components/index.ts
(1 hunks)packages/vue/src/components/ui-components/UserAvatar.vue
(1 hunks)
🧰 Additional context used
📓 Path-based instructions (19)
**/*.{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:
integration/templates/react-vite/src/user-avatar/index.tsx
packages/nextjs/src/client-boundary/uiComponents.tsx
integration/tests/components.test.ts
packages/react/src/components/index.ts
integration/tests/user-avatar.test.ts
packages/types/src/appearance.ts
integration/templates/react-vite/src/main.tsx
packages/testing/src/playwright/unstable/page-objects/userAvatar.ts
integration/templates/next-app-router/src/app/user-avatar/page.tsx
packages/react/src/components/__tests__/UserAvatar.test.tsx
packages/clerk-js/src/ui/customizables/elementDescriptors.ts
integration/templates/vue-vite/src/router.ts
packages/clerk-js/src/ui/components/UserAvatar/index.tsx
packages/clerk-js/src/ui/types.ts
packages/clerk-js/src/ui/lazyModules/components.ts
packages/vue/src/components/index.ts
packages/clerk-js/src/core/clerk.ts
integration/tests/vue/components.test.ts
packages/clerk-js/src/ui/contexts/ClerkUIComponentsContext.tsx
packages/types/src/clerk.ts
packages/clerk-js/src/ui/contexts/components/UserAvatar.ts
packages/testing/src/playwright/unstable/page-objects/index.ts
packages/react/src/isomorphicClerk.ts
packages/react/src/components/uiComponents.tsx
packages/clerk-js/sandbox/app.ts
packages/nextjs/src/index.ts
packages/clerk-js/src/ui/contexts/components/index.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:
integration/templates/react-vite/src/user-avatar/index.tsx
packages/nextjs/src/client-boundary/uiComponents.tsx
integration/tests/components.test.ts
packages/react/src/components/index.ts
integration/tests/user-avatar.test.ts
packages/types/src/appearance.ts
integration/templates/react-vite/src/main.tsx
packages/testing/src/playwright/unstable/page-objects/userAvatar.ts
integration/templates/next-app-router/src/app/user-avatar/page.tsx
packages/react/src/components/__tests__/UserAvatar.test.tsx
packages/clerk-js/src/ui/customizables/elementDescriptors.ts
integration/templates/vue-vite/src/router.ts
packages/clerk-js/src/ui/components/UserAvatar/index.tsx
packages/clerk-js/src/ui/types.ts
packages/clerk-js/src/ui/lazyModules/components.ts
packages/vue/src/components/index.ts
packages/clerk-js/src/core/clerk.ts
integration/tests/vue/components.test.ts
packages/clerk-js/src/ui/contexts/ClerkUIComponentsContext.tsx
packages/types/src/clerk.ts
packages/clerk-js/src/ui/contexts/components/UserAvatar.ts
packages/testing/src/playwright/unstable/page-objects/index.ts
packages/react/src/isomorphicClerk.ts
packages/react/src/components/uiComponents.tsx
packages/clerk-js/sandbox/app.ts
packages/nextjs/src/index.ts
packages/clerk-js/src/ui/contexts/components/index.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
Avoidany
type - preferunknown
when type is uncertain, then narrow with type guards
Useinterface
for object shapes that might be extended
Usetype
for unions, primitives, and computed types
Preferreadonly
properties for immutable data structures
Useprivate
for internal implementation details
Useprotected
for inheritance hierarchies
Usepublic
explicitly for clarity in public APIs
Preferreadonly
for 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 assertions
for literal types:as const
Usesatisfies
operator 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 ...
Noany
types without justification
Proper error handling with typed errors
Consistent use ofreadonly
for 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:
integration/templates/react-vite/src/user-avatar/index.tsx
packages/nextjs/src/client-boundary/uiComponents.tsx
integration/tests/components.test.ts
packages/react/src/components/index.ts
integration/tests/user-avatar.test.ts
packages/types/src/appearance.ts
integration/templates/react-vite/src/main.tsx
packages/testing/src/playwright/unstable/page-objects/userAvatar.ts
integration/templates/next-app-router/src/app/user-avatar/page.tsx
packages/react/src/components/__tests__/UserAvatar.test.tsx
packages/clerk-js/src/ui/customizables/elementDescriptors.ts
integration/templates/vue-vite/src/router.ts
packages/clerk-js/src/ui/components/UserAvatar/index.tsx
packages/clerk-js/src/ui/types.ts
packages/clerk-js/src/ui/lazyModules/components.ts
packages/vue/src/components/index.ts
packages/clerk-js/src/core/clerk.ts
integration/tests/vue/components.test.ts
packages/clerk-js/src/ui/contexts/ClerkUIComponentsContext.tsx
packages/types/src/clerk.ts
packages/clerk-js/src/ui/contexts/components/UserAvatar.ts
packages/testing/src/playwright/unstable/page-objects/index.ts
packages/react/src/isomorphicClerk.ts
packages/react/src/components/uiComponents.tsx
packages/clerk-js/sandbox/app.ts
packages/nextjs/src/index.ts
packages/clerk-js/src/ui/contexts/components/index.ts
**/*.{jsx,tsx}
📄 CodeRabbit inference engine (.cursor/rules/development.mdc)
**/*.{jsx,tsx}
: Use error boundaries in React components
Minimize re-renders in React components
**/*.{jsx,tsx}
: Always use functional components with hooks instead of class components
Follow PascalCase naming for components:UserProfile
,NavigationMenu
Keep components focused on a single responsibility - split large components
Limit component size to 150-200 lines; extract logic into custom hooks
Use composition over inheritance - prefer smaller, composable components
Export components as named exports for better tree-shaking
One component per file with matching filename and component name
Use useState for simple state management
Use useReducer for complex state logic
Implement proper state initialization
Use proper state updates with callbacks
Implement proper state cleanup
Use Context API for theme/authentication
Implement proper state selectors
Use proper state normalization
Implement proper state persistence
Use React.memo for expensive components
Implement proper useCallback for handlers
Use proper useMemo for expensive computations
Implement proper virtualization for lists
Use proper code splitting with React.lazy
Implement proper cleanup in useEffect
Use proper refs for DOM access
Implement proper event listener cleanup
Use proper abort controllers for fetch
Implement proper subscription cleanup
Use proper HTML elements
Implement proper ARIA attributes
Use proper heading hierarchy
Implement proper form labels
Use proper button types
Implement proper focus management
Use proper keyboard shortcuts
Implement proper tab order
Use proper skip links
Implement proper focus traps
Implement proper error boundaries
Use proper error logging
Implement proper error recovery
Use proper error messages
Implement proper error fallbacks
Use proper form validation
Implement proper error states
Use proper error messages
Implement proper form submission
Use proper form reset
Use proper component naming
Implement proper file naming
Use proper prop naming
Implement proper...
Files:
integration/templates/react-vite/src/user-avatar/index.tsx
packages/nextjs/src/client-boundary/uiComponents.tsx
integration/templates/react-vite/src/main.tsx
integration/templates/next-app-router/src/app/user-avatar/page.tsx
packages/react/src/components/__tests__/UserAvatar.test.tsx
packages/clerk-js/src/ui/components/UserAvatar/index.tsx
packages/clerk-js/src/ui/contexts/ClerkUIComponentsContext.tsx
packages/react/src/components/uiComponents.tsx
integration/**
📄 CodeRabbit inference engine (.cursor/rules/global.mdc)
Framework integration templates and E2E tests should be placed under the integration/ directory
Files:
integration/templates/react-vite/src/user-avatar/index.tsx
integration/tests/components.test.ts
integration/tests/user-avatar.test.ts
integration/templates/react-vite/src/main.tsx
integration/templates/next-app-router/src/app/user-avatar/page.tsx
integration/templates/vue-vite/src/router.ts
integration/tests/vue/components.test.ts
integration/templates/vue-vite/src/views/UserAvatar.vue
integration/**/*
📄 CodeRabbit inference engine (.cursor/rules/monorepo.mdc)
End-to-end tests and integration templates must be located in the 'integration/' directory.
Files:
integration/templates/react-vite/src/user-avatar/index.tsx
integration/tests/components.test.ts
integration/tests/user-avatar.test.ts
integration/templates/react-vite/src/main.tsx
integration/templates/next-app-router/src/app/user-avatar/page.tsx
integration/templates/vue-vite/src/router.ts
integration/tests/vue/components.test.ts
integration/templates/vue-vite/src/views/UserAvatar.vue
**/*.{js,ts,tsx,jsx}
📄 CodeRabbit inference engine (.cursor/rules/monorepo.mdc)
Support multiple Clerk environment variables (CLERK_, NEXT_PUBLIC_CLERK_, etc.) for configuration.
Files:
integration/templates/react-vite/src/user-avatar/index.tsx
packages/nextjs/src/client-boundary/uiComponents.tsx
integration/tests/components.test.ts
packages/react/src/components/index.ts
integration/tests/user-avatar.test.ts
packages/types/src/appearance.ts
integration/templates/react-vite/src/main.tsx
packages/testing/src/playwright/unstable/page-objects/userAvatar.ts
integration/templates/next-app-router/src/app/user-avatar/page.tsx
packages/react/src/components/__tests__/UserAvatar.test.tsx
packages/clerk-js/src/ui/customizables/elementDescriptors.ts
integration/templates/vue-vite/src/router.ts
packages/clerk-js/src/ui/components/UserAvatar/index.tsx
packages/clerk-js/src/ui/types.ts
packages/clerk-js/src/ui/lazyModules/components.ts
packages/vue/src/components/index.ts
packages/clerk-js/src/core/clerk.ts
integration/tests/vue/components.test.ts
packages/clerk-js/src/ui/contexts/ClerkUIComponentsContext.tsx
packages/types/src/clerk.ts
packages/clerk-js/src/ui/contexts/components/UserAvatar.ts
packages/testing/src/playwright/unstable/page-objects/index.ts
packages/react/src/isomorphicClerk.ts
packages/react/src/components/uiComponents.tsx
packages/clerk-js/sandbox/app.ts
packages/nextjs/src/index.ts
packages/clerk-js/src/ui/contexts/components/index.ts
**/*.tsx
📄 CodeRabbit inference engine (.cursor/rules/react.mdc)
**/*.tsx
: Use proper type definitions for props and state
Leverage TypeScript's type inference where possible
Use proper event types for handlers
Implement proper generic types for reusable components
Use proper type guards for conditional rendering
Files:
integration/templates/react-vite/src/user-avatar/index.tsx
packages/nextjs/src/client-boundary/uiComponents.tsx
integration/templates/react-vite/src/main.tsx
integration/templates/next-app-router/src/app/user-avatar/page.tsx
packages/react/src/components/__tests__/UserAvatar.test.tsx
packages/clerk-js/src/ui/components/UserAvatar/index.tsx
packages/clerk-js/src/ui/contexts/ClerkUIComponentsContext.tsx
packages/react/src/components/uiComponents.tsx
packages/**/*.{ts,tsx}
📄 CodeRabbit inference engine (.cursor/rules/development.mdc)
TypeScript is required for all packages
Files:
packages/nextjs/src/client-boundary/uiComponents.tsx
packages/react/src/components/index.ts
packages/types/src/appearance.ts
packages/testing/src/playwright/unstable/page-objects/userAvatar.ts
packages/react/src/components/__tests__/UserAvatar.test.tsx
packages/clerk-js/src/ui/customizables/elementDescriptors.ts
packages/clerk-js/src/ui/components/UserAvatar/index.tsx
packages/clerk-js/src/ui/types.ts
packages/clerk-js/src/ui/lazyModules/components.ts
packages/vue/src/components/index.ts
packages/clerk-js/src/core/clerk.ts
packages/clerk-js/src/ui/contexts/ClerkUIComponentsContext.tsx
packages/types/src/clerk.ts
packages/clerk-js/src/ui/contexts/components/UserAvatar.ts
packages/testing/src/playwright/unstable/page-objects/index.ts
packages/react/src/isomorphicClerk.ts
packages/react/src/components/uiComponents.tsx
packages/clerk-js/sandbox/app.ts
packages/nextjs/src/index.ts
packages/clerk-js/src/ui/contexts/components/index.ts
packages/**/*.{ts,tsx,d.ts}
📄 CodeRabbit inference engine (.cursor/rules/development.mdc)
Packages should export TypeScript types alongside runtime code
Files:
packages/nextjs/src/client-boundary/uiComponents.tsx
packages/react/src/components/index.ts
packages/types/src/appearance.ts
packages/testing/src/playwright/unstable/page-objects/userAvatar.ts
packages/react/src/components/__tests__/UserAvatar.test.tsx
packages/clerk-js/src/ui/customizables/elementDescriptors.ts
packages/clerk-js/src/ui/components/UserAvatar/index.tsx
packages/clerk-js/src/ui/types.ts
packages/clerk-js/src/ui/lazyModules/components.ts
packages/vue/src/components/index.ts
packages/clerk-js/src/core/clerk.ts
packages/clerk-js/src/ui/contexts/ClerkUIComponentsContext.tsx
packages/types/src/clerk.ts
packages/clerk-js/src/ui/contexts/components/UserAvatar.ts
packages/testing/src/playwright/unstable/page-objects/index.ts
packages/react/src/isomorphicClerk.ts
packages/react/src/components/uiComponents.tsx
packages/clerk-js/sandbox/app.ts
packages/nextjs/src/index.ts
packages/clerk-js/src/ui/contexts/components/index.ts
integration/**/*.{test,spec}.{js,ts}
📄 CodeRabbit inference engine (.cursor/rules/monorepo.mdc)
Integration tests should use Playwright.
Files:
integration/tests/components.test.ts
integration/tests/user-avatar.test.ts
integration/tests/vue/components.test.ts
packages/**/index.{js,ts}
📄 CodeRabbit inference engine (.cursor/rules/development.mdc)
Use tree-shaking friendly exports
Files:
packages/react/src/components/index.ts
packages/vue/src/components/index.ts
packages/testing/src/playwright/unstable/page-objects/index.ts
packages/nextjs/src/index.ts
packages/clerk-js/src/ui/contexts/components/index.ts
**/index.ts
📄 CodeRabbit inference engine (.cursor/rules/react.mdc)
Use index.ts files for clean imports but avoid deep barrel exports
Avoid barrel files (index.ts re-exports) as they can cause circular dependencies
Files:
packages/react/src/components/index.ts
packages/vue/src/components/index.ts
packages/testing/src/playwright/unstable/page-objects/index.ts
packages/nextjs/src/index.ts
packages/clerk-js/src/ui/contexts/components/index.ts
packages/types/src/appearance.ts
📄 CodeRabbit inference engine (.cursor/rules/clerk-js-ui.mdc)
Add new element descriptor types in packages/types/src/appearance.ts before using them elsewhere
Files:
packages/types/src/appearance.ts
packages/**/*.{test,spec}.{js,jsx,ts,tsx}
📄 CodeRabbit inference engine (.cursor/rules/monorepo.mdc)
Unit tests should use Jest or Vitest as the test runner.
Files:
packages/react/src/components/__tests__/UserAvatar.test.tsx
**/*.test.{jsx,tsx}
📄 CodeRabbit inference engine (.cursor/rules/react.mdc)
**/*.test.{jsx,tsx}
: Use React Testing Library
Test component behavior, not implementation
Use proper test queries
Implement proper test isolation
Use proper test coverage
Test component interactions
Use proper test data
Implement proper test setup
Use proper test cleanup
Implement proper test assertions
Use proper test structure
Files:
packages/react/src/components/__tests__/UserAvatar.test.tsx
**/__tests__/**/*.{ts,tsx}
📄 CodeRabbit inference engine (.cursor/rules/typescript.mdc)
**/__tests__/**/*.{ts,tsx}
: Create type-safe test builders/factories
Use branded types for test isolation
Implement proper mock types that match interfaces
Files:
packages/react/src/components/__tests__/UserAvatar.test.tsx
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/elementDescriptors.ts
packages/clerk-js/src/ui/components/UserAvatar/index.tsx
packages/clerk-js/src/ui/types.ts
packages/clerk-js/src/ui/lazyModules/components.ts
packages/clerk-js/src/ui/contexts/ClerkUIComponentsContext.tsx
packages/clerk-js/src/ui/contexts/components/UserAvatar.ts
packages/clerk-js/src/ui/contexts/components/index.ts
packages/clerk-js/src/ui/customizables/elementDescriptors.ts
📄 CodeRabbit inference engine (.cursor/rules/clerk-js-ui.mdc)
Append new element descriptors to APPEARANCE_KEYS in packages/clerk-js/src/ui/customizables/elementDescriptors.ts
Files:
packages/clerk-js/src/ui/customizables/elementDescriptors.ts
🧬 Code graph analysis (16)
integration/templates/react-vite/src/user-avatar/index.tsx (2)
packages/clerk-js/src/ui/components/UserAvatar/index.tsx (1)
UserAvatar
(26-26)packages/react/src/components/uiComponents.tsx (1)
UserAvatar
(644-670)
integration/tests/user-avatar.test.ts (2)
integration/testUtils/index.ts (2)
testAgainstRunningApps
(88-88)createTestUtils
(24-86)integration/presets/index.ts (1)
appConfigs
(15-32)
integration/templates/react-vite/src/main.tsx (3)
packages/clerk-js/src/ui/components/UserAvatar/index.tsx (1)
UserAvatar
(26-26)packages/clerk-js/src/ui/lazyModules/components.ts (1)
UserAvatar
(51-53)packages/react/src/components/uiComponents.tsx (1)
UserAvatar
(644-670)
integration/templates/next-app-router/src/app/user-avatar/page.tsx (5)
packages/clerk-js/src/ui/components/UserAvatar/index.tsx (1)
UserAvatar
(26-26)packages/clerk-js/src/ui/lazyModules/components.ts (1)
UserAvatar
(51-53)packages/nextjs/src/client-boundary/uiComponents.tsx (1)
UserAvatar
(26-26)packages/nextjs/src/index.ts (1)
UserAvatar
(38-38)packages/react/src/components/uiComponents.tsx (1)
UserAvatar
(644-670)
packages/react/src/components/__tests__/UserAvatar.test.tsx (2)
packages/react/src/components/index.ts (1)
UserAvatar
(12-12)packages/react/src/components/uiComponents.tsx (1)
UserAvatar
(644-670)
packages/clerk-js/src/ui/components/UserAvatar/index.tsx (4)
packages/types/src/clerk.ts (1)
UserAvatarProps
(1642-1645)packages/clerk-js/src/ui/contexts/components/UserAvatar.ts (1)
useUserAvatarContext
(7-20)packages/clerk-js/src/ui/styledSystem/InternalThemeProvider.tsx (1)
InternalThemeProvider
(12-16)packages/clerk-js/src/ui/customizables/elementDescriptors.ts (1)
descriptors
(571-571)
packages/clerk-js/src/ui/types.ts (1)
packages/types/src/clerk.ts (1)
UserAvatarProps
(1642-1645)
packages/clerk-js/src/ui/lazyModules/components.ts (2)
packages/clerk-js/src/ui/components/UserAvatar/index.tsx (1)
UserAvatar
(26-26)packages/react/src/components/uiComponents.tsx (1)
UserAvatar
(644-670)
packages/clerk-js/src/core/clerk.ts (2)
packages/types/src/clerk.ts (1)
UserAvatarProps
(1642-1645)packages/shared/src/telemetry/events/component-mounted.ts (1)
eventPrebuiltComponentMounted
(53-59)
integration/tests/vue/components.test.ts (1)
integration/testUtils/index.ts (1)
createTestUtils
(24-86)
packages/clerk-js/src/ui/contexts/ClerkUIComponentsContext.tsx (1)
packages/clerk-js/src/ui/contexts/components/UserAvatar.ts (1)
UserAvatarContext
(5-5)
packages/types/src/clerk.ts (2)
packages/clerk-js/src/ui/types.ts (1)
UserAvatarProps
(39-39)packages/types/src/appearance.ts (1)
UserAvatarTheme
(973-973)
packages/clerk-js/src/ui/contexts/components/UserAvatar.ts (1)
packages/clerk-js/src/ui/types.ts (1)
UserAvatarCtx
(96-98)
packages/testing/src/playwright/unstable/page-objects/index.ts (1)
packages/testing/src/playwright/unstable/page-objects/userAvatar.ts (1)
createUserAvatarPageObject
(7-24)
packages/react/src/isomorphicClerk.ts (1)
packages/types/src/clerk.ts (1)
UserAvatarProps
(1642-1645)
packages/react/src/components/uiComponents.tsx (5)
packages/react/src/components/withClerk.tsx (1)
withClerk
(7-37)packages/react/src/types.ts (1)
WithClerkProp
(74-74)packages/types/src/clerk.ts (1)
UserAvatarProps
(1642-1645)packages/react/src/utils/useWaitForComponentMount.ts (1)
useWaitForComponentMount
(71-102)packages/react/src/components/ClerkHostRenderer.tsx (1)
ClerkHostRenderer
(59-140)
⏰ 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). (6)
- GitHub Check: Formatting | Dedupe | Changeset
- GitHub Check: Build Packages
- GitHub Check: semgrep/ci
- GitHub Check: semgrep-cloud-platform/scan
- GitHub Check: semgrep-cloud-platform/scan
- GitHub Check: Analyze (javascript-typescript)
🔇 Additional comments (29)
packages/nextjs/src/index.ts (1)
38-38
: LGTM! Consistent export pattern for new UserAvatar component.The export follows the established pattern for UI components in this file, maintaining consistency with other components like UserButton and UserProfile.
packages/nextjs/src/client-boundary/uiComponents.tsx (1)
26-26
: LGTM! UserAvatar properly exported from Clerk React.The export follows the correct pattern for re-exporting components from @clerk/clerk-react. This approach is consistent with other simple component exports like UserButton.
packages/vue/src/components/index.ts (1)
11-11
: LGTM! Vue UserAvatar component export follows naming conventions.The export pattern matches other Vue SFC components in this file, using
default as UserAvatar
from the corresponding Vue file.integration/tests/components.test.ts (1)
44-49
: LGTM! UserAvatar test entry properly configured.The test configuration correctly includes:
protected: true
for authentication requirement- Appropriate fallback text matching the pattern used by other components
- Proper placement in the component list between UserProfile and UserButton
This aligns with the cross-framework integration approach for the new UserAvatar component.
integration/templates/react-vite/src/user-avatar/index.tsx (1)
1-11
: LGTM! Clean React page implementation for UserAvatar.The component follows React best practices:
- Proper imports from @clerk/clerk-react
- Functional component with TypeScript
- Appropriate fallback prop usage matching the test expectations
- Clean JSX structure with semantic HTML
The fallback text "Loading user avatar" matches the test configuration in the integration test file.
integration/templates/vue-vite/src/views/UserAvatar.vue (1)
1-10
: LGTM! Vue UserAvatar view follows Vue 3 composition API patterns.The component correctly:
- Uses
<script setup lang="ts">
for Vue 3 composition API- Imports UserAvatar from @clerk/vue
- Renders with proper template structure
- Follows Vue SFC conventions
The implementation is consistent with other Vue views in the codebase.
integration/tests/vue/components.test.ts (1)
41-50
: LGTM! Vue integration test properly validates UserAvatar functionality.The test correctly:
- Follows the established test pattern with sign-in flow
- Uses proper page object methods (
u.po.userAvatar.goTo()
,u.po.userAvatar.toBeVisible()
)- Maintains consistency with other component tests in the file
- Verifies both authentication and component visibility
This provides appropriate test coverage for the Vue UserAvatar component.
integration/tests/user-avatar.test.ts (3)
15-22
: LGTM! Test setup follows established patterns.The setup correctly:
- Creates a fake user with phone number and username
- Uses the proper test utilities
- Creates a BAPI user for authentication testing
This matches the pattern used in other integration tests.
35-47
: LGTM! Test flow correctly validates UserAvatar functionality.The test properly:
- Signs in with the fake user credentials
- Navigates to UserAvatar using page objects
- Verifies component visibility
- Uses appropriate assertions with
toBeSignedIn()
andtoBeVisible()
This provides comprehensive coverage for the UserAvatar component integration.
7-10
: Verified — patterns exist in presets; no change required.
Both 'react.vite.withEmailCodes' (integration/presets/longRunningApps.ts:58) and 'vue.vite' (integration/presets/longRunningApps.ts:61) are present, so the test patterns are valid.packages/clerk-js/src/ui/lazyModules/components.ts (1)
6-6
: Lazy entry and registry update look good.Chunk name and registry wiring are consistent with existing components.
Also applies to: 51-53, 143-143
packages/react/src/components/uiComponents.tsx (1)
644-670
: React wrapper matches established mounting pattern.Fallback handling,
renderWhileLoading
, and host renderer wiring look consistent.packages/clerk-js/src/core/clerk.ts (1)
83-83
: withCoreUserGuard present — no change required.UserAvatar is exported as withCoreUserGuard(_UserAvatar) in packages/clerk-js/src/ui/components/UserAvatar/index.tsx:26.
packages/clerk-js/src/ui/components/UserAvatar/index.tsx (1)
15-21
: Avoid spreading the entireuser
object into InternalUserAvatar.
- Spreading {...user} in packages/clerk-js/src/ui/components/UserAvatar/index.tsx can leak unrelated fields and weakens type safety — pass only the fields the avatar needs (e.g., imageUrl, firstName, lastName) or change InternalUserAvatar to accept a single typed
user
prop.- Verification: InternalUserAvatar prop types were not found during verification — confirm its prop shape accepts the spread or update its API accordingly.
Fix incorrect error message in useUserAvatarContext (if present):
- if (!context || context.componentName !== 'UserAvatar') { - throw new Error('Clerk: useUserAvatarContext called outside ApiKeys.'); - } + if (!context || context.componentName !== 'UserAvatar') { + throw new Error('Clerk: useUserAvatarContext called outside UserAvatar.'); + }packages/react/src/isomorphicClerk.ts (1)
51-57
: Type-only import LGTM.Good adherence to type-only imports; keeps runtime bundle clean.
packages/clerk-js/sandbox/app.ts (3)
24-40
: Registering 'userAvatar' in AVAILABLE_COMPONENTS looks good.
86-102
: Controls wiring for 'userAvatar' is consistent with the rest.
292-294
: Route mounts UserAvatar correctly.Matches Clerk public API signature.
packages/clerk-js/src/ui/types.ts (1)
23-27
: Type surface updates for UserAvatar are coherent.
- Imports/exports added
- AvailableComponentProps/Ctx unions extended
- UserAvatarCtx defined
No issues spotted.
Also applies to: 29-43, 45-62, 96-99, 166-170
packages/types/src/clerk.ts (2)
1642-1646
: UserAvatarProps definition LGTM.Simple, clear surface; aligns with
UserAvatarTheme
.
18-21
: Theme import LGTM.Keeps appearance typing consistent across components.
packages/clerk-js/src/ui/contexts/components/index.ts (1)
15-16
: Re-exporting UserAvatar is correct and consistent with neighbors.packages/types/src/appearance.ts (1)
361-363
: Types wired for UserAvatar (elements, theme alias, and Appearance override) — OKElementsConfig entries,
UserAvatarTheme
, andappearance.userAvatar
are consistent with descriptors.If
UserAvatar
exposes loading/error UI states, consider adding state selectors (e.g.,WithOptions<never, 'loading'>
) so themes can target them. Please confirm whether the component sets any ofcl-loading
,cl-error
, etc.Also applies to: 973-973, 1009-1011
integration/templates/vue-vite/src/router.ts (1)
45-48
: UserAvatar route added — OKLazy import and naming are consistent with existing routes.
packages/testing/src/playwright/unstable/page-objects/index.ts (2)
18-18
: Import page object — OK
49-49
: ExposeuserAvatar
in page objects — OKAPI is consistent with other components.
integration/templates/next-app-router/src/app/user-avatar/page.tsx (1)
1-9
: Next.js page renders UserAvatar with fallback — OKFits App Router usage; fallback handled via prop.
packages/clerk-js/sandbox/template.html (1)
76-82
: Approve — User Avatar nav item wired correctlyAVAILABLE_COMPONENTS includes 'userAvatar' (packages/clerk-js/sandbox/app.ts ~24) and app.ts defines a '/user-avatar' route that mounts Clerk.mountUserAvatar(... ) (≈ lines 292–293). No changes required.
packages/clerk-js/src/ui/customizables/elementDescriptors.ts (1)
222-224
: Descriptors added (userAvatarBox
,userAvatarImage
) — approved.
Names produce .cl-userAvatarBox/.cl-userAvatarImage; usage confirmed in packages/clerk-js/src/ui/components/UserAvatar/index.tsx (lines 16–17) and test SELECTOR in packages/testing/src/playwright/unstable/page-objects/userAvatar.ts (line 5).
6c37561
to
64c7b73
Compare
378f06d
to
1f41968
Compare
Description
Adds a new
UserAvatar
component for React and Vue alongsideuserAvatar.goTo()
,userAvatar.waitForMounted()
, anduserAvatar.toBeVisible()
testing helpers.USER-2751
Checklist
pnpm test
runs as expected.pnpm build
runs as expected.Type of change
Summary by CodeRabbit
New Features
Sandbox
Public API
Tests