davesnx / styled-ppx

Type-safe styled components for ReScript, Melange and native with type-safe CSS
https://styled-ppx.vercel.app
BSD 2-Clause "Simplified" License
401 stars 32 forks source link

[Feature request] JSX version 4 #327

Closed whitchapman closed 9 months ago

whitchapman commented 1 year ago

I use this ppx with Rescript, and the error message I get when attempting to use version 4 is:

  The record field children can't be found.

  If it's defined in another module or file, bring it into scope by:
  - Prefixing it with said module name: TheModule.children
  - Or specifying its type:
  let theValue: TheModule.theType = {children: VALUE}

Thanks!

ashton commented 1 year ago

Is there anything we can help with that? I don't have knowledge creating PPX but if there is some guide of manual work that is needed I can help with.

davesnx commented 1 year ago

There are a few doubts from my side, help resolving those might make the feature available very soon (depending on the answers obviously!).

davesnx commented 1 year ago

I posted an issue for the ReScript team about some technical issue with the generation of props, If anyone have a good idea, tune in. Let's see how this goes, but meanwhile would love to know some opinions on the above.

The post is https://forum.rescript-lang.org/t/ann-new-nightly-release-of-styled-ppx-working-with-jsx4/4331/2,

davesnx commented 1 year ago

I published a new alpha version that has dynamic components broken, the rest should work as expected.

npm install @davesnx/styled-ppx@0.35.1-f167a44.0

davesnx commented 1 year ago

Pushed a new version with most of the fixes, should be a little stable now.

npm install @davesnx/styled-ppx@nightly

A few things to take into account:

davesnx commented 1 year ago

I merged the PR with JSX4 support (v0.35), it's currently in beta and append here any issue you find with it.

whitchapman commented 1 year ago

Thanks for doing this. Unfortunately, I still get the exact same compile error when setting jsx to version 4 using version 0.35 of the ppx. It's possible that I am missing something basic. EDITED: removed superfluous comments

davesnx commented 1 year ago

Ok, miss-typed the version and forgot to publish it. It's 0.36. Can you try updating?

whitchapman commented 1 year ago

Ok, miss-typed the version and forgot to publish it. It's 0.36. Can you try updating?

Yes, that did it. Outstanding!

ashton commented 1 year ago

Hello @davesnx! First let me thank you for being so quick and prestative! I don't know if I'm doing something wrong, but when I do:

module CardBody = %styled.div(`
  display: flex;
  justify-content: space-between;
`)

@react.component
let make = () => {
  <CardBody className="card-body">
     {"... many children here"}
  </CardBody>
}

Using the option at bsconfig.json:

{"jsx": {"version": 4, "mode": "classic"}}

It should render the CardBody component with the generated class name for the style that I provided using the %styled extension, and also concatenate it with the class name that I provide in the className argument right?

That is not what is happening:

image image

I'm using the 0.36.2 version of styled-ppx

davesnx commented 1 year ago

Right, it seems like className isn't appended. Will have a look.

Thanks for trying it <3

ashton commented 1 year ago

Heeey, any news?

davesnx commented 1 year ago

Pushed 0.38.1 fixing the className issue. Thanks for the testing!

davesnx commented 1 year ago

The missing piece on JSX4 is the new JSX transformation.

davesnx commented 11 months ago

Hey @ashton @whitchapman

Do you have any OSS repository with ReScript that is using v11?

ashton commented 10 months ago

Do you have any OSS repository with ReScript that is using v11?

Hey, I don't think v11 is out yet, but as soon as it gets released I'll update my projects with it

davesnx commented 9 months ago

Finishing the v11 support on https://github.com/davesnx/styled-ppx/issues/415

JSX4 should work nice