Skip to content

POC: feat: stable style for AtomLabelEditForm#75

Merged
tpoisseau merged 10 commits intomainfrom
72-ensure-stable-styling-accross-integrations
Dec 19, 2025
Merged

POC: feat: stable style for AtomLabelEditForm#75
tpoisseau merged 10 commits intomainfrom
72-ensure-stable-styling-accross-integrations

Conversation

@tpoisseau
Copy link
Contributor

  • minimal and optional css reset with <OclReset>
  • useCSS internal util to manage dynamic css

Refs: #72


Pro:

  • Light
  • No new build steps
  • No deps

Cons:

  • Rough DX
    • css in js strings (no autocomplete / color highlights)
    • hardcoded class to use in JSX and css.

@tpoisseau tpoisseau linked an issue Dec 15, 2025 that may be closed by this pull request
@tpoisseau tpoisseau changed the title feat: stable style for AtomLabelEditForm POC: feat: stable style for AtomLabelEditForm Dec 15, 2025
@tpoisseau tpoisseau requested a review from targos December 15, 2025 12:48
@targos
Copy link
Member

targos commented Dec 15, 2025

By reading https://react.dev/reference/react/useInsertionEffect, we should not use useInsertionEffect as we are not a CSS-in-JS library. I don't want us to create our own way of doing it (the documentation doesn't show how to do it correctly with CSSStyleSheet)

@cloudflare-workers-and-pages
Copy link

cloudflare-workers-and-pages bot commented Dec 15, 2025

Deploying react-ocl with  Cloudflare Pages  Cloudflare Pages

Latest commit: ab54cff
Status: ✅  Deploy successful!
Preview URL: https://244e744b.react-ocl.pages.dev
Branch Preview URL: https://72-ensure-stable-styling-acc.react-ocl.pages.dev

View logs

@tpoisseau
Copy link
Contributor Author

We are not a CSS-in-JS lib, but what is done here is similar to css-in-js.

But if we want to have this kind of feature (on-demand styling, optional reset) the best we can do is to integrate emotion to this lib. Because we have good knowledge of this lib and it has all features we needs.

@targos
Copy link
Member

targos commented Dec 15, 2025

I wonder if https://react.dev/reference/react-dom/components/style isn't actually the simple answer to just inject css at the level of the component render.

@tpoisseau
Copy link
Contributor Author

I will give it a try

@tpoisseau
Copy link
Contributor Author

Ok, So I finally moved OclReset to stories., the reset stylesheet comes from preflight react-science.

I tweaked atomLabelEditCss so it looks nearly identical with and without reset.

And I added a css tagged template literal helper + docs to enable CSS Language injection in js strings for webstorm. It's not perfect but it drastically improves DX with auto-complete and syntax highlight.

@tpoisseau tpoisseau requested a review from targos December 16, 2025 14:31
@tpoisseau tpoisseau requested a review from targos December 17, 2025 13:22
@tpoisseau
Copy link
Contributor Author

So, @targos do you prefer we merge as-is this POC, or do you prefer we use @emotion/styled ?

@targos
Copy link
Member

targos commented Dec 19, 2025

I discussed with Luc and if we are ok with using @emotion/styled if it makes the implementation simpler and if it works transparently for the end-user

@tpoisseau
Copy link
Contributor Author

With @emotion/styled the DX will be better and simpler related to DX.
With this PoC, it's transparent for the user because the styles are written to be similar with and without a reset stylesheet. And there is no css compilation and the components takes care to implement his styles.

@emotion/styled should keep theses advantages (works transparently for user of lib) and improve the DX at the cost of a new library in the final app bundle (mitigated because we already use this lib in our other libraries like react-science). The cost is for other users of react-ocl.

To conclude:

  • react-ocl is responsible to styled his own components to be compatible with and without reset stylesheet. No technology here to help us.
  • @emotion/styled to have a better DX and be transparent for apps using this lib.

@targos
Copy link
Member

targos commented Dec 19, 2025

Let's use @emotion/styled. You convinced me that it's generally better to keep something that we have experience with.

And it's not so large after all: https://bundlephobia.com/package/@emotion/styled@11.14.1

@tpoisseau
Copy link
Contributor Author

Done, But I wonder if I should use dependencies or peerDependencies. WDYT @targos

@targos
Copy link
Member

targos commented Dec 19, 2025

I think dependencies is good.

* move dependencies above devDependencies

Refs: #75 (comment)
Refs: #75 (comment)
@tpoisseau tpoisseau requested a review from targos December 19, 2025 13:10
@tpoisseau tpoisseau merged commit 4b4645c into main Dec 19, 2025
11 checks passed
@tpoisseau tpoisseau deleted the 72-ensure-stable-styling-accross-integrations branch December 19, 2025 15:45
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.

Ensure stable styling accross integrations

2 participants