Skip to content

Promote inline style props for direct JSX resolution#393

Draft
skovhus wants to merge 5 commits intomainfrom
cursor/promote-inline-style-props-direct-jsx-3e1d
Draft

Promote inline style props for direct JSX resolution#393
skovhus wants to merge 5 commits intomainfrom
cursor/promote-inline-style-props-direct-jsx-3e1d

Conversation

@skovhus
Copy link
Copy Markdown
Owner

@skovhus skovhus commented Apr 20, 2026

Direct JSX usages of imported components (like <Flex>) now promote inline style={{...}} objects into stylex.create entries on the sx prop instead of falling back to mergedSx. Static values are routed through the authoritative cssDeclarationToStylexDeclarations helper so any supported shorthand (padding, margin, background, border, …) is expanded into longhands; promotion is gated by a small denylist of multi-component shorthands StyleX rejects (font, animation, transition, grid, inset, …) — anything else is allowed through and StyleX's valid-styles/TypeScript types remain the source of truth for typo errors. Promotion also bails when the styled decl carries wrapper-scoped artifacts that can't be re-evaluated at the call site.

Open in Web Open in Cursor 

Direct JSX usages of imported components (like <Flex>) now promote inline style={{...}} objects into stylex.create entries instead of falling back to mergedSx. Multi-value padding/margin shorthands are expanded to their longhand form so StyleX accepts them.

Co-authored-by: Kenneth Skovhus <skovhus@users.noreply.github.com>
@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Apr 20, 2026

PR Preview Action v1.8.1

🚀 View preview at
https://skovhus.github.io/styled-components-to-stylex-codemod/pr-preview/pr-393/

Built to branch gh-pages at 2026-04-21 00:07 UTC.
Preview will be ready when the GitHub Pages deployment is complete.

cursoragent and others added 4 commits April 20, 2026 17:41
Co-authored-by: Kenneth Skovhus <skovhus@users.noreply.github.com>
Promotion of inline style props now routes static values through cssDeclarationToStylexDeclarations, the authoritative CSS-to-StyleX mapping. This expands every supported shorthand (background, border, padding, margin, …), not just directional ones, and bails out only when the helper cannot fully decompose the shorthand. Promotion is also skipped when the styled decl carries wrapper-scoped artifacts (inlineStyleProps, extraStylexPropsArgs/StyleKeys, conditional styleFnFromProps) since inlining the call site would emit unresolved wrapper-internal identifiers.

Co-authored-by: Kenneth Skovhus <skovhus@users.noreply.github.com>
Adds an explicit set of camelCase CSS properties (PROMOTABLE_STYLE_PROPS) covering the common React inline-style surface (layout, spacing, longhand borders, background longhands, typography, visual effects, transforms, transitions). Promotion bails when the input key—or any expanded longhand—falls outside the allowlist, so unvetted properties stay as inline styles via mergedSx instead of silently emitting unverified StyleX entries.

Co-authored-by: Kenneth Skovhus <skovhus@users.noreply.github.com>
Replaces the curated PROMOTABLE_STYLE_PROPS allowlist (~200 entries) with a small NON_PROMOTABLE_STYLE_PROPS denylist of multi-component shorthands StyleX rejects when given multiple tokens (font, animation, transition, grid, grid-area, grid-template, border-block, border-inline, inset, all). Anything else is allowed through; StyleX's valid-styles plugin and TypeScript types remain the source of truth for typo/unsupported-prop errors. Adds a cross-reference test that keeps the denylist in sync with NOT_APPLICABLE_SHORTHANDS.

Co-authored-by: Kenneth Skovhus <skovhus@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants