-
Notifications
You must be signed in to change notification settings - Fork 460
feat(ui): migrate Mosaic Heading and Text to StyleX #9244
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?
Changes from all commits
767bebc
03043ed
9c01700
d97f67c
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,2 @@ | ||
| --- | ||
| --- | ||
This file was deleted.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,7 @@ | ||
| import * as stylex from '@stylexjs/stylex'; | ||
|
|
||
| import { fontWeightVars } from '../../tokens.stylex'; | ||
|
|
||
| export const styles = stylex.create({ | ||
| base: { fontWeight: fontWeightVars['--cl-font-semibold'] }, | ||
| }); |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,71 @@ | ||
| import { render, screen } from '@testing-library/react'; | ||
| import React from 'react'; | ||
| import { describe, expect, it } from 'vitest'; | ||
|
|
||
| import { Heading, HeadingContext } from './heading'; | ||
|
|
||
| describe('Mosaic Heading', () => { | ||
| it('renders an h2 with its children', () => { | ||
| render(<Heading>Title</Heading>); | ||
| expect(screen.getByRole('heading', { level: 2, name: 'Title' })).toBeInTheDocument(); | ||
| }); | ||
|
|
||
| it('applies default variants when none are passed', () => { | ||
| render(<Heading>Title</Heading>); | ||
| const heading = screen.getByRole('heading'); | ||
| expect(heading).toHaveClass('cl-heading'); | ||
| expect(heading).toHaveAttribute('data-size', 'base'); | ||
| expect(heading).toHaveAttribute('data-intent', 'primary'); | ||
| }); | ||
|
|
||
| it('wires variant props and consumer className/style through to the element', () => { | ||
| render( | ||
| <Heading | ||
| size='2xl' | ||
| intent='destructive' | ||
| className='my-heading' | ||
| style={{ marginTop: '8px' }} | ||
| > | ||
| Title | ||
| </Heading>, | ||
| ); | ||
| const heading = screen.getByRole('heading'); | ||
| expect(heading).toHaveAttribute('data-size', '2xl'); | ||
| expect(heading).toHaveAttribute('data-intent', 'destructive'); | ||
| expect(heading).toHaveClass('cl-heading', 'my-heading'); | ||
| expect(heading).toHaveStyle({ marginTop: '8px' }); | ||
| }); | ||
|
|
||
| it('renders a different element through the render prop, keeping the slot props', () => { | ||
| render(<Heading render={p => <h3 {...p} />}>Title</Heading>); | ||
| const heading = screen.getByRole('heading', { level: 3 }); | ||
| expect(heading).toHaveClass('cl-heading'); | ||
| expect(heading).toHaveAttribute('data-size', 'base'); | ||
| }); | ||
|
Comment on lines
+39
to
+44
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win Cover the React-element
🤖 Prompt for AI AgentsSource: Coding guidelines |
||
|
|
||
| it('reads defaults from HeadingContext, with own props winning', () => { | ||
| render( | ||
| <HeadingContext.Provider value={{ size: 'xl', intent: 'mutedForeground' }}> | ||
| <Heading intent='destructive'>Title</Heading> | ||
| </HeadingContext.Provider>, | ||
| ); | ||
| const heading = screen.getByRole('heading'); | ||
| expect(heading).toHaveAttribute('data-size', 'xl'); | ||
| expect(heading).toHaveAttribute('data-intent', 'destructive'); | ||
| }); | ||
|
|
||
| it('forwards arbitrary props and the ref', () => { | ||
| const ref = React.createRef<HTMLHeadingElement>(); | ||
| render( | ||
| <Heading | ||
| ref={ref} | ||
| id='section-title' | ||
| > | ||
| Title | ||
| </Heading>, | ||
| ); | ||
| const heading = screen.getByRole('heading'); | ||
| expect(ref.current).toBe(heading); | ||
| expect(heading).toHaveAttribute('id', 'section-title'); | ||
| }); | ||
| }); | ||
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.
📐 Maintainability & Code Quality | 🟠 Major | ⚡ Quick win
Add a non-empty changeset for the Mosaic package change.
This suppresses release metadata despite changes to
@clerk/uicomponent behavior and customization. Add the appropriate package bump and a user-facing summary; reserve empty changesets for tooling-only work. As per coding guidelines, “usepnpm changesetfor package changes” and use an empty changeset only when there is no user-facing impact.🤖 Prompt for AI Agents
Source: Coding guidelines