Skip to content

StyleX plug-in for resolving atomic styles to values for props.xstyle#22808

Merged
bvaughn merged 4 commits into
facebook:mainfrom
bvaughn:devtools-internal-xstyle-prop
Dec 8, 2021
Merged

StyleX plug-in for resolving atomic styles to values for props.xstyle#22808
bvaughn merged 4 commits into
facebook:mainfrom
bvaughn:devtools-internal-xstyle-prop

Conversation

@bvaughn
Copy link
Copy Markdown
Contributor

@bvaughn bvaughn commented Nov 22, 2021

Adds the concept of "plugins" to the inspected element payload. Also adds the first plugin, one that resolves StyleX atomic style names to their values and displays them as a unified style object (rather than a nested array of objects and booleans).

Note the new "stylex" panel below the props panel. Source file names are displayed first, in dim color, followed by an ordered set of resolved style values:
Screen Shot 2021-12-07 at 1 21 06 PM

A more complex set of styles (from multiple sources) can be seen here:
Screen Shot 2021-12-07 at 1 21 30 PM

Compare the new display to the behavior of viewing the xstyle prop directly:
Screen Shot 2021-12-07 at 1 21 56 PM

For builds with the new feature flag disabled, there is no observable change.

A next step to build on top of this could be to make the style values editable, but change the logic such that editing one directly added an inline style to the item (rather than modifying the stylex class– which may be shared between multiple other components).

@facebook-github-bot facebook-github-bot added CLA Signed React Core Team Opened by a member of the React Core Team labels Nov 22, 2021
@sebmarkbage
Copy link
Copy Markdown
Contributor

Fwiw, I'm going to open a PR with a proposal to change stylex to a plain object.

@bvaughn
Copy link
Copy Markdown
Contributor Author

bvaughn commented Nov 24, 2021

Fwiw, I'm going to open a PR with a proposal to change stylex to a plain object.

@sebmarkbage Can you elaborate a little here to help me understand what the proposed change is, how long it until it might land, how likely it is to land, etc.

This feature was requested by FB engineers working with StyleX, along with a few others (which I haven't pushed yet) to help them with every day productivity issues.

@bvaughn bvaughn force-pushed the devtools-internal-xstyle-prop branch from 167b67e to 5854587 Compare December 7, 2021 16:41
@bvaughn bvaughn marked this pull request as ready for review December 7, 2021 17:42
@bvaughn bvaughn requested review from jstejada and lunaruan December 7, 2021 17:45
@bvaughn bvaughn force-pushed the devtools-internal-xstyle-prop branch 2 times, most recently from 26f9579 to ac638f1 Compare December 7, 2021 18:44
@necolas
Copy link
Copy Markdown
Contributor

necolas commented Dec 7, 2021

stylex's babel plugin can inline classnames with no style object left in the code, e.g., className="krdjnda erwlkre"

I wonder if we might have better options for identifying all stylex data defined using stylex.create rather than only the xstyle convention in Comet.

@bvaughn
Copy link
Copy Markdown
Contributor Author

bvaughn commented Dec 7, 2021

stylex's babel plugin can inline classnames with no style object left in the code, e.g., className="krdjnda erwlkre"

I'm not sure how we would detect the presence of StyleX (vs any other styling library) in that scenario. Any ideas?

I wonder if we might have better options for identifying all stylex data defined using stylex.create rather than only the xstyle convention in Comet.

Trying to limit the scope of this change by rolling it out within Facebook only, for starters.

I like this suggestion in the longer term, although I'm also not sure of a way (currently) to identify values created by stylex.create.

Copy link
Copy Markdown
Contributor

@jstejada jstejada left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm!

Comment thread packages/react-devtools-shared/src/devtools/views/Components/types.js Outdated
Brian Vaughn added 4 commits December 7, 2021 19:13
Only enabled for FB builds (for now)
And display it separately in DevTools, as read-only (for now)
Moved StyleX plugin type to be shared. Replaced Array-of-plugins type with object type, since the frontend already needs to know about which types it supports anyway (so no need to do unnecessary filtering).
@bvaughn bvaughn force-pushed the devtools-internal-xstyle-prop branch from ac638f1 to 6b9eb2b Compare December 8, 2021 00:37
@bvaughn bvaughn merged commit ad60746 into facebook:main Dec 8, 2021
@bvaughn bvaughn deleted the devtools-internal-xstyle-prop branch December 8, 2021 01:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CLA Signed Component: Developer Tools React Core Team Opened by a member of the React Core Team