Repository navigation
Conversation
styled-ppx now carries the binding name as the third element of the CSS.styles carrier. When the ppx expands styles= on a lowercase element it also emits ?part from CSS.label, only when the label is non-empty, and an explicit part prop merges with it the way className does. Native and Melange mode share the expansion; the Melange side needs ReactDOM.domProps to accept ~part.
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
BenchmarksNo baseline from
|
This branch was successfully deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
styled-ppx's next snapshot (davesnx/styled-ppx#614 and the stack below it) turns the
CSS.stylescarrier into(className, style, label), where the label is the binding name, and renders that label as the element'spartattribute so styles stay findable in DevTools ([part~="Button"]) now that class names carry no label suffix. Styled components do that themselves; lowercase elements withstyles=are expanded here, so the ppx has to emit it too.Styles_attribute.expand_attributesnow adds?partnext toclassNameandstyle:?styleskeepspartoptional through theNonecase.partprop merges with the label the wayclassNamemerges (part="Button host");merge_classNamebecamemerge_string_attribute nameso both share one implementation.?partreachesReactDOM.domProps, which does not accept~partin reason-react 0.17 yet, so that side needs a reason-react change before this can be released. Draft until that lands or until we decide to gate the Melange emission.Requires a styled-ppx runtime that defines
CSS.label.Tests
At c3eae9a, OCaml 5.4.0, quickjs 0.5.1, melange 7.0.1, ocamlformat 0.28.1:
dune build @packages/styles-attribute/runtest: 7 tests, including the newexpand_styles_with_previous_part.dune build @packages/server-reason-react-ppx/runtest: 72 tests; theCSSstub is a triple now, withstyles_attribute_with_label,styles_attribute_with_label_and_partandstyles_attribute_optional_some_with_labelassertingpart="Button",part="Button host"andpart="Card"in the rendered HTML. Cram expectations forstyles,styles-native,styles-jsandoptional-prop-shadowed-nonewere promoted and reviewed; the only change is the addedpartbranch.dune build @runtest: everything passes exceptpackages/router/test/browser, which needsnpm installin that checkout.dune build @fmton the touched directories: clean.Risk: two-way door. Reverting restores the
className/style-only expansion. Merging as is breaks Melange builds that usestyles=on lowercase elements until reason-react'sdomPropsaccepts~part.