-
Notifications
You must be signed in to change notification settings - Fork 402
fix(clerk-js): Variable line-height discrepancy #7112
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.
|
🦋 Changeset detectedLatest commit: 45f5c10 The changes in this PR will be included in the next version bump. This PR includes changesets to release 3 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 |
WalkthroughA changeset entry is added for @clerk/clerk-js with a patch version bump. Line-height values in the typography module are refactored from decimal strings to fractional expressions for improved consistency with font-sizing calculations and reduced cross-browser rendering differences. Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes
Poem
Pre-merge checks and finishing touches❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✨ Finishing touches
🧪 Generate unit tests (beta)
Comment |
|
!snapshot |
|
Hey @alexcarpenter - the snapshot version command generated the following package versions:
Tip: Use the snippet copy button below to quickly install the required packages. npm i @clerk/[email protected] --save-exact
npm i @clerk/[email protected] --save-exact
npm i @clerk/[email protected] --save-exact
npm i @clerk/[email protected] --save-exact
npm i @clerk/[email protected] --save-exact
npm i @clerk/[email protected] --save-exact
npm i @clerk/[email protected] --save-exact
npm i @clerk/[email protected] --save-exact
npm i @clerk/[email protected] --save-exact
npm i @clerk/[email protected] --save-exact
npm i @clerk/[email protected] --save-exact
npm i @clerk/[email protected] --save-exact
npm i @clerk/[email protected] --save-exact
npm i @clerk/[email protected] --save-exact
npm i @clerk/[email protected] --save-exact
npm i @clerk/[email protected] --save-exact
npm i @clerk/[email protected] --save-exact
npm i @clerk/[email protected] --save-exact
npm i @clerk/[email protected] --save-exact
npm i @clerk/[email protected] --save-exact
npm i @clerk/[email protected] --save-exact
npm i @clerk/[email protected] --save-exact |
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
🧹 Nitpick comments (1)
.changeset/twenty-sides-take.md (1)
1-5: LGTM! Changeset follows conventions.The patch version bump is appropriate for this bug fix, and the description clearly communicates the intent. Optionally, you could make the description more specific by mentioning the change from decimal to fractional format (e.g., "Updates line-height calculations from decimal strings to fractional expressions to align with font-sizing approach and reduce cross-browser rendering differences").
📜 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)
.changeset/twenty-sides-take.md(1 hunks)packages/clerk-js/src/ui/foundations/typography.ts(1 hunks)
🧰 Additional context used
📓 Path-based instructions (8)
.changeset/**
📄 CodeRabbit inference engine (.cursor/rules/monorepo.mdc)
Automated releases must use Changesets.
Files:
.changeset/twenty-sides-take.md
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/foundations/typography.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/foundations/typography.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/foundations/typography.ts
packages/**/*.{ts,tsx}
📄 CodeRabbit inference engine (.cursor/rules/development.mdc)
TypeScript is required for all packages
Files:
packages/clerk-js/src/ui/foundations/typography.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/foundations/typography.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/foundations/typography.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/foundations/typography.ts
🔇 Additional comments (1)
packages/clerk-js/src/ui/foundations/typography.ts (1)
23-27: LGTM! Consistent fractional format.The fractional expressions with decimal equivalents in comments provide good clarity. This format works correctly since these values are consumed within
calc()expressions (as seen on lines 34-38), where division is properly evaluated.
| extraSmall: '16 / 12', // = 1.33333 | ||
| small: '18 / 13', // = 1.38462 | ||
| medium: '24 / 17', // = 1.41176 | ||
| large: '16 / 11', // = 1.45455 |
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
Verify that lineHeight consumers support fractional expressions.
The fractional format (e.g., '16 / 12') aligns with the font-sizing approach used in FONT_SIZE_SCALE_RATIOS, but this is only valid CSS when wrapped in calc(). Unlike FONT_SIZE_SCALE_RATIOS (which are explicitly used inside calc() on lines 34-38), the consumption of lineHeights is not visible in this file.
Run the following script to verify how lineHeights are consumed and whether they're properly wrapped in calc():
🏁 Script executed:
#!/bin/bash
# Description: Find all usages of lineHeights to verify fractional format compatibility
# Search for lineHeights usage patterns
rg -n -C3 --type=ts --type=tsx 'lineHeights\.' packages/clerk-js/src/
# Also check for direct object access
rg -n -C3 --type=ts --type=tsx 'from.*typography.*lineHeights' packages/clerk-js/src/Length of output: 55
---
🏁 Script executed:
```shell
#!/bin/bash
# Description: Find lineHeights usage with corrected rg syntax
# Search for lineHeights imports and usages without type filters
rg -n -C3 'lineHeights' packages/clerk-js/src/ --glob='*.ts' --glob='*.tsx'
# Also search for where typography is imported
rg -n -C3 'from.*typography' packages/clerk-js/src/ --glob='*.ts' --glob='*.tsx'
# Search for calc\(\s*\$\{.*lineHeights to see if wrapped in calc
rg -n -C2 'calc.*lineHeights|lineHeights.*calc' packages/clerk-js/src/ --glob='*.ts' --glob='*.tsx'
Length of output: 8180
---
🏁 Script executed:
```shell
#!/bin/bash
# Description: Verify how typography style objects (h1, h2, etc.) are consumed
# Find where common.ts exports are used
rg -n -C3 'from.*common' packages/clerk-js/src/ui/ --glob='*.ts' --glob='*.tsx'
# Search for how typography preset styles are applied
rg -n 'h1|h2|h3|subtitle|body|caption|buttonLarge|buttonSmall' packages/clerk-js/src/ui/styledSystem/common.ts -A1 -B1
# Check if there's styled-system configuration that processes lineHeight
rg -n -C5 'lineHeight' packages/clerk-js/src/ui/styledSystem/ --glob='*.ts' --glob='*.tsx'
Length of output: 66783
---
🏁 Script executed:
```shell
#!/bin/bash
# Find how the typography presets from common.ts are exported and used
# Check what common.ts exports
rg -n 'export.*common' packages/clerk-js/src/ui/styledSystem/index.ts -A5
# Find usage of the typography presets (h1, h2, h3, subtitle, body, etc.)
rg -n '\bh1\b|\bh2\b|\bh3\b|\bsubtitle\b' packages/clerk-js/src/ui/ --glob='*.ts' --glob='*.tsx' -B2 -A2 | head -100
# Check if there's any CSS-in-JS library processing (e.g., styled-components, emotion)
rg -n 'css|styled' packages/clerk-js/src/ui/styledSystem/createVariants.ts -A5 | head -50
# Look for where lineHeight values get processed
rg -n 'lineHeight' packages/clerk-js/src/ui/styledSystem/createVariants.ts -B3 -A3
Length of output: 6998
---
🏁 Script executed:
```shell
#!/bin/bash
# Find textVariants function definition in common.ts
# Show the entire common.ts file to understand structure
cat packages/clerk-js/src/ui/styledSystem/common.ts
# Also check if there's any processing of lineHeight values elsewhere
rg -n 'textVariants' packages/clerk-js/src/ui/ --glob='*.ts' --glob='*.tsx' -B2 -A2
Length of output: 12688
Wrap lineHeight values in calc() to fix invalid CSS syntax.
The fractional format (e.g., '16 / 12') used in lineHeights is invalid CSS syntax unless wrapped in calc(). Unlike FONT_SIZE_SCALE_RATIOS, which are properly wrapped in calc() on lines 34-38 of packages/clerk-js/src/ui/foundations/typography.ts, the lineHeights values are spread directly into style objects without calculation wrapping. This will cause browsers to reject these values and fall back to inherited line-height, breaking the intended typography scaling.
Update lineHeights in packages/clerk-js/src/ui/foundations/typography.ts (lines 12-15) to wrap fractional expressions in calc():
extraSmall: 'calc(16 / 12)', // = 1.33333
small: 'calc(18 / 13)', // = 1.38462
medium: 'calc(24 / 17)', // = 1.41176
large: 'calc(16 / 11)', // = 1.45455🤖 Prompt for AI Agents
In packages/clerk-js/src/ui/foundations/typography.ts around lines 12 to 15, the
lineHeights entries use raw fractional strings like '16 / 12' which are invalid
CSS when emitted into style objects; wrap each fractional expression in calc(),
e.g. change '16 / 12' to 'calc(16 / 12)' (and similarly for '18 / 13', '24 /
17', '16 / 11') so the generated CSS is valid and browsers compute the intended
numeric line-height.
Description
Updates line-height calculations to follow font-sizing approach to fix discrepancies between browsers.
Checklist
pnpm testruns as expected.pnpm buildruns as expected.Type of change
Summary by CodeRabbit